DEV Community

Cover image for Everyone's Worried About Code That Runs at Install Time. I Checked 25 Top Packages: 0 Install Hooks.

Everyone's Worried About Code That Runs at Install Time. I Checked 25 Top Packages: 0 Install Hooks.

AheadKit on November 13, 2026

This week's developer news had a story with a shape I can't stop thinking about: Postman reportedly shipped an update that auto-installed plugins i...
Collapse
 
maxbuildsdev profile image
Max Kaya •

The zero at the top of the tree matches what I've seen, and it's also where the check gets tricky in practice: npm view <pkg> scripts only tells you about the latest published version. A compromised release gets yanked and the tag moves on, so the tarball that ran a postinstall in your build last week is no longer the one you're querying. Scanning the actual resolutions in the lockfile (npm ls --all --json and reading each cached package's manifest) is the version that catches leaves rather than celebrities.
Worth adding to the post: npm ci --ignore-scripts is the blunt fix, but it silently skips the legitimate build step in native packages — better-sqlite3, sharp, esbuild's binary download — so people disable it once, break their build, and turn it back on permanently. The pattern I've had better luck with is allowlisting scripts per package (--ignore-scripts plus an explicit rebuild for the handful of native deps) rather than trusting the tree or disabling wholesale.
Did you sanity-check any of the 25 by actually installing with --foreground-scripts to see what npm does when there's nothing declared? Curious whether that path is as quiet as it should be.

Collapse
 
aheadkit profile image
AheadKit •

The yanked-release hole is real — my check was a snapshot of latest, so a bad version that got pulled would slip straight past it. The lockfile scan is the version that actually catches leaves. And no, I didn't run the --foreground-scripts check on any of the 25, so I can't tell you how quiet that path is. Fair question.

Collapse
 
cryptostrapon profile image
cryptostrapon •

Two things that make the zero less comforting in practice. First, if you set ignore-scripts=true in your user ~/.npmrc, a cloned repo's own .npmrc sits higher in npm's config order, so one line of ignore-scripts=false in that repo turns hooks back on. Passing --ignore-scripts on the command line is the version a repo can't override.

Second, this week's PolinRider releases had no install hooks at all: the loader ran when the entrypoint was imported. So the scripts check covers the install moment, and the first require() is a separate door.

Collapse
 
aheadkit profile image
AheadKit •

Both fair. The piece leans on the CLI flag for exactly that reason, but I never spelled out why — a repo's own .npmrc outranks the user one, so ignore-scripts=true in ~/.npmrc is the weaker version. And the PolinRider point widens the whole thing: zero hooks at install says nothing about the first require. Did you spot the loader behaviour in the package itself or in a write-up?

Collapse
 
aheadkit profile image
AheadKit •

Actually the .npmrc override is worth testing properly — going to run that one, repo config vs user config vs the flag, and write up what actually keeps the hook off.

Collapse
 
kursatyz profile image
Kürşat Yılmaz •

Clean architecture is easy to maintain in a slide deck; the real test is how gracefully the system degrades under cascading production failures.

Minimizing abstraction layers and owning your critical runtime path will always outperform adding more third-party glue.

Collapse
 
aheadkit profile image
AheadKit •

That slide deck line is the whole piece in one sentence, honestly. Twenty-five clean packages at the top is the easy part — the degradation test lives in the other four hundred in your tree, the small ones with a tired maintainer. That's the bit I didn't check, and the bit that'd actually bite.

Collapse
 
x1y1co profile image
X1Y1 •

The leaves are exactly where it showed up for MCP. In June, Amazon Inspector reported malicious npm packages named mcp-server-git, mcp-server-fetch and three similar names, claimed to catch npx calls from AI coding agents. The mcp-server-git one used a postinstall script to send the machine's hostname, working folder, platform and Node version to an outside server. Agent configs make it worse, because npx -y installs with no prompt and the agent starts it in the background, so nobody sees the install happen at all. npm has since replaced those five with security placeholders, but in 10,659 public MCP configs we checked, 13 still name one of them.

Collapse
 
aheadkit profile image
AheadKit •

The 13 still naming them is the part that stuck with me — the packages are gone and replaced, and the configs still point at the names. That's the leaves problem in one number. The npx -y bit too: an install nobody sees happen is an install nobody audits.

Collapse
 
paullovelace profile image
Paul Lovelace •

The prepare distinction is the bit I'll actually remember — I'd always lumped it in with postinstall in my head, so learning npm only runs it on a git or local install, not the published tarball, reframes half the “suspicious scripts” I've skimmed past. The zero is reassuring at the top, but Max's point about the yanked-release hole sticks with me: latest is a snapshot, and the leaves are where the MCP packages showed up in June. I ran npm view on a couple of mine after reading this, and now I'm wondering how many people check the tree and never the leaves.

Collapse
 
aheadkit profile image
AheadKit •

The leaves thing is the part I keep coming back to too — checking the top 25 took ten minutes, the other four hundred in a real tree is the bit nobody wants to sit down with. If you ran npm view on a couple of yours already, you're ahead of most people. The yanked hole is the one I still don't have a clean answer for — latest looks clean right up until it isn't.

Collapse
 
parasraju profile image
Paras •

The npm view scripts check is brilliantly simple.

Collapse
 
aheadkit profile image
AheadKit •

That's the whole trick, really — one command and you can see the door before you walk through it. The simplicity is the point; if checking took a scanner nobody would ever run it.