AI Security AI安全 6h ago Updated 1h ago 更新于 1小时前 50

Keyv-Linked npm Worm Poisons Hundreds of Packages, Plants Claude Code and VS Code Hooks Keyv-Linked npm 蠕虫污染数百个软件包,植入 Claude Code 和 VS Code 钩子

A credential-stealing npm worm originated in keyv@6.0.0 on August 4, 2026, spreading across hundreds of packages in the Keyv and Cacheable namespaces and beyond The attack used a preinstall script to execute a 727KB compiled payload that harvested credentials from GitHub, npm, cloud providers, Vault, Kubernetes, databases, and private keys, then propagated by poisoning additional packages The repository also planted Claude Code and VS Code hooks via .claude/settings.json and .vscode/tasks.json, npm恶意蠕虫通过keyv@6.0.0首发,已污染353个版本、79个包名,波及数百个包和多个组织 攻击利用preinstall脚本在开发者和CI环境中执行凭证窃取bundle,可窃取GitHub、npm、云、Vault、Kubernetes及私钥等敏感材料 恶意仓库同时植入Claude Code和VS Code hooks,在用户信任工作区时触发payload执行 攻击者利用合法GitHub Actions发布流程获得有效的OIDC和SLSA溯源证明,绕过供应链安全验证 npm 12默认阻止未批准的生命周期脚本,但早期npm客户端和允许生命周期脚本的安装路径仍暴露于风险中

72
Hot 热度
68
Quality 质量
75
Impact 影响力

Analysis 深度分析

TL;DR

  • A credential-stealing npm worm originated in keyv@6.0.0 on August 4, 2026, spreading across hundreds of packages in the Keyv and Cacheable namespaces and beyond
  • The attack used a preinstall script to execute a 727KB compiled payload that harvested credentials from GitHub, npm, cloud providers, Vault, Kubernetes, databases, and private keys, then propagated by poisoning additional packages
  • The repository also planted Claude Code and VS Code hooks via .claude/settings.json and .vscode/tasks.json, creating secondary execution paths when users open the workspace
  • The worm exploited legitimate CI/CD workflows to obtain valid OIDC and SLSA provenance attestations, making malicious releases appear trustworthy
  • npm 12 blocks unapproved lifecycle scripts by default, but earlier versions and alternative install paths remain vulnerable; SafeDep verified 353 poisoned versions across 79 package names with broader estimates reaching 868 packages

Why It Matters

This incident demonstrates a sophisticated supply-chain attack that combines automated package poisoning with IDE-level persistence, showing how attackers can leverage legitimate build provenance to bypass trust mechanisms. For AI practitioners and security teams, it underscores the critical importance of verifying exact resolved dependency versions rather than relying on namespace-level blocklists, and highlights the growing risk of AI coding tools (Claude Code, VS Code) becoming additional attack vectors when workspace trust is misconfigured.

Technical Details

  • Initial vector: keyv@6.0.0 added a preinstall script (node setup.mjs) that checked for Bun runtime, downloaded Bun 1.3.13 from official GitHub releases if absent, then executed a 727,680-byte compiled malicious bundle while leaving the legitimate library code unchanged
  • Payload capabilities: The bundle harvested GitHub tokens, npm credentials, cloud provider keys, HashiCorp Vault secrets, Kubernetes configs, database credentials, and private keys; it also read GitHub Actions runner memory, installed a token-revocation watcher (triggered on credential rotation to execute attacker handlers), and carried npm publishing machinery for autonomous propagation
  • Secondary execution paths: .claude/settings.json contained a SessionStart hook calling .vscode/setup.mjs, and .vscode/tasks.json had an Environment Setup task with runOn: folderOpen calling .claude/setup.mjs — both requiring workspace trust but executable in default configurations
  • Provenance exploitation: The malicious release passed through the project's legitimate GitHub Actions release workflow, obtaining valid OIDC and SLSA attestations that verified the build process but could not confirm source code integrity
  • Scale and detection challenges: SafeDep verified 353 poisoned versions across 79 package names (442 versions/353 names wider); Aikido reported 868 packages/1,381 versions. The registry changed rapidly with earlier clean versions retagged as latest, making static blocklists ineffective — exposure checks require exact package names, resolved versions, and lockfile analysis

Industry Insight

  • Organizations should implement lockfile-pin verification and exact-version resolution checks in CI/CD pipelines rather than relying on namespace-level warnings; the rapid tag-churning in this campaign proves that cached or broad blocklists are insufficient against dynamic supply-chain attacks
  • Security teams must audit Claude Code and VS Code workspace trust configurations immediately — the planted hooks demonstrate how AI-assisted development tools can become persistent execution channels even after the initial compromised dependency is removed; treat any workstation that ran an affected version as credential-exposed and remove the revocation watcher before rotating tokens
  • The attack's use of legitimate SLSA/OIDC provenance to authenticate malicious releases signals a shift toward "trust-through-process" exploitation; software supply-chain security programs must evolve to verify source integrity at the commit level, not just attest to build reproducibility, and consider restricting lifecycle script execution by default even on npm < 12 environments

TL;DR

  • npm恶意蠕虫通过keyv@6.0.0首发,已污染353个版本、79个包名,波及数百个包和多个组织
  • 攻击利用preinstall脚本在开发者和CI环境中执行凭证窃取bundle,可窃取GitHub、npm、云、Vault、Kubernetes及私钥等敏感材料
  • 恶意仓库同时植入Claude Code和VS Code hooks,在用户信任工作区时触发payload执行
  • 攻击者利用合法GitHub Actions发布流程获得有效的OIDC和SLSA溯源证明,绕过供应链安全验证
  • npm 12默认阻止未批准的生命周期脚本,但早期npm客户端和允许生命周期脚本的安装路径仍暴露于风险中

为什么值得看

此次攻击展示了npm供应链攻击的新高度:攻击者不仅污染发布包,还通过IDE hooks建立持久化执行路径,并利用合法CI流程获取可信溯源证明。对AI从业者而言,这警示了依赖管理、CI/CD安全和开发环境信任机制的脆弱性,需要重新评估包管理策略和开发工作区安全配置。

技术解析

  • 攻击载体与传播机制:恶意代码通过preinstall脚本执行,首阶段检测Bun运行时并下载v1.3.13,随后执行727KB编译后的恶意bundle。攻击者利用npm发布权限进行自动化传播,形成蠕虫式扩散。
  • 凭证窃取能力:payload可收集GitHub token、npm发布凭证、云服务商密钥、HashiCorp Vault、Kubernetes配置、数据库凭据及私钥材料,还能读取GitHub Actions runner内存,并安装令牌吊销监控器。
  • IDE Hooks持久化:仓库.claude/settings.json配置SessionStart钩子调用.vscode/setup.mjs,.vscode/tasks.json配置Environment Setup任务在文件夹打开时执行.claude/setup.mjs,形成双重触发路径。
  • 供应链信任绕过:恶意发布通过项目合法GitHub Actions工作流,获得有效的OIDC和SLSA溯源证明,证明构建流程可信但无法验证输入源码安全性。
  • 防御机制与局限:npm 12默认阻止未批准的生命周期脚本,但攻击者利用吊销监控器机制,若先旋转凭证会触发攻击者本地处理器。namespace级黑名单因标签频繁变更存在漏报和误报风险。

行业启示

  • 供应链安全需纵深防御:单一信任链(如SLSA证明)无法保证源码安全,需结合依赖锁定文件验证、SBOM分析和运行时行为监控建立多层防护。
  • 开发环境信任模型需重构:IDE和AI编程助手(如Claude Code)的工作区信任机制可能被恶意仓库利用,建议默认拒绝未验证项目的自动任务执行,并加强用户安全提示。
  • 应急响应策略调整:面对快速变化的恶意包标签,依赖精确版本和lockfile检查而非包名黑名单;凭证旋转前必须先清除恶意监控器,避免触发攻击者预设的本地处理逻辑。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Security 安全 Open Source 开源 Claude Claude Programming 编程 Agent Agent