Join our Newsletter — 33% off our NHI Course
Home FAQ Cyber Security How should security teams implement Trusted Publishing for…
Cyber Security

How should security teams implement Trusted Publishing for npm packages in CI pipelines?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated August 27, 2026 Domain: Cyber Security

Security teams should replace long-lived npm tokens with short-lived OIDC-based publishing credentials, then restrict pipeline permissions so only trusted release workflows can mint them. The practical goal is to remove persistent secrets from repos and runners, because token theft becomes much harder when credentials expire quickly and cannot be reused outside the intended build step.

Why This Matters for Security Teams

trusted publishing changes the risk profile of npm release automation by removing the need to store durable publishing secrets in CI. That matters because package publishing is a high-value path for supply chain compromise, and a single leaked token can allow malicious releases, dependency poisoning, or account takeover of a maintenance workflow. Security teams should treat this as a control design problem, not just a developer convenience feature.

The key shift is from static credentials to short-lived identity assertions issued at build time. That aligns well with NIST SP 800-53 Rev 5 Security and Privacy Controls, especially where least privilege, access enforcement, and auditability are already expected. It also reduces the blast radius of runner compromise, because the CI job only needs enough authority to publish one package, one time, under tightly defined conditions.

Practitioners often get this wrong by focusing only on the token format and ignoring workflow trust boundaries, branch protections, and repository ownership checks. In practice, many security teams encounter package compromise only after a release workflow or maintainer account has already been abused, rather than through intentional control design.

How It Works in Practice

Trusted Publishing for npm typically relies on OpenID Connect, where the CI system presents a signed identity assertion to npm during release. npm validates claims about the workflow, repository, and environment, then issues a short-lived authorization for publishing instead of requiring a long-lived secret in the runner. The implementation goal is simple: prove that a specific, approved pipeline executed the release step, and nothing else.

A sound rollout usually includes these controls:

  • Enable OIDC in the CI platform and map the identity claims to the exact repository, branch, or release environment permitted to publish.
  • Remove npm automation tokens from repository secrets, runner images, and shared secret stores once Trusted Publishing is in place.
  • Restrict the publishing job to protected branches, protected tags, or an approved release workflow with required reviews.
  • Separate build and publish stages so only the final release step can request publishing authority.
  • Log the identity assertion, workflow run, package name, and version for later audit and incident response.

Security teams should pair this with repository integrity checks and release governance. The build must come from trusted source, the package metadata must match the intended release, and maintainers should verify that provenance links back to the expected automation identity. NIST guidance on secure software development and identity assurance is useful here, and npm’s own Trusted Publishing documentation should be reviewed alongside internal change control. Trusted Publishing is strongest when it is part of a broader software supply chain control set, not a single isolated setting. These controls tend to break down in highly shared CI environments because broad runner permissions and ambiguous workflow ownership make claim binding unreliable.

Common Variations and Edge Cases

Tighter publishing controls often increase release friction, requiring organisations to balance supply chain assurance against developer throughput. That tradeoff is acceptable for production packages, but it can be cumbersome for multi-package monorepos, fork-based contributions, or release trains that do not map cleanly to a single trusted workflow.

There is no universal standard for every CI platform’s OIDC claim set, so best practice is evolving. Some environments support precise audience and subject matching, while others require extra guardrails around job permissions, environment approval, and branch protections. Security teams should not assume that enabling OIDC alone eliminates release risk if the workflow itself can be modified by untrusted contributors.

Edge cases also appear when organisations publish from self-hosted runners, reusable workflows, or mirrored repositories. In those cases, the trust decision depends on who can alter the workflow definition, how secrets are isolated, and whether the CI identity can be replayed outside the intended context. For broader software supply chain assurance, it is worth aligning release governance with NIST Secure Software Development Framework practices and, where applicable, OWASP supply chain and automation guidance for modern delivery pipelines.

Standards & Framework Alignment

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

OWASP Agentic AI Top 10 and OWASP Non-Human Identity Top 10 address the attack and risk surface, while NIST CSF 2.0, NIST AI RMF and NIST SP 800-53 Rev 5 set the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST CSF 2.0PR.AC-4Trusted publishing depends on least-privilege release access and tight identity enforcement.
NIST AI RMFAI RMF is relevant when CI or release automation uses AI-assisted code or workflow decisions.
OWASP Agentic AI Top 10Agentic automation can widen release risk if tools or workflows can publish without strong guardrails.
OWASP Non-Human Identity Top 10CI identities acting as machine principals need lifecycle and secretless governance.
NIST SP 800-53 Rev 5IA-2Publishing should rely on strong identity assertion rather than reusable secrets.

Treat pipeline identities as managed non-human identities with scoped, revocable publishing rights.

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