On 11 May, between 19:20 and 19:26 UTC, 84 malicious versions of 42 @tanstack/* packages landed on npm. Six minutes. Every one of them carried a valid SLSA Build Level 3 provenance attestation — the cryptographic receipt that says "this was built by the project's own pipeline". It was true. The pipeline had been turned against its owners.
Eight days later the same family of worm, Mini Shai-Hulud, published 639 poisoned versions of 323 packages in about an hour, most of them in the @antv ecosystem. Within 48 hours of the first wave it had already spread to 172 packages across npm and PyPI.
If your product is built with JavaScript, those numbers are not someone else's news. Your node_modules folder is the largest codebase you ship, and you wrote almost none of it.
How the two waves worked
The TanStack wave is the one to study, because it beat the controls the industry has been asking for. According to the post-mortems, the attacker opened a pull request from a fork that poisoned the GitHub Actions cache. The project's release workflow later restored that cache, and the attacker's binaries read the short-lived OIDC publish token straight out of the runner's memory. The tests failed and the publish step was skipped — and the signed packages reached the registry anyway.
The @antv wave was cruder and just as effective. Each infected package gained a preinstall hook that ran a script the moment anyone installed it. The script collected what a developer machine or a CI runner keeps lying around — GitHub and npm tokens, AWS credentials, Kubernetes and Vault secrets, SSH keys, Docker auth, database connection strings — and sent it away. Then it used the stolen npm token to list every package the victim could publish, injected itself into them, bumped the version and republished them under the victim's name. That is what makes it a worm: each infection publishes the next ones.
Why the controls did not stop it
npm has tightened a lot since late 2025. Classic tokens were revoked for good on 9 December 2025. A new write token now expires after seven days by default, and after ninety at most. Publishing enforces 2FA. Trusted publishing replaces stored tokens with credentials minted for a single CI job. All of that is good, and all of it was in place for at least part of what happened in May.
The pattern is the uncomfortable part. Each control closes the door the last attack used:
- 2FA stops a stolen password. The worm does not need one; it uses tokens that already passed 2FA.
- Short-lived tokens limit how long a stolen token works. An hour is plenty for a worm that republishes in minutes.
- Provenance proves where a package was built. It says nothing about whether the build was hijacked.
- Trusted publishing removes stored secrets, but its token is only as narrow as the workflow you allow to request it. In the TanStack case it was the whole repository.
None of these is useless. They are necessary, and they are not sufficient. As one researcher put it after the TanStack incident, the control that actually mattered was the scope of the OIDC trust — not provenance, not 2FA.
Five settings that would have helped
Most teams are not publishers; they are consumers. The good news is that the consumer side has cheap, boring defences, and they are exactly the kind that hold up against an attack nobody has seen yet.
-
Install from the lockfile, nothing else. In CI,
npm ci,pnpm install --frozen-lockfileorbun install --frozen-lockfile. A poisoned version can only reach you when something resolves a new version; a frozen install never does. -
Do not run your dependencies' install scripts by default. The
@antvpayload lived in apreinstallhook. pnpm 10 and Bun already refuse to run dependency lifecycle scripts unless you allow a package by name; with npm, setignore-scripts=truein.npmrcand allowlist the few packages that genuinely need a build step. -
Wait before you upgrade. Both waves were detected within minutes to an hour. A cooldown that refuses versions younger than a day would have skipped them entirely, at the cost of getting patches a day later. pnpm 11 now does this by default, waiting 24 hours; npm (
min-release-age), Bun and Yarn have their own setting for it, and Renovate can hold its pull requests the same way. -
Keep secrets away from the job that installs. Any script that runs during an install can read the environment it runs in. The job that runs
installand the tests should not hold your cloud keys or publish rights. If you publish, grantid-token: writeonly to the publish job, scope trusted publishing to one workflow on a protected branch, and never let a fork's code share a cache with your release. - Have fewer dependencies. Every package is a maintainer account you are trusting with your build machine. The cheapest dependency to secure is the one you removed.
Honesty corner
None of this makes you immune. A lockfile pins a version that may already be bad; a cooldown protects you from fast-moving worms, not from a patient attacker who waits a week. The goal is not zero risk. It is to make sure that the next wave — and there will be one, the cadence this year has been monthly — finds nothing to run and nothing to steal on your machines.
The business version
If you run a company rather than a codebase, three questions to ask your team or your vendor this week:
- Does CI install strictly from the lockfile, with install scripts off by default?
- Which secrets does the job that installs dependencies have access to — and why?
- If a maintainer we depend on were compromised tonight, how would we know, and how long would it take us to rotate everything?
A team that answers all three without hesitating has done the work. A team that has to think about it has a weekend of configuration ahead, which is far cheaper than the alternative.
I'm an independent software architect focused on front-end work. Technical audits of JavaScript codebases — dependencies, build pipelines, the things that only get looked at after an incident — are a good part of what I do. If you'd like a second pair of eyes on yours, let's talk: a 30-minute intro call is free.
Top comments (0)