The Threat Model: Source to Consumer
Before choosing tools, draw the chain and ask where an attacker could step in. The SLSA project ("Supply-chain Levels for Software Artifacts", pronounced salsa) publishes a standard picture of it, with the threats labelled A to I. This lesson walks through it with one question at each step: what would we have to trust, and how could we check it instead?
The chain
developer ──(A)──► source repo ──(B,C)──► build platform ──(E,F)──► package / registry ──(G,H)──► consumer
▲
│ (D) dependencies: other packages, base images, tools| Step | Threat (SLSA label) | Example | Control |
|---|---|---|---|
| Producer | A submit an unauthorized change | a stolen developer account pushes a backdoor | MFA, required code review, branch protection |
| Source | B compromise the source repository | an attacker with admin rights rewrites history | signed commits, protected tags, audit logs |
| Source → build | C build from modified source | CI builds a commit or tarball that isn't in the repo | provenance that names the exact commit |
| Dependencies | D use a compromised dependency | a typosquatted package, a poisoned base image | SBOMs, scanning, pinning, verifying dependencies' own provenance |
| Build | E compromise the build process | malware on the build machine edits the output (SolarWinds) | hosted, isolated, ephemeral builders; reproducible builds |
| Build → package | F upload a modified package | a stolen registry token publishes a tampered version | publish only from CI; signatures and provenance |
| Package registry | G compromise the registry | a mirror serves different bytes | content digests, signature verification |
| Consumer | H use a compromised package | a user installs a look-alike name | verification at install / deploy time, admission policies |
| Availability | I (in some versions) a dependency becomes unavailable | a package is deleted | mirrors, vendoring, artifact repositories |
The labels are SLSA's; the important part is the shape. Threats A–C are about source integrity, E–F about build integrity, D is everyone else's supply chain feeding into yours, and G–H are about getting the right bytes to the consumer.
Four classic attacks
| Attack | How it works | Where it lands |
|---|---|---|
| Typosquatting | publish reqeusts next to requests and wait for typos, AI-hallucinated names or copy-paste mistakes |
D, H |
| Dependency confusion | publish a public package with the same name as a company's internal one, at a higher version; a misconfigured resolver prefers it | D |
| Compromised maintainer | steal or socially engineer a maintainer's account, or become a trusted maintainer over years, then release a malicious version | A, B, F |
| Compromised build system | get code execution on CI or the release machine and alter artifacts after the source was checked | E, F |
Each has a lesson or more: Typosquatting & Malicious Packages, Dependency Confusion, the incidents for maintainers and build systems, and SLSA for build integrity.
A model: which controls catch which attack
Security controls overlap, and none covers everything. This small model lists what each control checks and runs four attacks through it. It is deliberately simple, but it shows the one conclusion that matters: you need layers.
CONTROLS = {
"code review": {"A"},
"sbom + scan": {"D"}, # known-vulnerable components only
"pin by hash/digest": {"D", "G"}, # stops silent replacement, not a bad first choice
"signature verify": {"F", "G", "H"},
"slsa provenance": {"C", "E", "F"},
"reproducible build": {"E"},
}
ATTACKS = {
"typosquatted package": {"D", "H"},
"malicious new maintainer": {"A", "F"},
"tampered CI runner": {"E"},
"re-tagged registry image": {"G"},
}
for attack, points in ATTACKS.items():
caught = sorted(c for c, covers in CONTROLS.items() if covers & points)
print(f"{attack:26} hits {','.join(sorted(points)):4} caught by: {', '.join(caught) or 'nothing'}")typosquatted package hits D,H caught by: pin by hash/digest, sbom + scan, signature verify
malicious new maintainer hits A,F caught by: code review, signature verify, slsa provenance
tampered CI runner hits E caught by: reproducible build, slsa provenance
re-tagged registry image hits G caught by: pin by hash/digest, signature verify
Look at the first line: hash pinning "catches" typosquatting only after you picked the right package. A pin faithfully locks in a bad choice too. The second line is the hardest case: a maintainer who is allowed to release can produce a validly signed, correctly provenanced, malicious release. Signatures prove who, not good intent; that's what the xz-utils incident showed.
Trust boundaries in your own pipeline
When you threat-model a real pipeline, list for each step:
- Inputs: source commit, dependencies (with versions and hashes), base image (by digest), build tools.
- Who can change it: humans with merge rights, bots with tokens, the CI system itself.
- What leaves: artifacts, and the metadata you should publish with them (SBOM, provenance, signature).
- What the next step verifies: if the answer is "nothing", that's your gap.
The Threat Modeling lesson in the Cybersecurity course teaches STRIDE; the supply-chain view is the same method applied to the path from commit to production.
Go further: Supply-Chain Attacks places these attack classes in the track's attack map.
Test yourself
Malware on a CI runner modifies the binary after the compiler produces it. Which SLSA threat is this?
- A: unauthorized change
- D: compromised dependency
- E: compromised build process
- H: consumer uses a compromised package
Why doesn't pinning a dependency by hash protect you from typosquatting?
- Hashes can collide
- The pin records whatever you chose, including the wrong package
- Registries ignore hashes
- Typosquatted packages have no hash
A long-time maintainer publishes a backdoored release from the official CI. Which control would show the release as legitimate?
- Signature verification and provenance, both of which pass
- Typosquatting checks, which fail
- Digest pinning, which fails
- None, every check fails