Join our Newsletter — 33% off our NHI Course
Home› FAQ› Authentication, Authorisation & Trust› How does trusted publishing work with OIDC tokens?
Authentication, Authorisation & Trust

How does trusted publishing work with OIDC tokens?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated November 25, 2026 Domain: Authentication, Authorisation & Trust

Trusted publishing uses an OIDC token from the build or release workflow to prove the package was produced by an authorised pipeline, then exchanges that short-lived assertion for publish rights without storing a long-lived secret. The package registry checks the token claims, such as issuer, audience, repository or workflow identity, before accepting the upload.

What OIDC is doing in the trusted publishing flow

Trusted publishing is not just “using OIDC” in a generic sense, it is a specific trust exchange. The workflow presents a short-lived OIDC assertion that identifies the build or release pipeline, and the registry uses those claims to decide whether that pipeline is allowed to publish. The important security property is that the workflow proves context at publish time without carrying a reusable secret.

The registry is therefore trusting the identity of the workflow run, not a stored password or token copied into the environment. In practice, that means the issuer, audience and repository or workflow claims must line up with what the registry expects before the publish request is accepted. The better mental model is “ephemeral proof plus policy check”, not “token as a permanent credential”.

This is why trusted publishing is most useful in build and release automation. It removes the need to inject a long-lived publish secret into CI, which reduces the blast radius of a leaked runner, a malicious dependency, or a compromised job step. The registry only accepts a narrowly scoped assertion from the right pipeline context, rather than a standing credential that can be reused later.

Why claim checking matters more than the token format

The security decision is made on the claims carried inside the OIDC assertion, so claim design is part of the control. If the registry does not verify the expected issuer, audience, repository, environment or workflow identity, an attacker can try to replay or substitute an assertion from a different context. The token is short-lived, but short-lived alone does not make it trustworthy.

That is also why audience restriction and workflow scoping matter. The token should be valid only for the intended registry and only for the intended publishing path. If the same assertion can be used across multiple services, environments or pipelines, the trust boundary gets wider than the release process you meant to protect.

In OAuth 2.0 and OpenID Connect Guide for Identity Teams, the underlying OIDC mechanics are explained in more detail, and that context helps here because trusted publishing depends on the same basic assertion model. For supply-chain specific implementation guidance, CI/CD Pipeline Identity Security Guide is the most direct match for keyless OIDC federation and publishing-token removal.

What happens when trusted publishing fails or is bypassed

Trusted publishing fails when the registry cannot reliably distinguish an authorised pipeline from an unauthorised one. Common causes include overly broad workflow identity, weak environment controls, mis-scoped audiences, or fallback paths that still allow legacy tokens. If any of those gaps exist, the system can drift back toward the old secret-based model even when OIDC is enabled.

The practical threat is credential theft and pipeline abuse. If an attacker compromises a build job, they may be able to steal the assertion while it is valid, alter the workflow so it requests a publish, or use the pipeline’s own trust to ship a malicious release. That is why trusted publishing should be treated as part of release integrity, not just as a convenience feature.

For an attack-path view of this problem, Megalodon GitHub Actions attack 2026 shows how compromised workflow identity can be turned into secret theft and release abuse. Shai-Hulud npm worm first wave 2025 and Mini Shai-Hulud SAP npm attack 2026 both illustrate why removing standing publishing secrets matters when the publication path itself becomes a target.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Non-Human Identity Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 sets the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementOIDC publish assertions replace long-lived secrets with short-lived authentication material.
IA-9 — Service Identification and AuthenticationThe pipeline authenticates as a non-human workload to the registry.
AC-6 — Least PrivilegeTrusted publishing should grant only the minimal publish rights for one workflow path.
Recommendation — Use IA-5 to rotate, limit and retire publishing credentials and assertions. Use IA-9 to authenticate CI/CD jobs and other services with scoped trust. Use AC-6 to constrain publish permissions to the minimum workflow scope.
OWASP Non-Human Identity Top 10NHI-04 — Insecure AuthenticationOIDC claim validation is the core defence against forged or mis-scoped publish assertions.
NHI-07 — Long-Lived SecretsTrusted publishing is adopted to remove standing publish tokens from CI/CD.
NHI-05 — Overprivileged NHIA workflow that can publish too broadly increases blast radius if abused.
Recommendation — Validate issuer, audience and workflow claims before accepting a publish assertion. Replace persistent publish secrets with short-lived OIDC-based exchange. Restrict each pipeline identity to the smallest publish scope needed.

Practitioner Guidance

What to verify: Confirm that the registry checks the exact claims you intend to trust, especially issuer, audience and workflow or repository identity. If any legacy secret-based publish path still exists, treat it as a parallel control that can undermine the trusted publishing model.

Decision rule: If a package can be published without a long-lived secret, prefer OIDC-based trusted publishing; if the registry or workflow cannot enforce strict claim validation, treat the setup as partially migrated rather than fully trusted.

What good looks like: The publish job is ephemeral, narrowly scoped and attributable to one pipeline context, and no reusable registry secret is required to release a package. The workflow can publish only when it presents the right identity claims to the right registry.

Practitioner takeaway: Trusted publishing is valuable because it moves publish authority from stored secrets to verifiable workflow identity, but its security depends on strict claim validation and tight pipeline scoping, not on OIDC alone.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org