ChainDrop: Inside a Self-Propagating npm Worm
A self-propagating npm worm called ChainDrop infected over 400 packages by adding a preinstall hook that runs a dropper, stealing cloud credentials, npm and GitHub tokens, SSH keys and other developer secrets. It used stolen npm tokens to republish infected packages and could execute attacker-supplied code returned by its command-and-control server.
A self-propagating npm worm nicknamed ChainDrop infected over 400 packages that are collectively downloaded hundreds of millions of times each week. This includes malicious versions of widely used packages such as keyv and cacheable-request.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the worm gained initial access through stolen npm publishing tokens, then modified package manifests to add a preinstall lifecycle hook that executes a dropper.
Impact
The worm could expose developer workstations, CI pipelines, cloud environments and downstream users, and it could execute additional attacker-supplied code, though the RCE channel was not observed serving code during testing.
What the attacker needed
Installing an infected npm package; Stolen npm publishing token for propagation; Developer opens project in VS Code or Claude Code
The fix
The report recommends identifying and removing affected package versions, investigating developer workstations and CI runners, revoking and rotating exposed credentials, removing persistence mechanisms and blocking both exfiltration channels.
How it was found
- The infected package's package.json contains a preinstall command pointing to setup.mjs.
- setup.mjs checks for Bun on PATH and downloads Bun 1.3.13 if absent.
- Bun runs an obfuscated JavaScript payload (math_init.js).
- The payload spawns a detached background process and sets _NODE_RUNTIME_INIT=1 to prevent recursive relaunch.
- The worm harvests credentials from the environment, including cloud, developer tooling and AI tool secrets.
- With a stolen npm token, it republishes infected packages with the preinstall hook and incremented patch version.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
This is about a malicious program hidden inside widely used software packages that developers download. When someone installs an infected package, the hidden code runs automatically and steals passwords and access keys from their computer. The attackers then use those stolen keys to break into more packages and spread further.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.