← Back

TanStack npm Compromise: Dead-Man's Switch Attack Explained

The TanStack npm packages were compromised in a sophisticated attack that used a dead-man's switch to wipe credentials—here's what every developer needs to know and do.

The TanStack npm compromise, disclosed on May 11, 2026, sent shockwaves through the open-source community. Several packages—including @tanstack/router and @tanstack/react-router—were compromised via stolen npm tokens. The attack introduced a malicious payload with a chilling dead-man's switch that punished victims for revoking the attacker's credentials. This incident forces every developer to rethink their assumptions about package security.

How the Attack Worked

The attack chain started with stolen npm tokens, likely obtained through developer credential theft or a CI pipeline breach. The attackers published malicious versions of TanStack packages that executed a postinstall script. That script dropped a shell script into ~/.local/bin/gh-token-monitor.sh and set up a systemd user service (Linux) or LaunchAgent (macOS) to run it every 60 seconds. The script periodically called api.github.com/user with any stolen GitHub token it found. If the token was revoked (HTTP 40x), it executed rm -rf ~/—wiping the home directory.

TanStack published a postmortem detailing the attack: the attacker gained access to publish credentials, bypassed 2FA, and published new versions. The malicious versions have been removed from the npm registry, and TanStack rotated all tokens. Separately, the Mistral npm package was compromised via similar tactics.

Why It Matters for Supply Chain Security

This attack is a stark reminder that npm's security model remains fundamentally flawed. The dead-man's switch is a nasty twist—it punishes the victim for reacting correctly. But the core issue is that a stolen token can still publish malicious packages. Trusted Publishing (TP) removes the need for long-lived tokens, but as the community pointed out on Hacker News, TP doesn't prevent an attacker who has compromised your CI or repo admin access. It's not a silver bullet.

The worm-like behavior is particularly worrying. The attacker specifically targeted GitHub tokens, suggesting they planned to chain compromises—the real target wasn't TanStack users, it was their GitHub credentials. This is supply chain attack 2.0: not just injecting code, but stealing keys for lateral movement.

Immediate Actions for Developers

1. Enable ignore-scripts globally

Npm, pnpm, and bun all support this. Add the following to your ~/.npmrc:

ignore-scripts=true

If you need lifecycle scripts for a specific package, run npm install --ignore-scripts=false only when necessary. This alone would have blocked the TanStack payload.

2. Set a minimum release age

Npm 10+ allows you to configure min-releases in your .npmrc to reject packages that haven't been published long enough. For example:

min-releases=1

This prevents malicious versions published moments ago from being installed. Consult the npm security best practices for details.

3. Leverage npm provenance

Publish your packages with provenance statements so users can verify they were built on a trusted CI. See the npm provenance docs.

4. Rotate tokens aggressively

If you have long-lived npm tokens, replace them with short-lived ones. For GitHub, use fine-grained tokens with minimal scopes.

5. Audit your CI pipelines

Ensure only trusted workflows can publish to npm. Use environment-based secrets and follow least privilege.

What This Means Going Forward

This incident highlights the urgent need for mandatory package signing and content-addressed packages. npm's provenance feature is a step forward, but adoption is voluntary and verification isn't widespread. Until then, the burden falls on each of us.

If you maintain any npm package with more than a few hundred weekly downloads, assume your credentials are a target. If you're a consumer, running ignore-scripts and enforcing minimum release ages will protect you from 90% of these attacks. As the attack surface grows, complacency is the real vulnerability.

Key takeaway: The TanStack compromise isn't an isolated incident—it's a blueprint for future attacks. Update your defenses today.