What I Changed the Morning After TanStack Was Compromised
On May 11, 2026, 84 malicious versions of TanStack packages went up on npm. Our team’s app, an invoicing tool for a university project, used two of them directly: @tanstack/react-router and @tanstack/react-query. Nobody on the team had run an install that pulled a new version during the window, so nothing bad landed. The next morning I made two changes so that luck would not be the plan next time.
What Happened
Snyk’s write-up has the full chain, so here is the short version. The attacker never stole an npm password. Their code got into TanStack’s own release workflow through a GitHub Actions pull request trigger and a poisoned pnpm cache, then read the workflow’s publishing token out of the runner’s memory. Between 19:20 and 19:26 UTC, that token published 84 versions across 42 packages.
Because the real pipeline built and published them, the malicious versions carried valid SLSA build provenance. A provenance check would have passed. According to Snyk, the versions were live for about three hours.
That last number is the useful one. Malicious versions tend to get caught and pulled quickly. pnpm’s own docs say most are removed within an hour. If your installs simply refuse anything younger than a day, a three-hour window never reaches you.
Change One: A One-Day Install Cooldown
pnpm 10.16 added a setting for exactly this. It takes a number of minutes, and pnpm will not install any version, direct or transitive, that was published more recently than that. Our project was on pnpm 10.18, so this went into .npmrc:
# Refuse any package version published less than a day ago.
# Requires pnpm >= 10.16.
minimum-release-age=1440
The web app had its own lockfile and was not part of a pnpm workspace, so the line had to live in its own .npmrc too. Without that, the web app ignored the root setting.
Snyk’s post says a seven-day cooldown would have fully protected against this attack. I went with one day. Seven days also delays every legitimate security fix by a week, and for this attack, which was live for three hours, one day was already enough. That is a judgment call, not a measurement.
The escape hatch, for the rare day you need a version that is hours old, is to exempt that exact version rather than turning the cooldown off. pnpm 10.19 added minimumReleaseAgeExclude for this, for example - nx@21.6.5.
Change Two: Exact Versions in the Manifest
The second change was replacing every ^ and >= in the manifests with an exact version:
// before
"@tanstack/react-router": "^1.123.0",
"@tanstack/react-query": "^5.91.0",
// after
"@tanstack/react-router": "1.123.5",
"@tanstack/react-query": "5.91.7",
It is worth being honest about what this buys, because it is less than it looks. The lockfile already pins every installed version, and CI installs with --frozen-lockfile. A range in package.json does not change what a normal install gets.
Ranges matter at the moments the lockfile gets rewritten: someone adds a dependency, runs pnpm update, or resolves a lockfile merge conflict by regenerating it. In any of those, a ^ range lets the resolver pick the newest matching version, which during an attack is the malicious one. With exact versions, a new version only arrives through a pull request that changes the number on purpose. The Python side of the app got the same treatment, with == pins in pyproject.toml.
One part did not follow the rule. We also had a few pnpm.overrides entries forcing transitive dependencies up to patched versions, like "rollup": ">=4.59.0". Those are ranges, not pins. The cooldown is what covers that path.
Update, December 2026: pnpm 11 Moved the Setting
If you copied the .npmrc line above, check it after upgrading. pnpm 11 reads only auth and registry settings from .npmrc, and it no longer reads the pnpm field in package.json. Both the cooldown line and the overrides block from May stop applying.
pnpm 11 also turned the cooldown on by default at 1,440 minutes, but in a lenient mode. If no version old enough satisfies your range, it falls back to a younger one so the install still succeeds. Setting the value yourself makes it strict. In pnpm 11 that goes in pnpm-workspace.yaml:
minimumReleaseAge: 1440
overrides:
rollup: ">=4.59.0"
So you may be protected without doing anything, but only loosely, and any override you relied on is gone until you move it.
Where This Falls Short
- A cooldown only helps against attacks that get caught quickly. A malicious version that stays unnoticed for two days walks straight through a one-day window.
- It delays fixes too. A legitimate security patch waits a day unless you exempt it.
- It covers pnpm only. The Python dependencies here had pins but no equivalent age check.
- Pinning does not protect a lockfile you regenerate carelessly. It narrows when a new version can arrive. It does not decide whether that version is safe.
The two changes together took about two hours. Neither depends on anyone reading security news on the right morning, which is the point.