Lesson 6 of 12 · 22m
Dependency Auditing: Most of Your Code Isn't Yours
Lockfiles, scanners, SBOMs, and the attack classes CVE feeds never see — confusion, hijacks, and install-script backdoors like xz's CVE-2024-3094.
Open your node_modules. A "small" Express app pulls in a few hundred packages and several hundred thousand lines of strangers' code — every one a liability you imported, and on npm several of them ran install scripts on your machine with your permissions. Dependency auditing exists because you cannot read your supply chain; you can only inventory it and watch it.
The lockfile is the contract
npm ci # installs exactly what package-lock.json pins — CI, always
npm install # may resolve NEWER versions inside semver ranges — dev machinesnpm install in CI quietly re-resolves the tree, meaning the artifact you shipped isn't the tree you scanned. npm ci fails when the lockfile and manifest disagree — that failure is the feature. Same rule everywhere: pip install -r requirements.txt --require-hashes, cargo build --locked, go build -mod=readonly (the default since Go 1.16), yarn install --immutable.
Scan the lockfile, not the intent
osv-scanner scan source . # OSV database, multi-ecosystem, reads lockfiles
npm audit --audit-level=high # the quick npm-native check
pip-audit # Python
cargo audit # Rust — the RustSec advisory DB
govulncheck ./... # Go: does real call-graph reachabilityTwo things juniors miss:
- Findings are mostly transitive. The vulnerable package usually sits three levels deep —
npm ls <pkg>shows which parent pulled it in, and the fix is often bumping the parent, not the leaf. - Severity isn't reachability.
govulncheckis what good looks like: it traces whether your code calls the vulnerable function and only reports the paths that execute. A critical CVE in a test helper that never ships is noise; a medium in your request-parsing path is not.
The attack classes no CVE feed covers
- Dependency confusion. Your internal
@acme/utilsdoesn't exist on the public registry, so an attacker publishes it there with version99.0.0and your resolver prefers it. Alex Birsan ran this against Apple, Microsoft, PayPal, and two dozen others in February 2021 — onenpm publish, ~$130k in bounties. Fix: publish a placeholder to the public name, force a private registry for scoped packages in.npmrc, and never let--extra-index-urlresolve internals publicly (pip prefers the highest version across indexes). - Maintainer compromise and sabotage.
event-streamabsorbedflatmap-streamin 2018 to steal Copay bitcoin wallets;coa,rc, andua-parser-jswere hijacked in late 2021 to drop miners and stealers;colorsandfakerwere deliberately broken by their own author in January 2022. No scanner flagged any of it — the packages did exactly what compromised packages do. - Build-script backdoors. xz 5.6.0/5.6.1 (CVE-2024-3094, March 2024) hid an OpenSSH backdoor in
m4build scripts and binary "test" blobs that no source review would catch. A scanner sees "xz, version 5.6.1"; only the advisory connects it to your image. - Typosquatting.
reqestsforrequests. Caught by lockfile discipline and review, not feeds. - Install scripts.
preinstall/postinstallrun arbitrary code at install time.npm ci --ignore-scriptskills the class for packages that don't need it — most don't.
SBOMs: the inventory that pays later
syft . -o cyclonedx-json=sbom.json # or: npx @cyclonedx/cyclonedx-npmThe day the next log4shell drops — Log4j 2's JNDI lookup, CVE-2021-44228, disclosed December 9, 2021 — the question is "do we ship it, anywhere?" An SBOM per release answers in minutes. Without one you're grepping lockfiles across forty repos at 2am; I've done that weekend and don't recommend it. Store SBOMs next to the artifacts, not in a wiki.
Field notes
- Pair scanning with automated update PRs (Renovate, Dependabot) grouped by ecosystem. A scanner producing findings nobody can land is a guilt generator.
npm audit fix --forcehappily bumps major versions and breaks your app. Read the diff it proposes.- Vendored dependencies (a checked-in
third_party/) are invisible to lockfile scanners — scan the files, not just the manifests. npm audit signaturesverifies the registry's Sigstore signatures on installed packages — cheap proof the bits match what was published.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
Buying Time: Package Managers Are Adding Delay as a Security Control
Composer 2.11 shipped a cooldown that refuses to install a version until it has aged. vlt now holds npm publishes until their dependencies actually exist, because 22% of new npm versions land broken. And Ruby Central's reviewers threw out 90% of what an AI scanner flagged.
Your npm Install Just Ran Someone Else's Code: Why Dependency Security Has to Start Before CI
A pull request checkout, a poisoned GitHub Actions cache, and an OIDC token pulled straight out of runner memory. That's how 84 malicious versions of TanStack's packages hit npm in six minutes.
CVE-2025-62718: Critical Axios SSRF Vulnerability Explained
A critical SSRF flaw in Axios was used in a North Korean supply chain attack. Here's what it does and how to patch it today.
What is Supply Chain Security? Dependencies, SBOMs, and the Attack That Hit 2.6 Billion npm Downloads
Your application is only as secure as every package it depends on. In September 2025, attackers compromised 27 npm packages with 2.6 billion weekly downloads by phishing one maintainer.