osec.one case analysis cover: TanStack 2026: a fork pull request that poisoned the pnpm cache, and why GitHub made caches read-only

On 11 May 2026 between 19:20 and 19:26 UTC, 84 malicious versions of 42 @tanstack/* npm packages were published from TanStack's own release workflow, with valid trusted-publishing credentials. No maintainer's npm token was stolen, the publish step in the workflow never ran (the tests had failed), and the pull request that started it all had been closed almost eight hours earlier with zero changed files.

The bridge was the GitHub Actions cache. A fork pull request ran code in a pull_request_target job, that code wrote a poisoned pnpm store into the cache under the key the release workflow would look for, and the next release restored it. Six weeks later GitHub changed how the cache works for every repository. This case analysis follows each step with TanStack's own timestamps, shows what our Workflow risk check finds in the files as they were, and where it falls short.

It differs from Ultralytics 2024, where a shell command hidden in a branch name was the way in and the pip cache was the bridge, and from our npm 12 and 2026 GitHub Actions hardening piece, which covers the new rules. Here the pull request's code was simply checked out and run, in a job its authors had labelled untrusted.

Attack chain: a fork pull request triggers bundle-size.yml on pull_request_target; the job checks out the PR merge ref and runs its build, which loads a 30,000-line vite_setup.mjs; the code writes a 1.1 GB pnpm store saved to main's cache scope; eight hours later release.yml restores it; attacker binaries read the OIDC token from runner memory; 84 versions are published to npm in six minutes
Eight hours between the poison and the release; 20 to 26 minutes until a researcher outside the project noticed.

The timeline

text
TanStack/router, 10-15 May 2026 (UTC, from TanStack's postmortem)

10 May 17:16     fork zblgg/configuration created
11 May ~10:49    PR #7378 "WIP: simplify history build" opened against main;
                 bundle-size.yml and labeler.yml (pull_request_target) run at once,
                 pr.yml (pull_request) waits for first-time-contributor approval
11:01-11:11      several force-pushes, each starting new pull_request_target runs
11:11            commit 65bf499d lands: vite_setup.mjs, about 30,000 lines of bundled JS
11:29            cache entry Linux-pnpm-store-6f9233a5... (1.1 GB) saved, scope refs/heads/main
11:31            PR force-pushed back to main's HEAD (0 files changed), closed, branch deleted
19:15:44         Release workflow re-run (attempt 4); poisoned cache restored
19:16:22         new Release run after a merge to main; same cache restored
19:20:39         npm receives the first batch of 42 versions
19:26:14         npm receives the second batch of 42
19:46:46         StepSecurity researcher opens issue #7383
~20:10           maintainers remove other team members' push rights
20:19-21:03      all 84 versions deprecated
by 21:30         every cache entry purged, hardening PR merged, advisory published
22:13-23:55      npm removes the tarballs
15 May           all-clear: only the Router/Start repository affected

The poison sat in the cache for 7 hours 46 minutes (11:29 to 19:15). The project learned about it from outside: "We got no internal alerting", the postmortem says. The first public report came 26 minutes after the first batch.

Step 1: a pull_request_target job that ran the pull request

bundle-size.yml measured how a pull request changed the size of the bundles and posted a comment. Posting a comment on a fork PR needs a token with write rights, which pull_request from a fork doesn't get, so it used pull_request_target. The file split the work into two jobs and said so in its header:

yaml
# bundle-size.yml at d296252 (17 March 2026), abridged
on:
  # We use `pull_request_target` to split trust boundaries across jobs:
  # - `benchmark-pr` checks out PR merge code and runs it as untrusted with read-only permissions.
  # - `comment-pr` runs trusted base-repo code with limited write access to upsert the PR comment.
  pull_request_target:
    paths: ['packages/**', 'benchmarks/**']
permissions:
  contents: read
jobs:
  benchmark-pr:
    steps:
      - uses: actions/checkout@v6.0.2
        with:
          ref: refs/pull/${{ github.event.pull_request.number }}/merge
          persist-credentials: false
      - uses: TanStack/config/.github/setup@main      # pnpm install, with the pnpm store cache
      - run: pnpm nx run @benchmarks/bundle-size:build

The design is careful: read-only token, no credentials left in git, the write step in a separate job that doesn't run PR code. What it missed is that permissions: doesn't cover the cache. Cache reads and writes use a runner-internal token, not GITHUB_TOKEN, and a pull_request_target run uses the default branch's cache scope. So the "untrusted, read-only" job could write cache entries that every branch, including the release, would restore. pull_request_target also skips the approval GitHub asks for before running a first-time contributor's workflows; that gate held pr.yml back, but not this one.

Our test: what the Workflow risk check says about these files

We ran the osec Workflow risk check on both files as they were before the attack (bundle-size.yml at commit d296252 of 17 March 2026, release.yml at 3a32ad6):

text
osec Workflow risk check, 25 Oct 2026, on the pre-attack files

file               danger  warn  findings
bundle-size.yml    1       1     pull_request_target checks out the pull request's code
                                 2 actions on a tag or branch (TanStack/config/.github/setup@main,
                                 actions/checkout@v6.0.2)
release.yml        0       1     2 actions on a tag or branch (same two)

not flagged: release.yml restores the pnpm cache. The actions/cache step is inside the
remote composite action TanStack/config/.github/setup@main, which the check doesn't open.

The way in is flagged as danger. The bridge isn't: our check looks for cache restores in the workflow file and in composite actions inside the same repository, and TanStack's cache step lived in a shared action in another repository. We've recorded following remote composite actions as the next improvement to the check. Until then, read the shared actions your release job uses yourself.

Step 2: writing the pnpm store under the release's key

The shared setup action cached the pnpm store with a key built from the lock file:

yaml
# TanStack/config/.github/setup/action.yml (before 11 May 2026), abridged
- uses: actions/cache@v5.0.4
  with:
    path: ${{ env.STORE_PATH }}
    key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
    restore-keys: |
      ${{ runner.os }}-pnpm-store-
- run: pnpm install --frozen-lockfile

The PR didn't touch pnpm-lock.yaml, so its job computed the same key as release.yml on main: Linux-pnpm-store-6f9233a5.... The attacker's vite_setup.mjs ran during the build, put its own files into the pnpm store on disk, and actions/cache saved the whole store at the end of the job: 1.1 GB, scope refs/heads/main. The restore-keys prefix made it worse: on an exact miss, any entry starting Linux-pnpm-store- is restored, newest first.

Two minutes after the save, the attacker force-pushed the PR back to main's HEAD and closed it. Anyone looking at PR #7378 afterwards saw an empty, abandoned draft.

Step 3: the release restored it

release.yml ran on every push to main, with id-token: write at the top of the file (for npm trusted publishing) and the same setup action as its first install step, before the tests. At 19:15 a maintainer re-ran an earlier release, and at 19:16 a merge started another. Both restored the poisoned store, so attacker-controlled binaries were on disk and ran during the build and test steps.

Both runs ended as failed: the tests broke, so the workflow's own Publish step was skipped. That didn't matter.

Step 4: the OIDC token, read from memory

With id-token: write, the runner can mint a short-lived OIDC token that npm's trusted publishing accepts in place of an npm token. The runner creates it lazily, in the memory of the Runner.Worker process. TanStack's postmortem lists what the malware did: find that process through /proc/*/cmdline, read /proc/<pid>/maps and /proc/<pid>/mem, pull out the token, and POST the packages straight to registry.npmjs.org. Two versions of each of 42 packages, about six minutes apart, one batch per run.

This is why "we use trusted publishing, there's no npm token to steal" isn't the end of the story. Trusted publishing removes long-lived tokens. It doesn't stop code running in the same job from using the short-lived one. The control is to make sure no code from a cache, a dependency install or a test suite runs in the job that holds id-token: write.

Step 5: what an install did

Each malicious version added an optionalDependencies entry pointing to an orphan commit in the fork network. On npm install, pnpm install or yarn install that commit was fetched, its prepare script ran, and a 2.3 MB obfuscated router_init.js looked for credentials: AWS instance metadata and Secrets Manager, GCP metadata, Kubernetes service-account tokens, Vault tokens and more. TanStack's advice to anyone who installed an affected version on 11 May: rotate AWS, GCP, Kubernetes, Vault, GitHub, npm and SSH credentials reachable from that machine. The advisory is GHSA-g7cv-rxg3-hmpx, CVE-2026-45321, CVSS 9.6.

A release cooldown (installing only versions older than a day or three) would have kept these versions out of most builds: all 84 were deprecated within two hours of publishing and removed within about 4.5 hours.

Why GitHub made caches read-only

text
GitHub Actions cache rules, before and after (GitHub changelog and docs)

                                   before 26 June 2026        after 26 June 2026
pull_request_target                read + write, main scope   read-only in main's scope
issue_comment                      read + write, main scope   read-only in main's scope
workflow_run from a fork PR        read + write, main scope   read-only in main's scope
push, schedule, workflow_dispatch  read + write               read + write
pull_request                       own PR scope only          own PR scope only
blocked save                       -                          warning in the log, job goes on

10 Sep 2026: cache-mode key (workflow or job level): read | write | write-only | none
             default read for low-trust events, write for trusted ones;
             write on a low-trust trigger raises a warning annotation

On 26 June 2026 GitHub started issuing read-only cache tokens for the default branch to events that can be started without write access to the repository. The changelog doesn't name TanStack, but under these rules step 2 fails: benchmark-pr can still restore the store, but its save is skipped with a warning. On 10 September the cache-mode key let a workflow say what it wants; a release that should never touch the cache can say cache-mode: none. On 17 September GitHub also announced workflow execution protections, including a default rule that turns pull_request_target off in public repositories, with enforcement from 2 December 2026.

None of this removes the need to separate the jobs. A trusted push workflow can still save a cache that a release then restores, and a poisoned dependency doesn't need the cache at all.

What to change in your own repository

1. No PR code in pull_request_target. Measure the PR with pull_request (no secrets, its own cache scope), upload the result as an artifact, and post the comment from a separate workflow_run job that only reads the artifact as data.
2. Release jobs don't use the Actions cache. Set cache-mode: none on the release workflow, and drop restore-keys prefixes anywhere near a release.
3. id-token: write only on the publish job, which downloads a built, tested artifact and publishes it: no install, no tests, no shared setup action in that job.
4. Pin shared setup actions to a commit, and read them: they decide what your release restores.
5. Alert on your own publishes: a webhook or a scheduled job that compares npm's latest versions with your release tags would have fired at 19:20, not 19:46.
6. After an incident, purge the cache first, then rebuild: a fix release that restores the same entry rebuilds the compromise.

yaml
# release.yml: the publish job holds the OIDC permission and nothing else runs in it
cache-mode: none
permissions:
  contents: read
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@<full commit sha>   # v6
      - run: pnpm install --frozen-lockfile && pnpm test && pnpm build && pnpm pack
      - uses: actions/upload-artifact@<full commit sha>
        with: { name: tarballs, path: '*.tgz' }
  publish:
    needs: build
    runs-on: ubuntu-latest
    environment: npm            # required reviewers on this Environment
    permissions:
      id-token: write
    steps:
      - uses: actions/download-artifact@<full commit sha>
        with: { name: tarballs }
      - run: for f in *.tgz; do npm publish "$f" --provenance; done

The free osec Workflow risk check flags step 1 in any public repository, and release workflows that restore the cache when the restore is in the workflow or in an action.yml in the same repository. The Action pin lookup turns @main and @v6.0.2 into commit SHAs.

Paste a public GitHub repository and see its pull_request_target checkouts, injected PR text, release jobs that restore the cache and unpinned actions, each with the fix. Free.

Check a repository's workflows

Sources

• TanStack: npm supply chain compromise postmortem (11 May 2026, updated 15 May): https://tanstack.com/blog/npm-supply-chain-compromise-postmortem
• GitHub advisory GHSA-g7cv-rxg3-hmpx / CVE-2026-45321: https://github.com/TanStack/router/security/advisories/GHSA-g7cv-rxg3-hmpx
• Tracking issue TanStack/router#7383: https://github.com/TanStack/router/issues/7383
• The workflow files as they were: https://github.com/TanStack/router/blob/d296252f73241c8aca41bd231b57f18e647abd46/.github/workflows/bundle-size.yml, https://github.com/TanStack/router/blob/3a32ad6cfbc9dce7a31842e31184955400144dec/.github/workflows/release.yml and https://github.com/TanStack/config/blob/d8cef73c4209d91ca578274ce6f83770f64752d3/.github/setup/action.yml
• GitHub changelog: Read-only Actions cache for untrusted triggers (26 June 2026): https://github.blog/changelog/2026-06-26-read-only-actions-cache-for-untrusted-triggers/
• GitHub changelog: Control GitHub Actions cache access with cache-mode (10 Sep 2026): https://github.blog/changelog/2026-09-10-control-github-actions-cache-access-with-cache-mode/
• GitHub changelog: Workflow execution protections generally available (17 Sep 2026): https://github.blog/changelog/2026-09-17-workflow-execution-protections-in-github-actions-generally-available/
• GitHub docs: dependency caching, scope and limits: https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching
• Adnan Khan: The Monsters in Your Build Cache (6 May 2024): https://adnanthekhan.com/2024/05/06/the-monsters-in-your-build-cache-github-actions-cache-poisoning/
• SafeDep: TanStack GitHub Actions cache poisoning: https://safedep.io/tanstack-github-actions-cache-poisoning/