Lesson 10 of 14 · 22m
Every Dependency Is Code You Own
npm install merges unreviewed code into your process — left-pad, event-stream, and Log4Shell are what that means in practice.
npm install foo does three things the abstraction hides: it downloads code you didn't write, it executes that package's postinstall script on your machine with your permissions, and it links the package into your process where it can read everything your process can read. A dependency isn't a black box you rent. It's a merge you didn't review, of a repository you don't control, maintained by people you've never met.
The wrong mental model is "dependencies are free abstraction" — with its cousin "popular means safe." Popularity is blast radius. The incidents below worked because the packages were everywhere.
The receipts
- left-pad (March 2016) — an 11-line package was unpublished after a naming dispute, and
babel,webpack, and thousands of builds broke within hours. The industry learned it had a hard dependency on eleven lines ofpadStart. npm changed its unpublish rules because of this. - event-stream (November 2018) — the maintainer handed the repository to a stranger. The stranger added
flatmap-stream, which contained code targeting the Copay Bitcoin wallet's private keys. It sat in the dependency tree of millions of weekly downloads for months before anyone read it. - ua-parser-js (October 2021) — the maintainer's npm account was hijacked; versions 0.7.29, 0.8.0, and 1.0.0 shipped a coin miner and credential stealer on the morning of October 22 — fixed releases were out about four hours later and the registry pulled the malicious versions the same day.
- node-ipc and colors.js (2022) — sabotage from inside:
node-ipcshippedpeacenotwarcode that wiped files on certain geolocated machines; Marak pushed an infinite loop intocolorsand broke thousands of builds in a day. "Trusted maintainer" is itself an attack surface. - Log4Shell (December 2021, CVE-2021-44228) — the risk cuts both ways: your dependencies carry vulnerabilities.
log4j's JNDI lookup reached into essentially every Java service on earth through the dependency tree. - fractureiser (June 2023) — malware shipped through compromised mod uploads in the Minecraft ecosystem. Any ecosystem where installing a package means running its code is a malware delivery system wearing a package manager.
What actually reduces the risk
- Commit the lockfile —
package-lock.json,yarn.lock,Cargo.lock,poetry.lock. In CI, install from it:npm ci, notnpm install. The lockfile is the difference between "the versions you tested" and "whatever the registry serves today." - Gate install scripts. pnpm refuses to run dependency build scripts unless the package is allowlisted;
--ignore-scriptsexists in npm for the same reason — and note thatnpm cistill executes them: the lockfile pins what installs, not what runs. Most of the incidents above arrived through install-time code — but event-stream's payload shipped inside the library itself, so script-gating is one control, not the control. - Vet before you add. Transitive count (an
npm install --dry-runshows how big the tree really is), maintenance recency, whether it ships an install script, and — honestly — whether the function is eleven lines you can inline. Nobody needed to depend on left-pad. - Scan in CI.
npm audit,pip-audit,cargo audit, Dependabot, Socket — automated eyes on the tree you'll never read line-by-line. - Treat version bumps as changes. The event-stream payload arrived as a routine dependency update. Review the diff on a bump the way you'd review the same lines written in-house.
The honest tradeoff
Writing it yourself costs maintenance forever; vendoring means you own the upgrade path. Sometimes the dependency is correct — you should not hand-roll a TLS stack or a date library with real edge cases. The rule isn't "never depend." It's "a dependency is code you maintain": count the cost like it's yours, because it is.
Try it yourself — what's actually in the tree, in JS
const pkg = { deps: ["left-pad", "express", "lib-with-postinstall"] };
const flagged = pkg.deps.filter((d) => d.includes("postinstall") || d === "left-pad");
console.log("needs a second look:", flagged);
// For every dep: who wrote it, does it run scripts, can I inline it?The cheapest dependency is the one you never took.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
systemd Added Rust by Refusing Almost Everything Rust Offers
The headline was "systemd adopts Rust." The commit, which I read in the tree, rejects most of how Rust is normally used: no standard library, no cargo, no crates, no rewrites, no Rust in shared libraries. The reasoning is a quiet argument about where systemd's real attack surface is.
Next.js Shipped Seven Advisories and Six of Them Are the Cache
The November 2026 Next.js security release patches seven issues, and six live in the new Cache Components layer, the feature meant to make your app faster by remembering more. Three hit self-hosted next start specifically: the ones Vercel's own platform quietly absorbs.
The Same Researcher Broke apt the Same Way Twice, Seven Years Apart
In 2019 Max Justicz showed apt would install a package an attacker swapped in over a redirect. In November 2026 he did it again, CVE-2026-109518, through a different door that ends in the same place: code as root from a man in the middle. The fix shows how apt reuses files on disk.
Java Pulled Primitive Patterns After Five Previews. JDK 28 Won't Compile Them.
Primitive types in patterns, instanceof, and switch previewed in every JDK from 23 to 27. On November 9 the Amber team withdrew the feature, and it won't be in JDK 28 even with --enable-preview. Here's why Valhalla changed the plan, what replaces it, and how to rewrite code that used it.