12-04 更新 实时
首页/ 技术栈/ 正文

5,400 个恶意 npm 包揭示 2026 软件供应链风险

技术栈 来源:Databricks Blog 2026-11-24 04:47 3 阅读 机器翻译
5,400 个恶意 npm 包揭示 2026 软件供应链风险

被劫持的真实软件包造成了几乎所有的暴露风险。受损的合法软件包仅占 5,400 个恶意软件包的 7%,却占据了超过 99% 的下载量。

攻击者已经从窃取令牌转向构建流水线。在 npm 撤销长期有效的令牌后,攻击者接管了 CI 环境并通过可信发布渠道发布;该数据集中 85% 的可信发布软件包都是被入侵的。

AI 开发工具是新的目标。恶意 MCP 服务器、篡改 AI 助手配置的软件包以及窃取 AI 服务密钥的窃取程序,正在瞄准两年前尚不存在的攻击面。

本报告是分析供应链威胁态势系列博客的第一篇。在第一部分中,我们分析了 2025 年 12 月至 2026 年 10 月期间发布的约 5,400 个已确认的恶意 npm 软件包,这是 npm 撤销长期有效的认证令牌后的第一年[1]。以下是八项发现。

暴露面集中在受损的合法软件包上。攻击者创建的恶意软件包占该数据集的 89%,但仅占其记录下载量的 0.2%。受损的合法软件包占该数据集的 7%,却占下载量的 99% 以上。

安装脚本管控措施能应对大约一半的已观察到的恶意软件。54% 的软件包声明了生命周期脚本;其余的在导入或调用时执行。该时期最大的攻击活动——针对单一组织、超过一千个软件包——仅有 1% 的软件包声明了生命周期脚本,并在连续多波攻击中交替使用导入时执行和 postinstall 钩子。

账户失陷的方式已从窃取 Token 转向构建流水线被攻陷。2026 年 8 月自我复制蠕虫攻击活动中暴露程度最高的受害者,是通过被攻陷的 CI 环境、借助 OIDC 可信发布重新发布的。在该批通过可信发布发布的软件包中,85% 是被攻陷的合法软件包;攻击者创建的软件包使用可信发布的比例仅为 0.1%。

攻击者的基础设施以合法共享服务为主。38% 的恶意软件包会与合法的第三方服务通信:无服务器托管、聊天平台 webhook、代码托管与粘贴站点、请求捕获端点,以及少数情况下被用作死投解析器的公共区块链 RPC 节点。域名信誉无法将这类流量与正常开发者流量区分开来。

还有一类性质不同的活动专门针对 AI 开发工具链。从智能体宿主中窃取凭证的 MCP 服务器软件包、修改 AI 助手配置与指令文件的软件包,以及专门窃取 AI 服务密钥的凭证窃取程序,共同构成了一类软件包,其主要攻击目标——MCP 宿主与助手配置——在两年前尚不构成攻击面。

以 AI 智能体为卖点的攻击性安全框架正通过 npm 分发。智能体式攻击性安全框架已开始出现在该软件仓库中用于开源分发,将远程访问、云凭证和企业身份工具与针对 AI 系统进行对抗测试的模块打包在一起。公开报道已经观察到威胁行为者利用智能体式工具攻击暴露的密钥。

该注册表被用作与软件供应链无关的载荷的分发渠道。该注册表为攻击者提供了在受信任域名下免费、高可用的托管,其内容由公共 CDN 和镜像重新分发;因此,从未运行包管理器的受害者也可能直接从 npm 基础设施收到载荷。

移除比报告更慢,而攻击者移除自己的软件包比注册表更快。87% 的已确认软件包有公开公告;未归属的软件包在发布后中位 1.7 天收到一份公告。注册表的安全下架随后发生,中位为 7 天,其中 10% 超过 59 天。37% 由攻击者创建的软件包在有任何下架之前就被其发布者自行取消发布,中位为七小时。16% 在本次分析时仍可安装。

数据集包含我们的扫描器检测到的软件包,该扫描器分析 npm 发布事件以发现可疑软件包,并通过仅保留至少有一个独立来源的软件包来过滤结果以提高精确度:公开公告、供应商发布的攻击活动报告、npm 安全下架或分析师审查。时间以 npm 发布日期衡量。记录单位是软件包版本;软件包以其首个恶意版本确定日期。下载计数是扫描时记录的月度快照。注册表活跃状态于 2026 年 11 月 6 日对照公共注册表进行了检查。

图 1:按月份的判定类型(%)

在这一时期内,已确认恶意包的月度计数相差达十五倍。这一波动可归因于少数几次攻击活动:2026 年 8 月,单次依赖混淆活动就占已确认版本的 78%。当每次活动被计为单个行为者时,活动情况是稳定的:每月新增数百个发布者账号,恶意包相对于已发布包总数的比例持平,而峰值可归因于有命名的攻击活动。

图 2:按首次发布月份统计的已核实恶意 npm 包

经过这一归一化处理后,可以观察到三项变化:

合法包被入侵的情况是偶发性的。大多数月份的活动都可忽略不计。同一种蠕虫家族在 2026 年 5 月、6 月和 8 月出现了三波活动;5 月和 8 月的两波各入侵了一百多个包,6 月的一波在一天之内重新发布了某厂商的全部 scope。

图 3:合法包被入侵情况,按月份统计的投毒版本

依赖混淆的侦察活动是持续性的,每个月都存在,且水平一致。

混淆行为有所增加。其包触发混淆规则的行为者占比在 2026 年 5 月至 8 月间增长了一倍以上。

针对 AI 开发者凭据的攻击全年都维持在包的 1%–4%;绝对数量随总量上升。npm 身份验证 Token 的窃取在 2026 年 3 月达到峰值,占包的 22%,并从 5 月起降至 5% 以下。传统的长期有效 Token 已于 2025 年 12 月 9 日被吊销;这一时期被针对的 Token 很可能是细粒度访问 Token 和 CI 密钥。

图4:各月针对各类凭证的已验证软件包占比

图5:针对云与 AI 开发的攻击:软件包 vs 行为主体(占当月百分比)

恶意软件包剖析

图6:2026 年 5 月至 10 月已验证恶意 npm 发布行为画像

发布者账号。99% 的恶意软件包由单维护者账号发布;55% 的账号使用免费邮箱地址。三分之二的账号只发布一个恶意软件包;在发布超过一个恶意软件包的账号中,从首次到末次恶意发布的中位间隔不足一天。DPRK 关联的攻击活动是例外,其运营数百个账号,每个账号发布一到两个软件包,其中 83% 使用免费邮箱地址。其他有命名的攻击活动仅在 15% 的情况下使用免费邮箱地址,这与采购而来的账号池情况相符。

图7:已验证恶意 npm 软件包背后的发布者账号

软件包元数据。88% 的软件包在被恶意发布时创建不足三十天;75% 未声明任何代码仓库;66% 只有一个版本;65% 在 author、description 或 repository 字段中保留了 npm init 模板值。54% 声明了生命周期脚本。17% 带有看似内部使用的名称(core、utils、sdk、config)。域名抢注属于少数手法:13% 嵌入了某个热门软件包的名称,不到 5% 与某个热门软件包名称的编辑距离在两个字符以内。

图8:package.json 文件中的作者与仓库伪造情况(%)

图 9:恶意软件包名称中使用的生态系统关键词

失陷指标。被入侵的合法软件包与攻击者创建的软件包在版本级变更信号上存在差异。78% 的被入侵版本会添加或修改生命周期脚本,而攻击者创建的软件包中这一比例仅为 4%。23% 显示维护者或发布者发生变更。大多数入侵事件通过合法账号发布,且所有者记录保持不变。

图 10:接管形态,被入侵的合法软件包 vs 攻击者发布的软件包

行为。72% 的软件包带有混淆标记,30% 会拉取第二阶段载荷。除 8 月外,凭据和数据窃取在每个月都是主要行为。8 月有相当数量的软件包窃取凭据,但最终目的是在受害者机器上投递 Sliver 命令与控制植入程序,因此其分类被改为木马 / 下载器。

图 11:按行为和月份划分的恶意软件包

原文较长,译文为节选;译文由英文原文机器翻译,术语按行业惯例统一,可在文末展开原文核对。

查看英文原文(What 5,400 Malicious npm Packages Reveal about Software Supply Chain Risk in 2026)

Hijacked real packages cause nearly all the exposure. Compromised legitimate packages are only 7% of the 5,400 malicious packages, but they account for over 99% of downloads.

Attackers have moved from stolen tokens to build pipelines. After npm revoked long-lived tokens, attackers took over CI environments and published through trusted publishing; 85% of trusted-published packages in the set are compromises.

AI development tools are a new target. Malicious MCP servers, packages that tamper with AI assistant configuration, and stealers of AI service keys are going after an attack surface that didn't exist two years ago.

This report is the first of a series of blogs analyzing the supply chain threat landscape. In this first part, we analyzed approximately 5,400 confirmed malicious npm packages published between December 2025 and October 2026, the first year following npm's revocation of long-lived authentication tokens [1]. Eight findings follow.

Exposure is concentrated in compromised legitimate packages. Attacker-created malware packages constitute 89% of the set but 0.2% of its recorded downloads. Compromised legitimate packages constitute 7% of the set and over 99% of downloads.

Install-script controls address roughly half of observed malware. 54% of packages declare a lifecycle script; the remainder execute on import or invocation. The largest campaign of the period, exceeding one thousand packages directed at a single organization, declared a lifecycle script in 1% of packages and alternated between import-time execution and postinstall hooks across successive waves.

Account compromise has shifted from stolen tokens to compromised build pipelines. The highest-exposure victims of the August 2026 self-replicating worm campaign were republished through OIDC trusted publishing from compromised CI environments. Of packages in the set published via trusted publishing, 85% are compromised legitimate packages; attacker-created packages use trusted publishing in 0.1% of cases.

Attacker infrastructure is predominantly legitimate shared services. 38% of malicious packages communicate with a legitimate third-party service: serverless hosting, chat-platform webhooks, code-hosting and paste sites, request-capture endpoints, and in a small number of cases public blockchain RPC nodes used as dead-drop resolvers. Domain reputation does not distinguish this traffic from normal developer traffic.

A distinct class of activity targets AI development tooling. MCP server packages that harvest credentials from the agent host, packages that modify AI assistant configuration and instruction files, and credential stealers specialized in AI service keys together form a population whose principal targets, MCP hosts and assistant configuration, did not exist as an attack surface two years ago.

Offensive-security frameworks marketed as AI agents are distributed through npm. Agentic offensive security frameworks have begun appearing on the registry for open source distribution, bundling remote-access, cloud-credential and enterprise-identity tooling with modules for adversarial testing of AI systems. Public reporting has already observed threat actors making use of agentic tooling against exposed secrets.

The registry is used as a distribution channel for payloads unrelated to the software supply chain. The registry offers attackers free, highly available hosting under a trusted domain, and its content is redistributed by public CDNs and mirrors; victims who never run the package manager can therefore be served a payload directly from npm infrastructure.

Removal is slower than reporting, and attackers remove their own packages faster than the registry does. 87% of confirmed packages have a public advisory; unattributed packages receive one at a median of 1.7 days after publication. The registry's security takedown follows at a median of 7 days, with 10% exceeding 59 days. 37% of attacker-created packages were unpublished by their own publisher, at a median of seven hours, before any takedown. 16% remained installable at the time of this analysis.

The dataset comprises packages detected by our scanner, which analyzes npm publish events for suspicious packages, with results filtered for precision by retaining only packages with at least one independent source: a public advisory, a vendor-published campaign report, an npm security takedown, or analyst review. Time is measured by npm publish date. The unit of record is the package version; a package is dated by its first malicious version. Download counts are monthly snapshots recorded at scan time. Registry active status was checked against the public registry on November 6, 2026.

image3.png

Figure 1: Verdict Type by Month (%)

Monthly counts of confirmed malicious packages vary by a factor of fifteen across the period. The variation is attributable to a small number of campaigns: in August 2026 a single dependency-confusion campaign accounts for 78% of confirmed versions. When each campaign is counted as a single actor, activity is stable: several hundred new publisher accounts per month, a flat rate of malicious packages relative to total packages published, and spikes attributable to named campaigns.

Figure 2: Verified Malicious npm Packages by First-Publish Month

Three changes are observable after this normalization:

Compromise of legitimate packages is episodic. Activity is negligible in most months. Three waves of a single worm family occurred in May, June and August 2026; the May and August waves each compromised more than one hundred packages, and the June wave republished a vendor's entire scope in one day.

Figure 3: Legitimate-Package Compromise, Poisoned Versions by Month

Dependency-confusion reconnaissance is continuous, present in every month at a consistent level.

Obfuscation increased. The share of actors whose packages trigger an obfuscation rule more than doubled between May and August 2026.

Targeting of AI-developer credentials remained at 1-4% of packages throughout the year; absolute counts rose with volume. Theft of npm authentication tokens peaked at 22% of packages in March 2026 and fell below 5% from May. Classic long-lived tokens had been revoked on December 9, 2025; the tokens targeted in this period were plausibly granular access tokens and CI secrets.

Figure 4: Share of Verified Packages Targeting Each Credential Class, by Month

Figure 5: Cloud and AI-Dev Targeting: Packages vs. Actors (% of month)

Anatomy of a malicious package

Figure 6: Profiles of Verified Malicious npm Publishing, May–October 2026

Publisher account. 99% of malicious packages are published by single-maintainer accounts; 55% of accounts use a free-mail address. Two thirds of accounts publish exactly one malicious package; among accounts publishing more than one, the median interval from first to last malicious publish is under one day. DPRK-nexus campaigns are the exception, operating several hundred accounts at one to two packages each, 83% on free-mail addresses. Other named campaigns use free-mail addresses in 15% of cases, consistent with procured account pools.

Figure 7: Publisher accounts behind Verified Malicious npm Packages

Package metadata. 88% of packages are under thirty days old at the malicious publish; 75% declare no repository; 66% have a single version; 65% retain npm init template values in the author, description or repository fields. 54% declare a lifecycle script. 17% carry an internal-looking name (core, utils, sdk, config). Typosquatting is a minority tactic: 13% embed a popular package name and under 5% are within two character edits of one.

Figure 8: Author and Repository Spoofing in package.json file (%)

Figure 9: Ecosystem Keywords Used in Malicious Package Names

Compromise indicators. Compromised legitimate packages differ from attacker-created packages on the version-level change signals. 78% of compromised versions add or modify a lifecycle script, compared with 4% of attacker-created packages. 23% show a change of maintainer or publisher. The majority of compromises are published through the legitimate account and leave ownership records unchanged.

Figure 10: Takeover Shape, Compromised Legitimate Packages vs Attacker-Published

Behavior. 72% of packages have an obfuscation marker, and 30% retrieve a second stage. Credential and data theft is the predominant behavior in every month, except August. A significant number of packages in August stole credentials but ultimately aimed to deliver on the victim machine a Sliver command-and-control implant, changing its classification to Trojan / Downloader.

Figure 11: Malware Packages by Behavior and Month

Of credential stealers, 45% target a single credential class and 36% target three or more. Single-class stealers are distributed evenly across cloud credentials, SSH keys, AI-developer credentials, npm tokens and .env files. In multi-class stealers, cloud credentials, SSH keys and .env files co-occur; wallet and browser-data theft occur separately. AI-developer credentials are the most specialized target: 80% of packages that target them target no other class.

Figure 12: Co-occurrence of credential classes

Platform. 55% of packages contain no operating-system-specific code. Among the remainder, droppers target Windows (PowerShell, scheduled tasks, executables) and credential stealers and backdoors target Linux (systemd, cron, shell configuration files). macOS-specific code appears in approximately one in eight stealers.

Lures. 24% of packages are scoped, across more than three hundred distinct scopes, most of which contain a single malicious package: an organization's internal namespace registered once. 36% declare an author and 24% a repository; where present, approximately 80% of each refer to an identity other than the publishing account. 62% include a README; of these, 16% contain an installation command for a different package, in half of those cases a popular one. The majority of attacker-created packages employ no lure, consistent with the exposure finding: these packages are retrieved by misconfigured builds rather than selected by users.

Figure 14: Package-name lures (%)

Compromised legitimate packages

Compromised legitimate packages are 7% of the set and over 99% of its download exposure.

Figure 15: Downloads per Month at Scan Time

All compromise waves in the period belong to one family, first the toolkit of a single threat actor and later open-sourced for free use in May. The May and August worms each compromised more than one hundred packages. In June 2026 the same open-source kit republished a single vendor's entire scope in one day through trusted publishing, followed within days by a small number of unrelated packages. Outside these waves, compromise occurs at a rate of a few packages per month.

Worm-compromised versions are distinguishable from attacker-created packages: all execute through a lifecycle script, one third read cloud credentials or the Kubernetes service-account token, and 44% trigger obfuscation rules. They receive public advisories within hours of publication.

The August wave's highest-exposure victims were republished through OIDC trusted publishing from compromised CI environments rather than through stolen tokens. Across the period, 85% of packages in the malicious set published via trusted publishing are compromises. The December 2025 token revocation directed maintainers toward trusted publishing; subsequent compromise activity targeted the publishing pipeline directly.

Infrastructure, exposure and public reporting

Shared legitimate services. 38% of packages, and 42% of those with a network indicator, communicate with a legitimate third-party service. Serverless hosting is most common; Cloudflare Workers alone serves several hundred packages from a comparable number of accounts. Code-hosting and paste sites follow, then Telegram, Discord and Slack webhooks. A small population retrieves its payload address from a smart contract via a public blockchain RPC endpoint; two thirds of these packages are heavily obfuscated and 42% ship a compiled binary. 8% of droppers carry no resolvable host, with the second-stage URL constructed at runtime.

Figure 16: Share of Packages Routing Through a Legitimate Service, by Month

Exposure. 81% of attacker-created packages had no downloads at the time of scanning. The ten most-downloaded packages in the set account for over 99% of recorded downloads; all are compromised legitimate packages.

Time to public advisory. 87% of the set has an OSV advisory. Named worm and dependency-confusion campaigns receive advisories on the day of publication. Unattributed packages receive advisories after a median of 1.7 days, with 10% exceeding one month. DPRK-nexus packages receive advisories after a median of 4.5 days, with 10% exceeding two months, the slowest of any developer-facing population.

Figure 17: Exposure Before Public Reporting

Registry outcome. Each attacker-created package was checked against the registry at the time of analysis. 40% had been replaced by npm's security placeholder, at a median of 7.1 days after publication and 10% after more than 59 days. 37% had been unpublished by their own publisher, at a median of 0.3 days; attackers withdraw packages faster than the registry removes them, and the share of self-removal rose through the year. 7% had been deleted without a recoverable timestamp. 16% remained installable. Removal rates vary by actor: 64% of DPRK-nexus packages were removed by npm, at a median lag of 19.5 days, and 5% remain installable; individual DPRK-nexus campaigns range from 16.4 to 65.9 days. Of unattributed packages, 21% remain installable. The registry takedown is a slower control than public reporting: from March 2026 onward the median advisory preceded the median takedown in every month.

Figure 18: Where Malicious Packages Ended Up

Figure 20: Days from Publish to Removal or Advisory, by Publish Month

Outcomes differ sharply by campaign. Campaigns that received same-day advisories had median takedown lags of a few days or less. DPRK-nexus campaigns received advisories within days but remained installable for weeks to months; every DPRK-nexus tag in the dataset has a median takedown lag above two weeks. A further group of campaigns, including five crypto-wallet stealer families, was never removed by the registry: the publishers withdrew every package themselves, typically within a day, and the registry recorded no security action.

Install-script blocking is a partial control. It addresses the half of attacker-created packages that execute through a lifecycle script and all worm-compromised versions, and none of the packages that execute on import. Combine it with lockfile integrity enforcement and a registry proxy applying an allowlist or minimum-age policy.

Monitor lifecycle-script changes between versions of existing dependencies. 78% of compromised versions add or modify a lifecycle script; 23% change maintainer or publisher.

Restrict credentials available to build environments. One third of worm victims and half of MCP-abuse packages read cloud credentials. Short-lived, job-scoped credentials limit the impact.

Treat trusted publishing as provenance, not assurance. It attests that a package originated from a pipeline, not that the pipeline was uncompromised. Pin CI actions, exclude secrets from pull-request builds, and review provenance attestations at publish time.

Do not rely on domain reputation for build-time egress control. 38% of malicious packages communicate with Cloudflare, Vercel, GitHub, Telegram or public blockchain nodes. Egress policy must be allowlist-based.

Register organizational scopes on the public registry. More than three hundred scopes were registered by attackers in the period, most once. Configure package managers to resolve internal scopes exclusively from internal registries.

Protect AI assistant configuration as a credential store. Assistant configuration directories, MCP host configuration and instruction files are read and written by malicious packages. Apply file-integrity monitoring equivalent to that for SSH keys.

Prepare for agent-operated intrusions. Autonomous offensive frameworks are now one npm install command away from a motivated actor. Plant content that trips an attacking agent's guardrails or diverts its plan, deploy canary credentials where an agent will enumerate them, and add agent-driven patterns to SOC detection: bursts of API calls with changing parameters, enumeration from one principal across many services, and credential use seconds after discovery.

This is the first in a series of posts on supply chain threats. In our next report, we will discuss emerging threats identified in the dataset that we believe are expanding the role of the npm registry beyond traditional malware distribution.

[1] GitHub (2025). “npm classic tokens revoked, session-based auth and CLI token management now available”.

Get the latest posts in your inbox

原文为英文,正文由自动抓取并保留原文。

本文由采集器自动同步

原文发布于 Databricks Blog(What 5,400 Malicious npm Packages Reveal about Software Supply Chain Risk in 2026),标题、摘要与正文由机器翻译,术语按行业惯例统一,未经人工逐句校订。

阅读原文 ↗