Postmortem: TanStack NPM supply-chain compromise
TL;DR Highlight
A fork PR poisoned the CI cache and got 84 malicious TanStack versions published across 42 packages.
Who Should Read
Developers who publish npm packages with GitHub Actions or use pull_request_target in their CI.
Core Mechanics
- Three flaws chained together
- On 2026-05-11 between 19:20 and 19:26 UTC, 84 malicious versions went out across 42 @tanstack/* packages.
- The attack combined the pull_request_target Pwn Request pattern, Actions cache poisoning, and OIDC token extraction from runner memory.
- No npm tokens were stolen and the publish workflow itself was not compromised.
- A fork PR poisoned the cache
- bundle-size.yml checked out the fork's merge ref under pull_request_target and ran a build.
- Fork code saved poisoned data under the pnpm store cache key Linux-pnpm-store-${hashFiles('**/pnpm-lock.yaml')}.
- release.yml on main later restored that cache as-is.
- permissions: read does not block cache writes
- The post-job save in actions/cache@v5 uses a runner-internal token, not the workflow GITHUB_TOKEN.
- So permissions: contents: read cannot stop cache mutation.
- Cache scope is per-repo, shared between pull_request_target runs and pushes to main.
- Publishing bypassed the real publish step
- release.yml had id-token: write, so malicious code dumped the OIDC token from runner memory (/proc/<pid>/mem).
- It POSTed directly to registry.npmjs.org with that token.
- The real Publish Packages step was skipped because tests failed, yet publishing still happened.
- Install alone leaks credentials
- On npm install, optionalDependencies fetched an orphan commit from the fork network and ran a prepare script that executed a ~2.3 MB router_init.js.
- It harvests AWS, GCP, Kubernetes, Vault, ~/.npmrc, GitHub tokens, and SSH keys.
- It self-propagates by republishing other packages the victim maintains.
- Detected externally, cleaned up by npm
- StepSecurity's ashishkurmi opened issue #7383 about 20 minutes after publish; public detection took about 26 minutes.
- All 84 versions were deprecated about 1h 43m after the first publish.
- npm's no-unpublish-with-dependents policy meant npm security pulled tarballs server-side, with the last removal about 4h 35m after publish.
Community Reactions
- Warning that the malware reacts to credential revocation
- A commenter shared analysis that the payload installs a gh-token-monitor service (systemd/LaunchAgent) that polls api.github.com/user every 60s.
- If the token is revoked and returns HTTP 40x, it runs rm -rf ~, so be careful when revoking tokens.
- Opinion that Trusted Publishing alone isn't enough
- A commenter argued that moving from local 2FA publishing to CI publishing removes the second factor.
- They want staged publishing, where an artifact is promoted on the npm side with 2FA.
- Experience that cooldowns and ignore-scripts would have helped
- A commenter shared min-release-age settings for npm, pnpm, bun and uv, plus ignore-scripts=true in ~/.npmrc.
- They wrote that, per the analysis, ignore-scripts alone would have mitigated this attack.
- Proposals to split the release pipeline
- Commenters suggested pull_request_target jobs should read caches but never write them.
- Others suggested releasing without caches, or publishing a prebuilt tarball from an isolated pipeline.
- Reports that the blast radius went beyond TanStack
- A commenter said the @mistralai/mistralai npm package was also compromised by the same worm and has been pulled.
- Another comment cited StepSecurity calling it the Mini Shai-Hulud worm and tracking its spread.
How to Apply
- Find pull_request_target workflows in your repo
- Run grep -rn pull_request_target .github/workflows today.
- Where a workflow checks out or builds fork code, split it so only trusted tasks like labeling and commenting remain.
- Drop cache restore from release workflows
- Remove actions/cache and cache-restoring setup steps from jobs that have id-token: write or publish rights.
- Install from the lockfile and build fresh.
- Pin third-party actions to SHAs
- Replace floating refs like @main or @v6.0.2 with commit SHAs.
- TanStack made the same change in its response.
- Set cooldown and script blocking on dev machines
- Add min-release-age=7 and ignore-scripts=true to ~/.npmrc.
- For pnpm, set minimum-release-age=10080 (minutes).
- If you installed affected @tanstack/* versions on 2026-05-11, rotate credentials reachable from that host.
Try It
# Paste into Claude Code (run at repo root). Prompt to audit for the incident's patterns
Read every workflow under .github/workflows and summarize in a table. Do not modify any files; report only.
1. Jobs that use the pull_request_target trigger and check out or run install/build/test on fork code (github.event.pull_request.head.*, refs/pull/*/merge)
2. Jobs with id-token: write or publish permissions that restore caches (actions/cache or setup actions with caching, e.g. setup-node cache, pnpm store)
3. Third-party actions referenced by tag or branch (@main, @v4, etc.) instead of a 40-character commit SHA
For each item give the file, line number, one sentence on why it is risky, and one sentence on the fix.
Target repo: {{repo path}}Terminology
Related Papers
Frostbite: A new CPU architecture discovered, designed and verified by AI
AI agents designed a CPU from scratch, claiming 4.59x perf/W over a traditional core
Restricting AI agents in mobile operating systems platforms from capturing data
Signal now blocks OS-level AI agents from reading its screen on iOS 27 and Android
Actions Speak Louder than Words: Stateful Privacy Sniffing of LLM Agents via Behavioral Covert Channels in Web Interactions
Agents' link choices alone let attackers rebuild user queries at F1 0.89; SOR cuts it to 0.39.
Tracking and Limiting Unsupported Claim Propagation in Multi-Agent LLM Systems: A Provenance-Aware Framework
Passing claims with source, evidence and history kept equivalence at 5 agent stages at 96% versus 31%.
LLM assisted reverse engineering
Pointing an agent at binaries with skills and MD notes made years-long hacks feasible
Metrics-in-the-Loop: Complexity Feedback Reshapes Agent-Written Code
Injecting per-turn complexity reports into coding agents cut code erosion without changing correctness
Why is Gemini 4 Carbon taking so long?
Carbon took nearly an hour on bug fixes that Astra and Opus finished in minutes, mostly from extra unrequested work.
Weight-Space Programming builds neural networks like a 1990s researcher
LLM hand-wrote MNIST weights to 91.3%, using 1990s-style techniques