GitHub Tightens npm Security After Shai-Hulud Attack

▼ Summary
– Attackers successfully compromised popular npm packages through phishing campaigns and the self-replicating Shai-Hulud worm, which affected over 500 packages and exposed secrets.
– GitHub has stopped the Shai-Hulud attack’s replication but acknowledges the need for future security improvements to prevent similar incidents.
– GitHub will require two-factor authentication (2FA) for local package publishing, migrating users from TOTP to more secure FIDO-based 2FA.
– The platform plans to expand trusted publishing, which uses short-lived identity tokens instead of long-lived API keys, to more CI/CD providers beyond GitHub Actions and GitLab Pipelines.
– Granular access tokens for publishing will have a maximum 7-day lifespan, with legacy tokens being deprecated to push users toward trusted publishing or 2FA-enforced methods.
The security of software supply chains faces relentless pressure from attackers seeking to hijack accounts and distribute malicious code through the npm registry, a critical hub for JavaScript and Node.js developers operated by GitHub. Recent incidents, including a sophisticated phishing campaign and the self-propagating “Shai-Hulud” attack, have compromised hundreds of packages and exposed sensitive secrets, prompting GitHub to implement significant new security measures.
GitHub successfully halted the replication of the Shai-Hulud worm and blocked new uploads containing its malware signatures. However, the scale of the incident revealed the need for more robust, systemic defenses. The company is now moving forward with a multi-pronged strategy to harden the npm ecosystem against future threats.
A cornerstone of this effort involves strengthening authentication for package publishers. GitHub will soon require two-factor authentication (2FA) for all local package publishing, eliminating the current option to bypass it. The platform also plans to deprecate the older time-based one-time password (TOTP) method, migrating users toward more secure FIDO-compliant WebAuthn standards.
Another major initiative is the broader adoption of trusted publishing. This system allows package repositories to authorize specific continuous integration/continuous deployment (CI/CD) workflows to publish code using short-lived OpenID Connect tokens. By replacing long-lived, easily compromised API keys, trusted publishing drastically reduces the risk of credential theft leading to malicious package distribution. While currently supporting GitHub Actions and GitLab Pipelines, GitHub intends to expand the list of eligible CI/CD providers for this feature.
Furthermore, GitHub is imposing strict limitations on access tokens. Granular tokens with publishing permissions will have a maximum lifespan of just seven days, and legacy classic tokens will be phased out entirely. The default setting for publishing access will disallow tokens, pushing maintainers toward the safer alternatives of trusted publishing or 2FA-enforced local workflows.
Recognizing that these changes will impact developer workflows, GitHub has committed to a gradual rollout. Xavier René-Corail, the company’s senior director of security research, emphasized a focus on minimizing disruption while bolstering npm’s overall security. The transition will be supported with clear timelines, comprehensive documentation, migration guides, and dedicated support channels. In the interim, npm maintainers are strongly encouraged to adopt WebAuthn for 2FA, begin using trusted publishing, and enforce 2FA for all package publishing and settings modifications.
(Source: HelpNet Security)