Skip to main content

The TanStack npm Compromise: Actions Cache Poisoning and a Stolen OIDC Token Behind a Legitimate Trusted Publisher

· 9 min read
Ankush K
Co-founder and CTO, Dwaar
The TanStack npm Compromise: Actions Cache Poisoning and a Stolen OIDC Token Behind a Legitimate Trusted Publisher

You moved npm releases to trusted publishing so there would be no long-lived token left to steal. Yesterday TanStack showed what that does and does not buy you: 84 malicious versions across 42 @tanstack/* packages went out through the project's legitimate OIDC binding, with no npm token stolen and the publish workflow unmodified. If anything of yours installed those versions, do the checks below first.

ItemDetail
IdentifierCVE-2026-45321, GHSA-g7cv-rxg3-hmpx
Affected84 versions, two per package, across 42 packages in the TanStack/router monorepo. A maintainer says TanStack Query core was not affected
Fixed inNo clean follow-up release on npm as of 2026-05-12. The advisory lists patched numbers, but they are not on the registry, so pin to a version from before the attack
Severity9.6 Critical, CVSS 3.1, scored by GitHub as CNA. NVD shows it as a secondary metric, not its own assessment
Exploited as of 2026-05-12Yes. The chain ran and the versions shipped. The postmortem says pulling tarballs through npm security leaves them installable for hours, and lists download numbers as an open question, so there is no install count yet. Not in CISA KEV as I write this, which is no comfort
Disclosed2026-05-11: public issue 19:46 UTC, advisory 22:40 UTC per GitHub's record (the postmortem says about 21:30). NVD 2026-05-12 01:16 UTC

How a bundle-size check became a release​

The CVE record describes three known vulnerability classes chained together. Nothing here is new. Times are from the postmortem, 2026-05-11 UTC.

Pwn Request. bundle-size.yml ran on pull_request_target and built fork-controlled code in the base repository's privileged context. Fork PR #7378 opened about 10:49. A commit at 11:11 made the benchmark job execute vite_setup.mjs from the fork. This is the postmortem's excerpt of bundle-size.yml, comments included. Note the checkout of the PR merge ref, because searching only for head.sha would miss it.

on:
pull_request_target:
paths: ['packages/**', 'benchmarks/**']

jobs:
benchmark-pr:
steps:
- uses: actions/checkout@v6.0.2
with:
ref: refs/pull/${{ github.event.pull_request.number }}/merge # fork's merged code

- uses: TanStack/config/.github/setup@main # transitively calls actions/cache@v5

- run: pnpm nx run @benchmarks/bundle-size:build # executes fork-controlled code

Cache poisoning. PR runs shared the base repository's cache scope with main. The attacker's code poisoned the pnpm store, and at 11:29 the job's actions/cache post-step saved all 1.1 GB of it under the exact key release.yml computes. Read-only permissions did not help: the postmortem says cache writes use a runner-internal token rather than GITHUB_TOKEN, so contents: read does not block them. It also lists confirming the post-step from the run logs as an open question. At 11:31 the PR was force-pushed back to main HEAD and closed. The cache entry stayed. The postmortem ties this to Adnan Khan's 2024 research.

OIDC token extraction. At 19:15 a release.yml run on main restored that store. The job holds id-token: write because trusted publishing needs it. The poisoned binaries read Runner.Worker memory via /proc, extracted the token and POSTed directly to registry.npmjs.org, skipping the publish step. Batches of 42 versions landed at 19:20 and 19:26. The postmortem says this matches the March 2025 tj-actions/changed-files compromise, and The Register reports reused code from it.

Installing a bad version pulled a git optionalDependencies entry whose prepare script ran an obfuscated payload. It harvests cloud, Kubernetes, Vault, GitHub and npm credentials plus SSH keys, exfiltrates over the Session network, and republishes other packages the victim maintains.

An external researcher opened the public issue about 26 minutes after the first publish. The postmortem and advisory credit that report, while a commenter in the issue says another came earlier. TanStack deprecated the versions the same day and says all are now deprecated, with npm security engaged to pull the tarballs. A maintainer said in the issue today that the affected versions were unpublished from npm. The Hacker News calls the wider wave Mini Shai-Hulud, attributes it to TeamPCP and, citing researchers, reports over 170 npm and PyPI packages, including Mistral AI and UiPath. Those are not TanStack's figures.

What to check and do today​

Samples only. The advisory has every package. It says clean follow-up releases are being prepared, and until they arrive it says to pin to a version published before 2026-05-11 19:00 UTC. The last column is the newest such version the registry shows for each package.

PackageMaliciousLast known good
@tanstack/history1.161.9, 1.161.121.161.6
@tanstack/react-router1.169.5, 1.169.81.169.2
@tanstack/router-core1.169.5, 1.169.81.169.2
@tanstack/react-start1.167.68, 1.167.711.167.65
@tanstack/zod-adapter1.166.12, 1.166.151.166.9
  1. Search before you clean. Check lockfiles and CI logs against the advisory's list, and keep the old lockfile as evidence. In installed packages, look for this entry, and for a roughly 2.3 MB obfuscated router_init.js at the package root:

    "@tanstack/setup": "github:tanstack/router#79ac49eedf774dd4b0cfa308722bc463cfe5885c"
  2. Search egress logs. Look for filev2.getsession.org, seed1.getsession.org through seed3.getsession.org, and litter.catbox.moe. The advisory says the Session channel has no attacker-controlled C2, so blocking by IP or domain is the only network mitigation for it. Block these hosts, but do not read this list as complete: The Hacker News also reports a fallback that commits stolen data to attacker-controlled repositories through the GitHub GraphQL API, and injected workflows that upload secrets to api.masscan[.]cloud.

  3. If you installed one, assume compromise. The advisory, as quoted by The Register, says any environment that installed an affected version on 2026-05-11 "should be considered compromised."

  4. Isolate and image before you revoke. A commenter in the issue warned that revoking tokens may trigger a dead-man's switch, installed as a systemd user service on Linux or a LaunchAgent on macOS, that polls api.github.com/user with the stolen token and runs rm -rf ~/ when it is revoked. The Register describes this as a GitHub token and The Hacker News as an npm token the malware created, so treat both as tripwires until the host is imaged. Then rotate every AWS, GCP, Kubernetes, Vault, GitHub, npm and SSH credential reachable from that host.

  5. Rebuild clean. The advisory says to pin every @tanstack/* dependency to a version published before 2026-05-11 19:00 UTC, delete node_modules and the lockfile, reinstall, and temporarily skip lifecycle scripts:

    npm config set ignore-scripts true
  6. If you maintain packages, check for versions you did not publish. The worm enumerates targets with registry.npmjs.org/-/v1/search?text=maintainer:<user>, so hunt for that too.

Trusted publishing did its job, and that is the point​

Trusted publishing answers one question: did this publish come from this repository's workflow? Here it did. Removing the long-lived token was still right. It just moved the target to a short-lived token inside the job, and to everything that job trusts.

Provenance has the same limit, and this is my reasoning, not a finding. It tells you where a package was built, not whether the build was honest. A job that restored an attacker's binaries is still the right repository and the right workflow. The Hacker News, relaying researchers, reports these packages carried valid SLSA Build Level 3 provenance. I cannot find that in a primary source, so treat it as reported.

Reviewing main would have found the weak workflow, not the payload. That is the case for scanning the artifact you ship, and why a malicious package is a different problem from a vulnerable one: your install records decide who is exposed, not a severity score.

Three positions for your own pipeline. Never build fork code under pull_request_target. Treat the cache as an input to your release, so a job with id-token: write restores nothing an untrusted run can write. And pin actions to SHAs, as TanStack now does alongside repository_owner guards and a cache purge, without expecting pins alone to stop this chain, because the poison arrived through a cache.

Now open your release workflow. Find the job with id-token: write, list every cache it restores, and work out which workflows can write those keys. If one of them runs on pull_request_target, you have TanStack's shape in your own repository.

References​