Back

~/blog/poisoned-npm-releases.mdx

84 poisoned npm releases in six minutes, and the one config that keeps them out

3 min read#bun #security

In May, after a batch of poisoned TanStack releases went out on npm, we told our backend to stop installing any package version younger than 14 days.

It took one line of config, and in six months it hasn't blocked a single install we needed.

Some context first. I work with a small team on a backend: TypeScript on Bun, with Postgres and ClickHouse behind it. Every bun install, whether on a laptop, in CI or in a deploy, pulls from npm.

On May 11, 2026, an attacker published 84 malicious versions across 42 @tanstack/* packages in about six minutes. They carried credential stealers, and GitHub's advisory said any machine or CI runner that installed one that day should be treated as compromised. It was reported within about half an hour. In the next few days, we merged our change.

What changed

Bun 1.3 added minimumReleaseAge to bunfig.toml. The value is in seconds. When Bun picks a version to install, it skips anything published more recently than that. We set it to 14 days, which is 1,209,600 seconds.

Why it works

A poisoned release only finds new victims while it's on the registry and people are installing it. That window keeps turning out to be short, because a scanner or a maintainer spots the bad versions within hours:

With a 14-day gate, by the time a version is old enough for us to install, it has spent two weeks being installed, scanned and complained about by everyone else. We're betting that two weeks is longer than the gap between a malicious publish and its takedown. So far it has been, by a wide margin.

It isn't a complete defence. It does nothing about a package that is malicious from its first release and stays quiet about it, or about a version that went bad years ago. It also only applies when Bun picks a version: anything already pinned in bun.lock is installed as it is. The gate protects what we add or update, not what we already have.

The change

The bunfig.toml added in PR 30: minimumReleaseAge set to 1209600 seconds, with an empty exclude list

That's the whole change: eight lines, plus a README section so the team knew what to expect.

What I do now

  • Every repo gets a release age. It's one line in Bun, and npm, pnpm and Yarn have similar settings.
  • Urgent patches are a decision, not a default. We haven't needed one yet. If a real security fix has to come in early, we'll turn the gate off for that one command, bun add <package>@<version> --minimum-release-age 0, and let bun.lock pin the result. Every other install stays gated.
  • The exclude list is for things you publish yourself. If your own CI published it an hour ago, the gate isn't protecting you from anything.

Postscript

We weren't the only ones moving this way. A few weeks before our change, pnpm 11 made a one-day release age the default. Recent Yarn versions also turn theirs on by default, under the name npmMinimalAgeGate. npm has min-release-age and Bun has minimumReleaseAge, but both leave it off until you set it.

Portrait of Shamoil Arsiwala

Written by

Shamoil Arsiwala · Full-Stack Engineer

I work from the UI down to the API and the database. Each post covers one problem I hit while shipping something real, and what fixed it.