The GitHub Blog 09月23日
npm 加强安全措施,应对开源软件供应链威胁
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

近期npm注册表面临一系列严峻的安全挑战,包括Shai-Hulud蠕虫攻击等,这些攻击旨在通过劫持维护者账户传播恶意软件,威胁到整个开源软件供应链的完整性和安全性。为应对这些威胁,npm正计划实施一系列安全加固措施,包括本地发布强制双因素认证(2FA)、引入有效期为七天的粒度化令牌,以及推广“可信发布”模式。此外,npm还将逐步淘汰旧版令牌和基于时间的一次性密码(TOTP)2FA,迁移至更安全的FIDO标准。这些举措旨在提高身份验证和安全发布实践的门槛,从而巩固npm生态系统的安全性,确保开源软件的可靠性。

🛡️ **npm生态系统面临严峻安全挑战**:近期,npm注册表遭遇了包括Shai-Hulud蠕虫在内的一系列账户劫持和恶意软件传播攻击。这些攻击通过控制维护者账户,将恶意代码注入流行的JavaScript包,对开源软件供应链构成了严重威胁,暴露了当前安全措施的不足。

🚀 **npm推出多项安全加固计划**:为应对不断升级的威胁,npm正积极规划并逐步实施一系列安全改进措施。核心举措包括:要求本地发布强制启用双因素认证(2FA),引入具有七天有效期的粒度化令牌,并大力推广“可信发布”模式,以减少对API令牌的依赖。

🔑 **弃用旧安全机制,拥抱新标准**:为了进一步提升安全性,npm计划淘汰不再安全的遗留经典令牌,并将逐步弃用基于时间的一次性密码(TOTP)2FA。取而代之的是,将鼓励用户迁移至更强大的FIDO标准认证,并限制粒度化令牌的发布权限和有效期,以降低令牌被滥用的风险。

🤝 **“可信发布”模式的重要性**:文章强调了“可信发布”模式作为一种推荐的安全实践,它能够有效避免在构建系统中管理API令牌的风险。该模式已在多个包管理器中推广,npm也将其视为加强生态系统安全的关键手段,鼓励项目尽快采用。

Open source software is the bedrock of the modern software industry. Its collaborative nature and vast ecosystem empower developers worldwide, driving efficiency and progress at an unprecedented scale. This scale also presents unique vulnerabilities that are continually tested and under attack by malicious actors, making the security of open source a critical concern for all. 

Transparency is central to maintaining community trust. Today, we’re sharing details of recent npm registry incidents, the actions we took towards remediation, and how we’re continuing to invest in npm security.

Recent attacks on the open source ecosystem

The software industry has faced a recent surge in damaging account takeovers on package registries, including npm. These ongoing attacks have allowed malicious actors to gain unauthorized access to maintainer accounts and subsequently distribute malicious software through well-known, trusted packages. 

On September 14, 2025, we were notified of the Shai-Hulud attack, a self-replicating worm that infiltrated the npm ecosystem via compromised maintainer accounts by injecting malicious post-install scripts into popular JavaScript packages. By combining self-replication with the capability to steal multiple types of secrets (and not just npm tokens), this worm could have enabled an endless stream of attacks had it not been for timely action from GitHub and open source maintainers. 

In direct response to this incident, GitHub has taken swift and decisive action including: 

Such breaches erode trust in the open source ecosystem and pose a direct threat to the integrity and security of the entire software supply chain. They also highlight why raising the bar on authentication and secure publishing practices is essential to strengthening the npm ecosystem against future attacks.

npm’s roadmap for hardening package publication

GitHub is committed to investigating these threats and mitigating the risks that they pose to the open source community. To address token abuse and self-replicating malware, we will be changing authentication and publishing options in the near future to only include:

    Local publishing with required two-factor authentication (2FA).Granular tokens which will have a limited lifetime of seven days.Trusted publishing.

To support these changes and further improve the security of the npm ecosystem, we will:

We recognize that some of the security changes we are making may require updates to your workflows. We are going to roll these changes out gradually to ensure we minimize disruption while strengthening the security posture of npm. We’re committed to supporting you through this transition and will provide future updates with clear timelines, documentation, migration guides, and support channels.

Strengthening the ecosystem with trusted publishing

Trusted publishing is a recommended security capability by the OpenSSF Securing Software Repositories Working Group as it removes the need to securely manage an API token in the build system. It was pioneered by PyPI in April 2023 as a way to get API tokens out of build pipelines. Since then, trusted publishing has been added to RubyGems (December 2023), crates.io (July 2025), npm (also July 2025), and most recently NuGet (September 2025), as well as other package repositories. 

When npm released support for trusted publishing, it was our intention to let adoption of this new feature grow organically. However, attackers have shown us that they are not waiting. We strongly encourage projects to adopt trusted publishing as soon as possible, for all supported package managers.

Actions that npm maintainers can take today

These efforts, from GitHub and the broader software community, underscore our global commitment to fortifying the security of the software supply chain. The security of the ecosystem is a shared responsibility, and we’re grateful for the vigilance and collaboration of the open source community. 

Here are the actions npm maintainers can take now:

True resilience requires the active participation and vigilance of everyone in the software industry. By adopting robust security practices, leveraging available tools, and contributing to these collective efforts, we can collectively build a more secure and trustworthy open source ecosystem for all.

The post Our plan for a more secure npm supply chain appeared first on The GitHub Blog.

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

npm 开源软件 软件供应链安全 安全加固 双因素认证 可信发布 GitHub Open Source Software Software Supply Chain Security Security Hardening Two-Factor Authentication Trusted Publishing
相关文章