Notes
The leverage
The leverage is enormous. Your application trusts its dependencies completely: their code runs with your code's privileges. Those dependencies trust theirs, transitively, many levels deep. So compromising one popular package reaches everyone who uses it, directly or indirectly. The same trust that makes open source work, reusing millions of lines you never read, is the attack surface. Supply-chain defence is about not trusting blindly the code you did not write.
- your app trusts its deps completely; they run your code
- deps trust their deps (transitive), levels deep
- compromise one popular package and you reach all its users
- the same trust that makes open source work is the attack surface
Typosquat and confusion
Two attacks trick the installer into fetching the wrong package. Typosquatting publishes a malicious package with a name close to a real one, so a typo or copy-paste installs it. Dependency confusion is cleverer: an attacker publishes a public package with the same name as your internal private one but a higher version, and the package manager, preferring the higher version, pulls the attacker's from the public registry. Both have hit real companies, and both often run a malicious install script.
- typosquatting: a malicious package named like a real one (reqeusts vs requests)
- dependency confusion: a public package shadows your private one with a higher version
- malicious install scripts run on install
- both have hit real companies at scale
Compromised maintainers
The most dangerous variant is when a genuine, trusted package ships a malicious version. A maintainer account gets phished or hijacked, and a poisoned release goes out to everyone who updates. The xz-utils case in twenty twenty four was chilling: an attacker spent months earning maintainer trust on a core compression library, then slipped in a backdoor that nearly reached mainstream Linux before one engineer noticed a tiny performance anomaly. It shows how patient these attacks are, and how close they come.
- a maintainer account is phished or hijacked
- or a maintainer is socially engineered over months
- a malicious version ships to everyone who updates
- xz-utils (2024): a backdoor almost reached mainstream Linux via a trusted maintainer
Build-system compromise
Attackers also target the build system itself. In the SolarWinds attack of twenty twenty, they compromised the build pipeline, not the source, and inserted malicious code during the build. The result shipped as an officially signed update to around eighteen thousand organisations, because every normal check passed: the source looked clean and the signature was valid. This is why build integrity and provenance, the SLSA framework from last episode, matter: they protect the step between source and artifact.
- compromise the build system, not the source
- malicious code inserted during the build
- ships signed and "legitimate" to all SolarWinds (2020): reached ~18,000 organisations
- this is why build integrity (SLSA) matters
The defences
No single control stops supply-chain attacks, so you layer the tools from this part. Pin exact versions with a lockfile, and add a cooldown so brand-new releases are not adopted instantly. Verify signatures and provenance at deploy. Use an internal proxy registry and scope private package names so confusion cannot shadow them. Run dependency and secret scanning in CI. Give build tokens least privilege and isolate builds so a compromise cannot spread. And monitor installs and runtime behaviour.
- pin exact versions; use a lockfile and a cooldown
- verify signatures and provenance (SLSA, ep 6)
- use an internal proxy/registry; block confusion by scoping private names
- SCA + secret scanning in CI
- least privilege for build tokens; isolate builds
- monitor installs and behaviour
The human layer
The xz-utils case teaches that not every defence is technical. Some attacks are patient and social: an attacker slowly becomes a trusted maintainer. So vet critical dependencies for maintainer health, watch for suspicious handoffs to a new, unknown maintainer, and be wary of a critical library with a single exhausted maintainer, a common pattern. Reduce your dependency count, support the maintainers you rely on, and have an incident plan for a poisoned dependency.
- vet critical dependencies: maintainer health, activity, single-maintainer risk
- watch for maintainer handoffs and sudden new contributors
- reduce dependency count; fewer deps, smaller surface
- support the maintainers you rely on have an incident plan for a poisoned dependency
Common mistakes
Mistakes that leave you exposed. Floating version ranges with no lockfile or cooldown, so a malicious release is pulled automatically. Private package names that are not scoped, inviting dependency confusion. No verification of signatures or provenance, so a swapped artifact is accepted. Build tokens with broad permissions, so a build compromise spreads far. Pulling in any package without any vetting of its maintainers or health. And no incident plan for the day a dependency you depend on is found to be backdoored.
- floating versions, no lockfile or cooldown
- private package names not scoped (confusion risk)
- no signature or provenance verification
- build tokens with broad permissions
- trusting any package without vetting
- no plan for a poisoned dep
Say it like this
In the interview: there is no single fix, so I layer. I pin exact versions with lockfiles and a cooldown, verify signatures and provenance at deploy, use an internal proxy registry and scope private names against dependency confusion, and run dependency and secret scanning in CI. I give build tokens least privilege and isolate builds so a pipeline compromise cannot spread. And because attacks like xz-utils are social, I vet critical dependencies and their maintainers.
- "Layer it: pin and lock with a cooldown, verify signatures and provenance, proxy registries
- and scope private names against
- confusion, SCA and secret
- scanning, least-privilege
- isolated builds, and monitoring. Plus vet critical
- deps and their maintainers.
- xz-utils and SolarWinds show why."