npm Trusted Publishing Flaw Enables Unauthorized Package Takeover
What It Is
Bloom Security discovered a design flaw in npm’s Trusted Publishing feature that lets an attacker publish new versions of a maintainer’s package without ever possessing the maintainer’s credentials. Trusted Publishing, generally available since July 2025, replaces long‑lived publishing tokens with short‑lived, GitHub‑issued identity tokens. A maintainer registers a specific GitHub repository (identified by its slug, e.g., owner/repo) and a workflow file that may publish the package. When the workflow runs, GitHub signs an identity token that npm exchanges for a publish credential that expires after a few minutes.
The vulnerability stems from npm’s reliance on the repository slug alone to validate the token. GitHub also embeds a permanent numeric repository ID in the token, but npm never checks this ID. If a maintainer renames, transfers, or deletes the bound repository—or if the owning GitHub account is renamed or deleted—the original slug becomes available for anyone to claim. An attacker can create a new repository with the freed slug, add a workflow file with the expected name, and receive a valid publish credential for the target npm package. The credential is indistinguishable from a legitimate one, and the resulting release carries a valid provenance attestation that names the attacker’s repository as the source.
Bloom proved the attack end‑to‑end on a test package they controlled. By registering a second organization’s repository under the reclaimed slug, they published a malicious version that included a post‑install script. Because npm automatically executes post‑install scripts on every machine that installs the package, a single hijacked package could deliver malicious code to any downstream consumer.
The researchers identified more than 1,500 npm packages exposed by this flaw, collectively accounting for over 10 million downloads to date and more than 1 million downloads per month. While the average package sees only a few hundred monthly installs, the risk is binary: a single compromised package can affect every downstream project that depends on it, directly or indirectly.
GitHub, which owns npm, responded by updating the Trusted Publishing flow. As of the October 2, 2026 release, unvalidated Trusted Publishing configurations now expire after 48 hours and can no longer authorize publishing. npm’s documentation also states that a configuration’s first successful publish now binds it to the repository’s immutable numeric ID, preventing future slug‑reuse attacks. It remains unclear whether existing configurations created before the fix were retroactively re‑bound, and Bloom reports no evidence of active exploitation in the wild.
The disclosure timeline is noteworthy. Bloom reported the issue through GitHub’s HackerOne bug bounty on June 6, 2026; GitHub validated the report on June 9. After a final response on July 8, six follow‑up messages—including a mediation request—went unanswered, according to Bloom. The fix was shipped in early October, but the lack of a clear public advisory leaves many package maintainers unaware of the risk.
Bloom also warned that AI‑driven coding assistants amplify the impact. Telemetry from dozens of organizations shows that AI agents install roughly 70 npm packages per month on typical endpoints and 350 on developer machines, often without human review. This automation means a malicious package could propagate far more quickly than a manually installed one, expanding the attack surface across both production and development environments.
Why It Matters for Compliance & Audit Readiness
The flaw undermines supply‑chain integrity controls and can invalidate evidence of provenance, challenging continuous monitoring and defensible audit trails for software‑origin verification.
Recommended Actions
- Run
npm trust listfor every package you maintain; verify that each listed repository slug still resolves to a repository you control. - Delete and re‑create any Trusted Publishing binding that points to a renamed, transferred, or deleted repository; remove the binding before deleting a repository.
- Validate provenance attestations of third‑party packages you consume; ensure the attested repository matches the expected owner and immutable ID.
Source: Help Net Security – npm Trusted Publishing flaw exposed 1,500+ npm packages to takeover