Threat Actor Exposes Playbook for Exploiting NPM to Build Blockchain-Powered
A threat actor published a playbook on an underground forum describing how to typosquat popular npm packages and abuse postinstall scripts to turn developers' machines into a cross-platform botnet whose command-and-control address is fetched from an Ethereum smart contract. The resulting packages were downloaded over 26,000 times, letting the operator run arbitrary JavaScript, open terminals and push further malware to infected systems.
socket.dev
Published on socket.dev
Threat ResearchSecurity News
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 npm ecosystem's trust model: install-time lifecycle scripts run with the installing user's permissions, and near-identical package names are easy to publish, so a typo silently executes attacker code.
Impact
Infected developer machines could be remotely controlled, with arbitrary code execution, file transfer and further malware deployment, though the actor admits about half of the packages were flagged and removed.
What the attacker needed
Developer installs a typosquatted package; install scripts allowed to run; no review of package names or scripts
The fix
The malicious packages were reported to the npm registry and removed, but the underlying weakness should be fixed by reviewing install scripts and dependency names before installing.
How it was found
- Generate many typo variants of popular package names, using ChatGPT to speed this up.
- Create a package whose package.json postinstall script runs a bundled install script.
- Obfuscate the install script so it evades static detection.
- On install, the script fetches the command-and-control address from an Ethereum smart contract.
- The script downloads an executable to the temporary directory and runs it in the background.
- The bot copies itself into a startup location so it survives reboots.
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.
When you install a package with npm, the package can carry a small setup script that runs automatically on your computer. Attackers publish packages with names almost identical to popular ones, so a typo makes you install theirs, and their setup script then downloads and runs malware. Here the malware also asks a public blockchain for the address of its control server, so there is no fixed address to block.
What is RCE?
Running the attacker's code on the target's servers: through command or code injection, unsafe deserialisation or template injection.