Published · Updated · 7 min read
npm supply chain attacks: the pnpm 11 settings I ship
Worms republished hundreds of npm packages in 2026. These are the pnpm settings in my repos, the reason for each one, and the two entries I got wrong.
On 11 May 2026, a worm pushed malicious versions of 42 @tanstack packages in a six-minute window. On 4 August, the ChainDrop wave republished more than 400 packages with credentials it had harvested from CI.
Both did their work at install time, on the machines of the people installing: TanStack's through a prepare script in a malicious optional dependency, ChainDrop's through preinstall. This post covers what my repos do about it, setting by setting, including two entries I got wrong.
1. What an install-time worm needs
The pattern repeats. A maintainer's token gets stolen. The attacker publishes a new version with an install script. Every machine that installs that version runs the script, and the script looks for more tokens: npm, GitHub, cloud keys. Every package those tokens can publish gets the same treatment.
Each setting below breaks one link of that chain:
| Link in the chain | Setting |
|---|---|
| A dependency's install script runs | allowBuilds, strictDepBuilds |
| A version a few minutes old gets installed | minimumReleaseAge |
| A dependency resolves from a git URL or tarball | blockExoticSubdeps |
| An install quietly resolves something new | --frozen-lockfile |
None of them is complete on its own. The June node-gyp wave got code execution through binding.gyp rather than an install script, and the TanStack versions shipped with valid signed provenance. Layers, not one switch.
2. No dependency builds unless I said so
Since pnpm 11, strictDepBuilds is on by default. If a dependency has a build script that nobody reviewed, the install fails with ERR_PNPM_IGNORED_BUILDS. You review it in allowBuilds, a map of package name to true or false.
This is the one from a healthcare platform I run, in full:
allowBuilds:
# required by drizzle-kit (apps/api): binaries verified via lockfile
esbuild: true
# its only install script is `only-allow yarn`, which refuses every other
# package manager and builds nothing: the published files are used as they are
h5p-standalone: false
# optional native accelerator for bullmq's msgpackr. The JS path carries
# this event volume, so no native build enters the worker image
msgpackr-extract: false
sharp: false
unrs-resolver: falseOne true in a monorepo with a NestJS API, BullMQ workers, and a Next.js app. Three of the five entries carry a comment saying why.
The false entries are decisions too. h5p-standalone ships one install script, only-allow yarn, which would refuse pnpm anyway and builds nothing. msgpackr-extract is an optional native speed-up for BullMQ's serializer, and the worker does not need it at this platform's event volume. Saying no is cheaper than carrying a native build into the worker image.
3. The two entries I got wrong
A CRM backend of mine, from June:
allowBuilds:
"@prisma/engines": true
"@scarf/scarf": true
argon2: true
bcrypt: set this to true or false
msgpackr-extract: true
prisma: true
sharp: true
unrs-resolver: trueTwo problems.
bcrypt: set this to true or false is the placeholder pnpm writes when it meets a build nobody reviewed. It arrived on 26 June, in the commit that added bcryptjs, the pure JavaScript hasher. About an hour later, argon2 replaced bcryptjs. Native bcrypt is not in the lockfile, then or now. The placeholder has sat there for four months: an unanswered question about a package nobody installs.
@scarf/scarf: true is worse. Scarf is install analytics. Its install script reports each install back to Scarf. It arrives through swagger-ui-dist, which @nestjs/swagger pulls in. I approved a telemetry ping, and Swagger UI does not need it to work.
The fix is two lines, and the rule behind it is the one I follow now: an approval without a comment is not an approval.
allowBuilds:
# install analytics only, via @nestjs/swagger > swagger-ui-dist
"@scarf/scarf": false4. Nothing younger than a day
pnpm 11 also turned on minimumReleaseAge by default, at 1440. A version published less than a day ago is not resolved. The bet is that a bad version gets noticed and pulled before it is a day old. A worm that publishes in a six-minute window is exactly the case that bet is built for.
The unit changes between package managers, which is how a security setting ends up silently wrong:
| Tool | Setting | Unit |
|---|---|---|
| pnpm 11 | minimumReleaseAge (default 1440) | minutes |
| npm 11.10+ | min-release-age | days |
| Yarn 4.10+ | npmMinimalAgeGate | minutes |
| Bun | minimumReleaseAge in bunfig.toml | seconds |
Copy 1440 from a pnpm file into an .npmrc and you have asked for versions almost four years old. Copy 1 from an .npmrc into pnpm and you wait one minute.
Exceptions go in minimumReleaseAgeExclude, by exact version, with the reason above them. One of my side projects has this:
# Newly published versions are gated by pnpm's minimumReleaseAge; these were
# reviewed and allowed explicitly.
minimumReleaseAgeExclude:
- tsx@4.23.12pnpm audit --fix also writes the patched version of each advisory into that list for you, so a security fix does not wait out the delay.
5. Security patches are new versions too
The delay has a cost, and it shows up on the day you need a patch.
On 25 October, the healthcare platform's web app was on Next.js 16.2.11. That version had five critical advisories, one of them remote code execution through the image optimizer, which the app has turned on. They are fixed from 16.4.1. I took 16.4.3, and pnpm audit --prod afterwards showed no advisory on next, sharp, or postcss.
The same upgrade retired a local patch. The platform carried patches/next@16.2.11.patch for a React bug, and the React that 16.4.3 bundles has the fix. A patch pins an exact version, and pinned versions are the ones that miss security releases. Delete patches as soon as upstream catches up.
6. Install exactly the lockfile, with a pinned pnpm
The rest is plumbing, and it has to be everywhere or it is not really anywhere. From the platform's API and web Dockerfiles:
RUN corepack enable && corepack prepare pnpm@11.9.0 --activate
RUN pnpm install --frozen-lockfileEvery CI job that installs runs the same pnpm install --frozen-lockfile. package.json pins "packageManager": "pnpm@11.9.0". One client site's pin goes further and includes the sha512 of pnpm itself, so the package manager cannot be swapped either. The production runtime image is Node only: no pnpm, no turbo, nothing that installs.
blockExoticSubdeps, also on by default in pnpm 11, stops a transitive dependency from resolving to a git repository or a tarball URL. A direct dependency can still do it, but then it is in your package.json where a reviewer sees it.
One trap if you run a scanner. pnpm's docs warn that pnpm-lock.yaml can now hold two YAML documents, and a scanner that reads only the first one sees no dependencies and reports no vulnerabilities. A clean report from a tool that read nothing is the worst kind.
7. If you are on npm
A small npm project of mine has this .npmrc:
ignore-scripts=true
audit=trueignore-scripts blocks every lifecycle script, your own pre and post hooks included, so check what breaks before you commit it. npm 11.10 added min-release-age, counted in days. Older npm ignores the key without a warning, so the cooldown fails open. Pair it with "engines": { "npm": ">=11.10.0" } and engine-strict=true to turn an old npm into an error.
This site runs on npm too, and has neither setting. I noticed while writing this.
What I'd do again
strictDepBuildson, and a comment on everyallowBuildsentry,falseones included.- Read the package name before approving a build. Twice if it sounds like analytics.
- Keep the one-day release age. Exclude by exact version, with a reason.
- Check the unit when you copy a cooldown from one tool to another.
--frozen-lockfileand a pinned package manager in CI and in every Dockerfile.- Search
pnpm-workspace.yamlforset this to true or falseonce in a while.
If you want a second pair of eyes on how your project installs its dependencies, get in touch.