Keyv npm Worm Spreads to Hundreds of Packages, Steals Developer Credentials
A malicious release of keyv — a popular JavaScript key-value storage library — spent August 4 spreading itself across the npm registry like a very determined digital virus, according to The Hacker News.
The attack began in keyv@6.0.0, which included a preinstall script (a command that runs automatically when you install a package) that silently executed a credential-stealing payload. That payload harvested GitHub tokens, npm credentials, cloud service keys, Kubernetes (a system for managing software deployments) secrets, database credentials, and private cryptographic keys. It also read GitHub Actions runner memory — the temporary environment used in automated software build pipelines — and installed a watcher to intercept any attempt to revoke the stolen tokens.
Once credentials were stolen, the worm used the victim's npm publishing access to push poisoned versions of other packages it could reach. Security firm SafeDep verified 353 poisoned versions across 79 package names. Aikido separately reported at least 868 affected packages across 1,381 versions. The numbers reflect different measurement points; neither total was independently reproducible from a complete public list at time of reporting.
The Keyv repository also contained hidden hooks for Claude Code and VS Code (a widely used code editor) that could trigger the payload when a developer opened the project, provided workspace trust had been granted.
The critical wrinkle for anyone responding: SafeDep warns you must remove the worm's token-revocation watcher before rotating any exposed credentials. Revoking first triggers an attacker-controlled local handler. Remove the malware, then rotate.
What you should do: If you installed any npm package on August 4, check your exact resolved versions and lockfiles against the advisories from SafeDep and Socket. Treat any affected machine or CI runner as fully credential-compromised. Upgrade to npm 12 where possible — it blocks unapproved lifecycle scripts by default.
Sources

