Lesson 4 of 9 · 22m
The Dependency Trust Model: You Ship Other People's Code
Analyze maintainers, package managers, lockfiles, transitive depth, typosquats, and the difference between popularity and trust.
Dependency risk feels abstract until you inventory it honestly. A modest web service can contain ten first-party packages and nine hundred transitive dependencies written by people you have never met, built by machines you do not control, and distributed through namespaces you do not own. Your application binary is not your code plus a little risk. It is mostly other people's code.
Draw the trust chain
For every dependency, the real chain looks like this:
upstream source repository
-> maintainer account
-> release commit or tag
-> package build environment
-> package registry publication
-> your package manager resolution
-> lockfile entry
-> artifact included in your releaseCompromise can enter at every arrow. A vulnerable library is only one failure mode. Account takeover, malicious release automation, dependency confusion, typosquatting, registry deletion, and hostile version selection are all supply-chain events.
Lockfiles are security controls
A lockfile freezes the resolution graph. Review it as carefully as application code:
{
"name": "left-pad",
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/left-pad/-/left-pad-1.3.0.tgz",
"integrity": "sha512-6k1x..."
}The integrity field protects against changing package content, but it does not decide whether version 1.3.0 should be trusted in the first place. Pinning prevents drift; it does not establish goodness.
Transitives carry the blast radius
Direct dependencies are visible in your manifest. Transitive dependencies arrive because something you chose needed them. That makes review uncomfortable: your biggest exposure may be five layers down and required only at build time.
npm ls --all --json > npm-tree.json
go mod graph > go-mod-graph.txt
pipdeptree --json-tree > pip-tree.jsonYou do not need to manually audit every package. You do need to know which ones execute at install time, run in production, handle input, or hold credentials.
Popularity is a weak signal
Download counts tell you exposure, not safety. Look for maintained release cadence, signed tags, security policy, multiple maintainers, provenance, issue handling, and whether ownership recently changed. A tiny package maintained carefully can be lower risk than a famous package with abandoned automation and broad publish access.
Install-time code deserves special suspicion
Postinstall scripts, setup hooks, build scripts, and code generation execute before your tests even start:
{
"scripts": {
"postinstall": "node ./install.js"
}
}Use --ignore-scripts where possible in CI and selectively permit packages that truly need scripts. Remember that a dependency can be harmless in production and catastrophic in CI because CI holds signing keys, registry tokens, and cloud credentials.
Field notes
- Dependency review is architecture review. If a package parses untrusted input, its risk is not merely its CVE count.
- Removing a dependency is often cheaper than monitoring it forever.
- Treat sudden maintainer transfers and brand-new publish automation as risk events.
- Build-only dependencies can still steal secrets because builds are credential-rich environments.
- Keep package-manager configuration in source control so registry overrides are reviewable.
Was this lesson helpful?