All posts
securitytooling

The Week chalk Got Compromised, and the Cooldown I Added

In September, malicious versions of chalk, debug, and more than a dozen other packages went out to npm. They were pulled within hours. That window is the whole argument for not installing anything brand new.

Muhamad Choirul Adam 3 min readPhoto: Unsplash

On September 8, a maintainer of some of the most downloaded packages on npm was phished. Malicious versions of chalk, debug, and around sixteen other packages were published. The payload targeted crypto wallets in the browser. The versions were found and removed in about two and a half hours.

A week later, a self-spreading worm went through more packages, stealing tokens and using them to publish more infected versions.

I wasn't hit. But I checked, and the reason I wasn't hit was luck, not process.

Why a few hours matter

Most of these attacks share a timeline. A bad version goes out, someone notices, it gets pulled. The danger is entirely in that window.

Rendering diagram…

If my installs simply refuse versions younger than a few days, the window closes before it reaches me.

The cooldown

pnpm shipped exactly this in 10.16, days after the attack. It's called minimumReleaseAge, measured in minutes:

pnpm-workspace.yaml
minimumReleaseAge: 4320 # 3 days
minimumReleaseAgeExclude:
  - "@my-org/*"

The exclude list is for my own packages, where I want the new version immediately.

Bun, which most of my projects use, doesn't have a setting for it yet. Until it does, those projects get the same effect the manual way: no blind bun update, and every upgrade goes in as its own pull request with the publish date checked.

The rest of the checklist

A cooldown is one layer. The ones I check on every project now:

HabitWhat it stops
Commit the lockfile, install with --frozen-lockfile in CISilent upgrades during a deploy
Don't run dependency install scripts by defaultPayloads that run on install
Update on purpose, not on every installPulling whatever was published an hour ago
Read the diff of the lockfile in PRsNew transitive packages nobody asked for

Bun already skips lifecycle scripts for dependencies unless they're listed in trustedDependencies, which is one reason I'm comfortable on it.

What a cooldown costs

Security fixes arrive three days late too. When a real CVE lands, I update that one package on purpose and let it skip the wait. That's a deliberate decision with someone looking at it, which is the point.

Why it matters

Nobody reviews every dependency, and pretending otherwise doesn't help. What I can control is when new code enters the project. Waiting a few days costs almost nothing, and it turns "were we fast enough to notice?" into "someone else noticed first."