BlogAI agents

No npm package younger than 7 days: how to set it up

This year's hijacked packages were live for 42 minutes to under 5 hours. One line of config per package manager would have kept them out.

Ink and watercolor illustration: a wooden crate tied with string waits on the doorstep of a closed door, next to a large hourglass slowly running down.

Make your project refuse any package version published less than seven days ago. It is one line in .npmrc (or its equivalent in pnpm, Yarn or Bun), and it would have kept out this year’s big package hijacks, all of which were pulled in under five hours.

What it is

On 1 November, Bruno Jurković described how his company works: a proxy sits between its developers and the public registries and holds every new npm and PyPI version for seven days before serving it. That wait is called a cooldown, or a minimum release age.

The reasoning comes from the incidents he lists, with how long each malicious version was available:

  • axios 1.14.1 (31 March): about 3 hours. A compromised maintainer account published releases that installed a remote access trojan.
  • lightning 2.6.2 and 2.6.3 on PyPI (30 April): 42 minutes.
  • TanStack (11 May): 84 malicious versions across 42 @tanstack/* packages, published through the project’s own release pipeline. The last one was pulled 4 hours 35 minutes after the first.
  • keyv 6.0.0 (4 August): 1 hour 40 minutes. It started the ChainDrop worm, which republished itself into hundreds of packages within four hours.
  • litellm 1.107.0 on PyPI (21 October): 1 hour 43 minutes.

All five were gone within about five hours. An npm install picks up a new version within seconds; a seven-day wait covers that whole window with room to spare. One detail matters a lot to me: the TanStack versions came from the legitimate pipeline, so signed provenance would not have helped.

In its first twelve days (20 October to 1 November), his company’s proxy served 81,710 downloads, hid 6,116 versions as too new and refused 71 downloads because a lockfile pinned a version still inside the wait.

How to turn it on

You don’t need a proxy to start. Every package manager already has a setting. Watch the units, because each one uses a different one:

Manager File Line Unit Since
npm .npmrc min-release-age=7 days 11.10
pnpm pnpm-workspace.yaml minimumReleaseAge: 10080 minutes 10.16
Yarn .yarnrc.yml npmMinimalAgeGate: "1w" duration 4.10
Bun bunfig.toml, under [install] minimumReleaseAge = 604800 seconds 1.3

With npm, for example, from the repo root:

npm --version   # you need 11.10 or later
echo "min-release-age=7" >> .npmrc
npm install

According to the npm docs, with min-release-age the dependency tree only includes versions that were available more than that many days ago, and if none qualify, the command fails. It complements --before, which does the same with a fixed date.

If you use an update bot, give it the same wait. Otherwise it will open pull requests with versions your own install rejects:

# .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: "npm"
    directory: "/"
    schedule:
      interval: "weekly"
    cooldown:
      default-days: 7

In Renovate it is "minimumReleaseAge": "7 days" in renovate.json.

If a new version fixes a vulnerability that affects you and you can’t wait, pnpm has minimumReleaseAgeExclude to let specific packages through. Use it for that one package and remove it once the week is up.

What breaks

Jurković is candid about what went wrong, and it is worth reading before you turn this on:

  • Old lockfiles. npm and pnpm lockfiles respect the wait. Yarn 1 downloads the exact URL in yarn.lock and skips it until you regenerate the file.
  • npm audit goes straight to npmjs.org and ignores the wait.
  • Prereleases. If the latest stable version is hidden, you may end up with a newer prerelease, especially with a bare npx call.
  • Update bots. If Dependabot waits less than your package manager (his was set to three days), its pull requests fail CI until you match the seven days.

What it does not stop

A week only buys time for someone else to notice. If nobody spots a poisoned version within seven days, it gets in on day eight: the wait checks dates, not contents. The article mentions a hijacked react-native-international-phone-number release from March that was still tagged latest on 1 November, 228 days later. And a third-party count of 1,336 hijacked npm packages estimates that a seven-day cooldown would have blocked about 85% of them.

My take

I would add it today to any repo where an AI agent works. An agent that installs dependencies doesn’t hesitate: ask it to add a library and it runs npm install without checking whether that version came out ten minutes ago. The wait makes that step safe by default, without relying on the agent or the reviewer to notice.

The cost is small and shows up quickly: some updates arrive a week later and the odd lockfile needs regenerating. In exchange, you stay out of the window in which almost every attack this year was installed. For a small team with nobody watching security advisories at three in the morning, I think it is one of the best cost-to-benefit defences there is.

I would start with the package manager line in each repo. Jurković’s shared proxy makes more sense once you have several teams or many CI runners, because it protects all of them at once and adds a blocklist and a download log.

Sources

If you want to see how I work with AI agents without opening security holes, follow me on LinkedIn.

← All articles

Have a product to build or a tech stack to put in order?

Tell me what you are trying to achieve and where you are today. I reply personally, usually within a day.

Free · 30 minutes

Digital strategy session

30 minutes to map where to start digitalizing and transforming your business. You pay nothing, before or after.

When you book, you answer three short questions: what you need, what stage your project is at and when. That way the session starts with context.