AI觉醒星球
Awakening is here
Knowledge File / 全球热点解读
2026-07-29 8 浏览 公开

npm 发布时恶意软件扫描与双重用途元数据

npm 将自动扫描新发布的包,并引入双重用途元数据声明,要求发布者使用双因素认证,可能影响发布流程。

SOURCE / 全球热点解读 MIN / 4 ACCESS / 公开 POST / 2026-07-29 06:50:05

原贴

查看原文
作者:Allison 来源站点:github.blog 原贴时间:

原文

As part of our ongoing supply-chain security work, npm is introducing automatic scanning of packages at publish time . This changelog covers what publishers can expect and a new metadata requirement for dual-use content. Newly published packages will be automatically scanned before they become available for install. Depending on the results, a package may be published as normal, held for manual review, or blocked. This introduces a short delay between publishing and availability, typically around five minutes. It may take longer, up to 15 minutes or more, at peak times or depending on a package’s content and size. These times reflect current typical behavior and may change as scanning evolves; they aren’t a service guarantee. For most publishes, no action is required beyond allowing for this brief delay. If you have automation that assumes a package is installable immediately after publishing, update it to tolerate a short availability delay. While scanning is pending, the npm dist-tag command continues to work. Other operations that depend on the published version, such as npm deprecate and npm unpublish , will not work until the package becomes available. If a package is blocked, the publisher may receive a notification with the option to appeal. Depending on the severity and confidence of a finding, further action may be taken on the associated maintainer account(s), consistent with our existing policies. npm blocks the malware we can detect and we are continuously working to improve detection coverage and reduce scan time. For what is and isn’t permitted on the registry, see the npm Acceptable Use Policies . Some legitimate packages have security-relevant capabilities that can resemble malware to automated scanning (dual-use content). We are introducing a contentPolicy field in package.json for maintainers to declare this content. Maintainers declaring dual-use content must also include a DISCLOSURE file in the package’s root directory, containing only text content. This file is free-form and should describe both the dual-use functionality and its intended legitimate use. Our Trust & Safety team uses it when reviewing dual-use packages. Declaring this metadata may trigger additional automated scanning suited to dual-use content when needed. It does not automatically grant publication, and our Trust & Safety team may review dual-use packages on a case-by-case basis. 2FA-enforced publishing: Packages declaring dual-use content must be published through a method that enforces two-factor authentication (e.g., trusted publishing (OIDC), an interactive session with two-factor authentication, or staged publishing). Staged publishing is 2FA-enforced through its staging and promotion step, so granular access tokens with bypass-2FA may still be used to publish to staging . Publishing a dual-use package directly (unstaged) with a token that bypasses two-factor authentication is not permitted. Persistent declaration: Once a package is published with dual-use metadata, the declaration must persist. New versions cannot remove the contentPolicy field or the DISCLOSURE file; publishes that drop them will be rejected.

中文翻译

作为我们持续进行的供应链安全工作的一部分,npm 正在引入在发布时自动扫描包的功能。本变更日志介绍了发布者可以期待的内容,以及针对双重用途内容的新元数据要求。新发布的包在可供安装之前将自动进行扫描。根据结果,包可能正常发布、保留供人工审查或被阻止。这在发布和可用性之间引入了短暂延迟,通常约五分钟。在高峰时段或根据包的内容和大小,可能需要更长时间,最多 15 分钟或更久。这些时间反映了当前典型行为,并可能随着扫描的演变而变化;它们不是服务保证。对于大多数发布,除了允许这一短暂延迟外,无需采取任何操作。如果您有自动化流程假设包在发布后立即可安装,请更新它以容忍短暂的可用性延迟。在扫描进行期间,npm dist-tag 命令继续工作。其他依赖已发布版本的操作,例如 npm deprecate 和 npm unpublish,在包可用之前将无法工作。如果包被阻止,发布者可能会收到通知,并可以选择上诉。根据发现的严重性和置信度,可能会对相关的维护者账户采取进一步行动,这与我们现有的政策一致。npm 会阻止我们能检测到的恶意软件,并且我们正在不断努力提高检测覆盖率并减少扫描时间。关于注册表中允许和不允许的内容,请参阅 npm 可接受使用政策。一些合法的包具有安全相关能力,这些能力可能被自动扫描视为类似恶意软件(双重用途内容)。我们正在 package.json 中引入 contentPolicy 字段,供维护者声明此类内容。声明双重用途内容的维护者还必须在包的根目录中包含一个 DISCLOSURE 文件,该文件仅包含文本内容。此文件是自由形式的,应描述双重用途功能及其预期的合法用途。我们的信任与安全团队在审查双重用途包时会使用它。声明此元数据可能会在需要时触发适合双重用途内容的额外自动扫描。它不会自动授予发布权限,我们的信任与安全团队可能会逐案审查双重用途包。强制双因素认证发布:声明双重用途内容的包必须通过强制双因素认证的方法发布(例如,可信发布(OIDC)、具有双因素认证的交互式会话或分阶段发布)。分阶段发布通过其分阶段和提升步骤强制双因素认证,因此具有绕过双因素认证的细粒度访问令牌仍可用于发布到分阶段环境。使用绕过双因素认证的令牌直接(未分阶段)发布双重用途包是不允许的。持久声明:一旦使用双重用途元数据发布包,声明必须持续存在。新版本不能移除 contentPolicy 字段或 DISCLOSURE 文件;删除它们的发布将被拒绝。

核心信息

npm 将自动扫描新发布的包,并引入双重用途元数据声明,要求发布者使用双因素认证,可能影响发布流程。

  • npm 将自动扫描新发布的包,并引入双重用途元数据声明,要求发布者使用双因素认证,可能影响发布流程。
  • 原贴提到:As part of our ongoing supply-chain security work, npm is introducing au
  • 来源:github.blog

详细解读

这是一个重要的供应链安全信号。npm 作为 JavaScript 生态的核心,开始强制在发布时进行自动恶意软件扫描,并引入双重用途元数据声明,表明平台正在从被动应对转向主动防御。

为什么重要:恶意 npm 包曾多次导致大规模供应链攻击,如 ua-parser-js 事件。自动扫描能在包流入安装环节前拦截风险,将显著提高生态安全基线。同时,双重用途元数据要求为合法安全工具提供了解释渠道,减少误杀。

对谁有价值:对于包发布者,必须适应新的发布延迟和认证要求;对于企业用户,扫描和声明机制增强了依赖的可信度;对于安全团队,这提供了新的数据源和合规依据。

行动建议:发布者应更新发布脚本,容忍 5-15 分钟延迟;如维护安全相关包,主动添加 contentPolicy 和 DISCLOSURE 文件;开发者应检查依赖更新,并关注包的安全公告。

风险与限制:扫描可能误伤合法包,导致延迟或下线;双重用途声明可能被恶意者滥用,需人工审查兜底;扫描本身仍无法覆盖所有未知恶意模式,且需要权衡扫描耗时与可用性。

信息差价值

这条内容的真正价值,不只是“有人发布了一个新功能”,而是它揭示了 github.blog 背后的产品方向、工作流变化或竞争信号。对 OPC 来说,这种信息可以转化成持续追踪的栏目选题。

如果把《npm 发布时恶意软件扫描与双重用途元数据》放到你的内容系统里,它最大的价值在于帮助读者更快看懂“为什么值得关注”,而不是只看到一条碎片化动态。

参考来源

上一篇 AIHOT 日报参考 2026-07-29 下一篇 Anthropic 支持 AI 发展节奏请愿