Stackmaven
Beat report Published 21d ago ·

npm Trusted Publishing trusted repository names, not IDs, and 1,500 packages were open to takeover

Bloom Security showed that npm Trusted Publishing bound packages to a GitHub owner/repo name, so anyone reclaiming a freed name could publish. GitHub now expires unvalidated bindings after 48 hours, but maintainers still need to audit theirs with npm trust list.

By Stackmaven

npm Trusted Publishing was supposed to remove the weakest link in package releases: long-lived publish tokens sitting in CI secrets. Research disclosed on October 13 shows it introduced a different weak link. Until GitHub changed the rules on October 2, npm decided who could publish a package by matching a GitHub repository’s name, and names on GitHub can be given up and claimed by someone else.

How the flaw worked

When a maintainer runs npm trust github --allow-publish, npm stores three things: the repository’s owner/repo slug, the workflow filename, and an optional environment. At publish time, GitHub Actions mints an OIDC token, and npm exchanges it for a short-lived publish credential if the claims match.

Bloom Security found that npm compared the slug and workflow name but ignored the immutable repository_id and repository_owner_id claims that the same token carries, until a binding’s first successful publish. A slug is freed whenever a repository is renamed, transferred, or deleted, or when its owner account is renamed or deleted. An attacker who found a binding pointing at a free, never-published slug could create a repository there, add a workflow with the matching filename, mint a token, and publish a new version of someone else’s package. No maintainer, npm, or GitHub credentials were needed.

Bloom says it reproduced the attack end to end against a scope it controlled, publishing from a second organization’s repository linked only by the reclaimed slug. Its registry-wide scan found more than 1,500 exposed packages with over 10 million total downloads, including security scanners, authentication tools, and cryptographic libraries, according to CSO Online. Bloom reported no exploitation in the wild.

One detail makes this worse than a typical token leak: the malicious release would be signed by Sigstore against the attacker’s repository. A provenance check that only confirms an attestation exists would pass.

What GitHub changed

GitHub’s changelog, dated October 2, says unvalidated npm trusted publishing configurations now expire 48 hours after creation and can no longer authorize publishing. A configuration becomes validated, and exempt from expiry, after its first successful publish. Changing the repository or project identity starts a new 48-hour window. npm also now rejects trusted publishing tokens from GitHub Actions issue_comment events, alongside the existing pull_request_target restriction.

Bloom says it reported the issue through GitHub’s HackerOne program on June 6, saw it triaged on June 9, and then received no substantive updates before the fix shipped. It describes the 48-hour expiry as narrower than the fix it recommended: resolving the slug to immutable IDs when the binding is created and requiring exact matches at exchange time, which Bloom says PyPI already does.

What remains unclear

GitHub’s changelog does not say explicitly how unvalidated configurations created before October 2 were handled, and Bloom says npm’s GitLab trusted publishing integration had the same weakness without describing a GitLab-specific fix. Neither point changes the core finding, but both are reasons not to assume every old binding is now safe.

What maintainers should do

For anyone publishing to npm with Trusted Publishing, the audit is short:

  • Run npm trust list for each package and confirm every bound repository still exists under an owner you control.
  • Delete and recreate any binding that points at a renamed or transferred repository.
  • Remove a binding before deleting, transferring, or renaming the repository it points to.
  • Publish right after creating a new binding so it validates instead of sitting open.
  • Watch for publish events you did not trigger.

For consumers, the practical lesson is that provenance only helps when you check its contents. Verifying that a package’s attestation names the expected source repository, not merely that an attestation exists, is what would have caught a SlugFest-style release.

WorkOS’s analysis draws the general rule: authorization keyed on renameable strings, such as org slugs, usernames, or email addresses, can be hijacked the same way. Anyone building OIDC trust policies for their own CI or cloud roles should match on system-assigned IDs where the identity provider exposes them.

Bloom also measured about 70 agent-installed packages per endpoint each month, rising to around 350 on developer machines. As AI coding agents add dependencies with less human review, a trusted-but-hijacked release has a shorter path into production, and identity checks in the publishing pipeline carry more of the load.

Sources cited
  1. Unvalidated npm trusted publishing configurations now expire (GitHub Changelog) github.blog
  2. SlugFest: Millions of AI Agents Install npm Packages Exposed to Malicious Takeover through GitHub (Bloom Security) bloom.security
  3. Over 1,500 npm packages exposed by trusted publishing validation flaw (CSO Online) www.csoonline.com
  4. GitHub Tightens npm Publishing After Flaw Left 1,500+ Packages Vulnerable to Hijacking (The Hacker News) thehackernews.com
  5. SlugFest: The npm Trusted Publishing flaw that trusted names, not IDs (WorkOS) workos.com
esc