npm Implements New Security Measures to Secure Node.js Supply Chain After Sha1-Hulud Attack

npm’s Enhanced Security Measures: Strengthening the Node.js Supply Chain

In December 2025, npm, the widely-used package manager for JavaScript, implemented significant authentication changes to bolster the security of its supply chain. This initiative was a direct response to the Sha1-Hulud incident, a sophisticated supply chain attack that compromised numerous npm packages, leading to widespread concern within the developer community.

Understanding the Initial Vulnerability

Historically, npm’s authentication system relied on classic tokens—long-lived credentials with broad access scopes that could persist indefinitely. If these tokens were stolen, malicious actors could publish compromised versions of packages without the need for publicly verifiable source code. This vulnerability made npm an attractive target for supply chain attacks. Notable incidents, such as the Shai-Hulud and Sha1-Hulud campaigns, as well as the compromise of popular packages like chalk and debug, underscored the pressing need for enhanced security measures.

npm’s Proactive Security Enhancements

To address these vulnerabilities, npm introduced several key changes:

1. Revocation of Classic Tokens: All existing classic tokens were revoked. In their place, npm introduced session-based tokens, which are short-lived and obtained through the `npm login` process. These tokens typically expire after two hours and default to requiring multi-factor authentication (MFA) for publishing operations.

2. Promotion of OIDC Trusted Publishing: npm now encourages the use of OpenID Connect (OIDC) Trusted Publishing. This approach allows Continuous Integration (CI) systems to obtain short-lived, per-run credentials, eliminating the need to store long-term secrets. By leveraging OIDC, developers can ensure that their CI/CD pipelines are more secure and less susceptible to credential theft.

Collectively, these measures aim to enhance security by ensuring that credentials expire quickly and that sensitive operations require a second authentication factor.

Persistent Challenges in npm’s Security Landscape

Despite these advancements, certain challenges remain:

1. MFA Phishing Vulnerabilities: The initial attack on tools like ChalkJS was executed through a successful MFA phishing attempt targeting npm’s console. The attackers tricked the maintainer into sharing both their login credentials and one-time password. This indicates that similar phishing campaigns could still succeed in obtaining short-lived tokens, providing attackers with sufficient time to upload malicious packages.

2. Optional MFA for Publishing: While npm encourages the use of MFA, it remains optional for publishing operations. Developers can still create 90-day tokens with MFA bypass enabled via the console. These tokens grant read and write access to the maintainer’s packages. If an attacker gains access to a maintainer’s console with these token settings, they can publish malicious packages on behalf of the author, effectively replicating the original vulnerability that npm sought to mitigate.

While the increased adoption of MFA for publishing is a positive development, the optional nature of these security measures means that the core issue of supply chain vulnerabilities persists.

Recommendations for Further Strengthening npm’s Security

To further enhance the security of the npm ecosystem, the following recommendations are proposed:

1. Mandate OIDC Adoption: Encouraging the widespread adoption of OIDC for publishing operations would significantly reduce the risk of supply chain attacks. OIDC’s robust security features make it challenging for attackers to compromise, thereby enhancing the overall security of the npm ecosystem.

2. Enforce MFA for Local Package Uploads: Implementing mandatory MFA for local package uploads, either through an email code or a one-time password, would further mitigate the risk of attacks like Shai-Hulud. This measure would prevent the creation of custom tokens that bypass MFA, thereby reducing the potential for unauthorized package publications.

3. Eliminate MFA Bypass Tokens: At a minimum, npm should consider disallowing the creation of tokens that bypass MFA. By ensuring that all tokens require MFA, the risk of unauthorized access and subsequent malicious package publications would be significantly reduced.

Conclusion

npm’s recent security enhancements represent a significant step forward in protecting the Node.js supply chain. However, the persistence of certain vulnerabilities underscores the need for continuous vigilance and the implementation of more stringent security measures. By mandating OIDC adoption, enforcing MFA for all publishing operations, and eliminating MFA bypass tokens, npm can further fortify its ecosystem against supply chain attacks, ensuring a safer environment for developers and users alike.