Skip to the content
AI and Cybersecurity Learning and Practice Center Test automation Open the Learning Center

IncidentSupply chain

ChainDrop: an npm worm hides its hooks in Claude Code and VS Code config files

CriticalnpmElastic Security LabsStepSecurity

A new Shai-Hulud style campaign compromised the maintainer of keyv and used stolen npm credentials to backdoor every package that account could publish: more than 400 packages with over a billion monthly downloads between them, in under four hours. Beyond the usual preinstall hook, the worm planted a Claude Code SessionStart hook in .claude/settings.json and a VS Code folderOpen task, so opening a project ran the payload with no install at all. It harvested npm, GitHub, cloud, Kubernetes and AI tool credentials, encrypted them and exfiltrated through command-and-control endpoints resolved from an Ethereum smart contract.

Replay the attack step by step in the Learning Center

How it happened

  1. Stolen maintainer credentials published trojanized versions of keyv, flat-cache and the cacheable family.
  2. A preinstall hook ran the worm, which used any npm token it found to republish more packages.
  3. Repository configuration files for Claude Code and VS Code gained hooks that run code when a developer opens the project, and stolen GitHub tokens committed those hooks to up to 50 branches per repository.
  4. A credential harvester matched over 300 patterns, including Anthropic, OpenAI and Gemini keys, and a watcher re-ran attacker code when developers tried to rotate tokens.

Impact

Developer and CI credentials across thousands of projects, with persistence that survives reinstalling packages.

The fix

Treat affected machines as compromised: remove the hooks from .claude and .vscode, check repositories for commits titled "chore: update config", pin to clean versions with install scripts disabled, and rotate npm, GitHub, cloud and AI credentials from a clean device. npm 12 and later block preinstall hooks by default.

Lessons

  • Agent and editor configuration files are code execution; review them like CI configuration and scan them in CI.
  • Install scripts off, soak periods on, and tokens that cannot publish from a laptop.

Sources