These are the notes for Cybersecurity Fundamentals (defensive), episode 62. Most of the code inside any app was written by someone else. This episode follows that code from where it comes from to what you ship: how dependencies multiply, how attackers poison them, two real attacks that changed the industry, and the defences that let you prove what you ship. Every term is defined the first time it appears; the Glossary collects them.
Scope. Defensive and educational only. Every program is a toy: made-up package names on made-up indexes, nothing is downloaded or installed, and the "extra code" in Demo 3 is just a comment string. Samples were run on 13 Nov 2026 in the SyntaxPilot compiler (Python 3.13).
Step 1: the software supply chain
Real-life example: a chai stall buys milk, tea leaves, sugar and cups from suppliers; the milkman gets milk from a dairy farm the stall owner has never seen. If the farm's milk goes bad, every cup at every stall is spoiled.
- Dependency: a library (code someone else wrote) that your software uses and you install, e.g. with
pip installornpm install. - Direct dependency: one you chose and listed yourself.
- Transitive dependency: a dependency of your dependencies; installed automatically, often without you noticing.
- Dependency tree: the picture of all dependencies and what pulled each one in.
- Package: a bundled, versioned piece of software ready to install.
- Package index / registry: a server packages are downloaded from, e.g. PyPI (Python), npm (JavaScript). Companies also run a private index for internal packages.
- Software supply chain: everything and everyone that turns source code into the software you run: your code, dependencies, maintainers, build tools, build servers, package indexes and update channels.
- Supply chain attack: poisoning one link of that chain to reach everyone downstream.
Demo 1: two installs, seven shipped
# You install 2 packages. What do you REALLY ship? (toy dependency tree)
DEPS = {"myshop": ["web-kit 3.2", "pay-sdk 1.4"],
"web-kit 3.2": ["templater 2.0", "http-core 5.1"],
"pay-sdk 1.4": ["http-core 5.1", "json-fast 0.9"],
"templater 2.0": ["text-utils 1.1"],
"http-core 5.1": ["tls-lite 0.8"],
"json-fast 0.9": [], "text-utils 1.1": [], "tls-lite 0.8": []}
ADVISORY = {"tls-lite 0.8": "HIGH: accepts expired certificates"}
def walk(pkg, depth=0, seen=set()):
note = " <- " + ADVISORY[pkg] if pkg in ADVISORY else ""
print(" " * depth + pkg + note)
for d in DEPS[pkg]:
seen.add(d); walk(d, depth + 1, seen)
return seen
everything = sorted(walk("myshop"))
print("direct:", len(DEPS["myshop"]), " total shipped:", len(everything))
print("SBOM:", ", ".join(everything[:4]))
print(" ", ", ".join(everything[4:]))
Real output:
myshop
web-kit 3.2
templater 2.0
text-utils 1.1
http-core 5.1
tls-lite 0.8 <- HIGH: accepts expired certificates
pay-sdk 1.4
http-core 5.1
tls-lite 0.8 <- HIGH: accepts expired certificates
json-fast 0.9
direct: 2 total shipped: 7
SBOM: http-core 5.1, json-fast 0.9, pay-sdk 1.4, templater 2.0
text-utils 1.1, tls-lite 0.8, web-kit 3.2
Two direct dependencies become seven shipped components, and the vulnerable tls-lite 0.8 sits three levels deep, pulled in twice. (In real projects, a handful of direct dependencies often becomes hundreds.)
SBOM and VEX
- SBOM (software bill of materials): a complete, machine-readable parts list of a piece of software: every component, its version and supplier. Like the ingredients label on a food packet. With an SBOM, "are we affected by this new advisory?" takes seconds.
- Advisory: a published notice that a version of a component has a vulnerability.
- Two standard SBOM formats:
| Format | From | Notes |
|---|---|---|
| SPDX | Linux Foundation | began as a way to track open-source licences; an ISO standard, ISO/IEC 5962:2021; JSON, XML, YAML or tag-value |
| CycloneDX | OWASP | designed for application security and component analysis; JSON or XML; native VEX support |
- VEX (Vulnerability Exploitability eXchange): a statement from a product's maker saying whether a known vulnerability actually affects that product, e.g.
not_affected: vulnerable_code_not_in_execute_path(the vulnerable function is never called). It cuts scanner noise. Typical statuses: not affected, affected, fixed, under investigation.
What the OWASP Top 10 calls it
- A06:2021 Vulnerable and Outdated Components: using components with known vulnerabilities or that are no longer maintained.
- A03:2025 Software Supply Chain Failures: OWASP describes it as "an expansion of A06:2021", covering compromises across dependencies, build systems and distribution infrastructure.
- A08:2025 Software or Data Integrity Failures: trusting code or data without verifying it (unsigned updates, unchecked plugins, untrusted build artifacts). See Step 6.
Step 2: how the chain gets poisoned
Dependency confusion
- Version number: e.g.
1.4.0= major.minor.patch; installers usually prefer the highest allowed version. - Dependency confusion: an attacker publishes a package on a public index with the same name as a company's internal package and a higher version; an installer that searches both picks the attacker's.
# Dependency confusion: the installer picks the HIGHEST version it sees.
PRIVATE = {"acme-billing": [(1, 4, 0)]} # our company's index
PUBLIC = {"acme-billing": [(99, 0, 0)], # someone else's upload
"pretty-print": [(3, 1, 0)]}
def install_v1(name): # looks everywhere, takes max
found = [(v, "PUBLIC") for v in PUBLIC.get(name, [])]
found += [(v, "private") for v in PRIVATE.get(name, [])]
v, where = max(found)
return f"{name} {'.'.join(map(str, v))} from {where} index"
def install_v2(name): # internal names: private ONLY
if name in PRIVATE:
v = max(PRIVATE[name])
return f"{name} {'.'.join(map(str, v))} from private index"
v = max(PUBLIC[name])
return f"{name} {'.'.join(map(str, v))} from PUBLIC index"
for name in ("acme-billing", "pretty-print"):
print("v1:", install_v1(name))
for name in ("acme-billing", "pretty-print"):
print("v2:", install_v2(name))
Real output:
v1: acme-billing 99.0.0 from PUBLIC index
v1: pretty-print 3.1.0 from PUBLIC index
v2: acme-billing 1.4.0 from private index
v2: pretty-print 3.1.0 from PUBLIC index
Version 1 takes the stranger's 99.0.0. Version 2 fetches internal names only from the private index; public packages still work.
Real case: in February 2021, security researcher Alex Birsan used this technique (through bug bounty programmes) to run code inside more than 35 companies, including Microsoft, Apple, PayPal, Shopify, Netflix, Tesla and Uber, and was awarded over $130,000 in bug bounties. He found internal package names in public places such as GitHub and JavaScript files.
Fixes: reserve your internal names on public indexes; use scopes / namespaces (e.g. @acme/billing on npm); configure the installer so each name comes from exactly one index; use lockfiles with hashes (Step 4).
Typosquatting, malicious packages, compromised maintainers and builds
- Typosquatting: publishing a package whose name is one typo away from a popular one (
reqeustsforrequests), waiting for mistakes. - Malicious package: a package written to cause harm, often stealing secrets such as tokens and keys.
- Install script: code some package managers run automatically during installation, before you ever use the package.
- Maintainer: a person who looks after an open-source project and can publish its releases.
- Compromised maintainer: the real maintainer's account is stolen, or a trusted insider turns bad; the package name and history look perfect.
- Compromised build: the source code is clean, but the build system adds something to the output.
Step 3: two real attacks
SolarWinds (2020)
- SolarWinds Orion: IT monitoring software used by many companies and government agencies.
- Attackers placed a backdoor (hidden code that gives secret remote access) called SUNBURST inside
SolarWinds.Orion.Core.BusinessLayer.dll, delivered through legitimate Orion software updates (versions 2019.4 HF 5 and 2020.2). - Mandiant (then FireEye) reported that the trojanised DLL "is signed by SolarWinds", and that trojanised updates were "digitally signed from March - May 2020 and posted to the SolarWinds updates website".
- SolarWinds said up to 18,000 customers may have installed the tainted versions.
- Lesson: customers did everything "right" (installed signed, official updates). A signature proves who signed and that nothing changed afterwards; it does not prove the build was clean. You also need protected build systems, provenance and verification.
- DLL (dynamic-link library): a Windows file of code that programs load at run time. Trojanised: altered to hide malicious code inside something legitimate.
xz-utils (2024)
- xz / XZ Utils: a compression tool and library (
liblzma) used widely on Linux. - A backdoor was found in versions 5.6.0 and 5.6.1, tracked as CVE-2024-3094. It interfered with SSH (secure remote login) authentication via
sshd. - It was added by a committer who had worked on the tool for several years, earning trust first.
- The full malicious code was only in the release download package (tarball), not fully in the Git repository people read.
- Found on Friday 29 March 2024 by developer Andres Freund, who noticed unusual behaviour on his Debian test system and investigated.
- Lessons: check that releases match their source (reproducible builds, Step 6); support the few volunteers maintaining critical tools; watch for unexplained behaviour.
- Tarball: a
.tar.gzarchive, a common way to distribute source releases.
Step 4: lockfiles, pinning and hashes
- Version range:
>=3.0means "any version from 3.0 up", so a new, unreviewed version can arrive on the next build. - Pinning: fixing an exact version (
2.0.1). - Hash: a fixed-length fingerprint of bytes (episode 13); change one byte and the hash changes.
- Lockfile: a file that records the exact version and hash of every dependency, direct and transitive, e.g.
package-lock.json(npm),poetry.lock,go.sum(Go); pip supports--require-hashes. - Hash pinning: refusing to install anything whose bytes don't match the recorded hash.
Demo 3: a lockfile refuses changed bytes and typos
# A lockfile pins EXACT versions + hashes. Changed bytes are refused.
import hashlib, difflib
def sha(data): return hashlib.sha256(data).hexdigest()[:16]
release = b"def total(cart): return sum(cart)" # what we reviewed
LOCK = {"cart-utils": ("2.0.1", sha(release))} # written once
def install(name, version, data):
if name not in LOCK: # typo check
close = difflib.get_close_matches(name, LOCK, n=1)
return f"REFUSED {name}: not in lockfile" + (
f" (did you mean {close[0]}?)" if close else "")
want_v, want_h = LOCK[name]
if version != want_v or sha(data) != want_h:
return f"REFUSED {name}: hash {sha(data)} != {want_h}"
return f"installed {name} {version}, hash ok"
evil = release + b"\n# extra code slipped in upstream"
print(install("cart-utils", "2.0.1", release))
print(install("cart-utils", "2.0.1", evil))
print(install("cart-utlis", "2.0.1", release))
Real output:
installed cart-utils 2.0.1, hash ok
REFUSED cart-utils: hash 83b70718bbb71d09 != d9ee36c27bb5567d
REFUSED cart-utlis: not in lockfile (did you mean cart-utils?)
The reviewed package installs; the same name and version with one extra line is refused (hash mismatch); the typo cart-utlis is refused with a suggestion. Commit the lockfile and update it on purpose, with review.
Step 5: provenance, SLSA and signing
Real-life example: a food packet says where it was made, which batch and when; a kitchen can display a hygiene rating.
- Provenance: in SLSA's words, a record that "describes what entity built the artifact, what process they used, and what the inputs were".
- Artifact: something a build produces: a package, a binary, a container image.
- SLSA (Supply-chain Levels for Software Artifacts), Build track (v1.0):
| Level | Name | Meaning |
|---|---|---|
| Build L0 | No guarantees | no SLSA |
| Build L1 | Provenance exists | the package has provenance showing how it was built (easy to forge, but prevents mistakes) |
| Build L2 | Hosted build platform | built on a hosted platform; forging provenance requires an explicit attack |
| Build L3 | Hardened builds | forging provenance requires exploiting a vulnerability in a hardened platform |
Artifact signing with Sigstore and cosign
- Artifact signing: attaching a digital signature (episode 16) to an artifact so anyone can check who produced it and that it wasn't changed afterwards.
- Sigstore: an open-source project for signing and verifying software artifacts. "Signatures are generated with ephemeral signing keys so there's no need to manage keys."
- cosign: the client tool that signs and verifies.
- Fulcio: Sigstore's certificate authority; it checks an OpenID Connect identity token (episode 33) and issues a short-lived certificate bound to that identity and a public key.
- Rekor: an append-only transparency log that records each signing event, so signing can't happen secretly.
- Ephemeral key: a key used once and thrown away.
- Keyless signing: signing where identity replaces long-term key management.
- Verify: the signer identity is the expected one, the entry is in the log, and the bytes are unchanged.
- A signature proves who and unchanged, not safe (SolarWinds' updates were signed).
Step 6: reproducible builds, integrity and Scorecard
- Reproducible build: a build where anyone building the same source with the same tools gets byte-for-byte identical output, so independent rebuilds can confirm a release matches its source.
- Build timestamp: the time recorded inside an archive or binary; one common reason two builds differ.
Demo 4: same source, different bytes, then identical bytes
# Reproducible builds: same source -> byte-for-byte the same package?
import io, tarfile, hashlib, time
SOURCE = {"app.py": b"print('hello, chai')\n", "README": b"v1.0\n"}
def build(fixed_time=None):
buf = io.BytesIO()
with tarfile.open(fileobj=buf, mode="w") as tar:
for name in sorted(SOURCE): # fixed file order
info = tarfile.TarInfo(name)
info.size = len(SOURCE[name])
info.mtime = fixed_time if fixed_time else time.time()
tar.addfile(info, io.BytesIO(SOURCE[name]))
return hashlib.sha256(buf.getvalue()).hexdigest()[:16]
a = build(); time.sleep(1.1); b = build()
print("build 1:", a); print("build 2:", b, "same?", a == b)
EPOCH = 1700000000 # one agreed timestamp
c = build(EPOCH); d = build(EPOCH)
print("fixed time 1:", c); print("fixed time 2:", d, "same?", c == d)
Real output (the first two hashes change every run because they depend on the clock):
build 1: 6f6e768bcee5e975
build 2: 18b3f7fdf2db3292 same? False
fixed time 1: 206fb11faf7ee892
fixed time 2: 206fb11faf7ee892 same? True
Removing the timestamp (one agreed value) and fixing the file order makes the two builds identical. Real projects also normalise folder paths, file permissions, user names and random IDs.
- Software or data integrity failures (A08): trusting code or data without checking it.
- OpenSSF Scorecard (Open Source Security Foundation): an automated tool that checks an open-source project's security practices; each check and the overall result are scored 0 to 10. Use it when choosing dependencies.
- The cheapest defence: fewer dependencies. Every dependency is a trust decision.
The whole chain
- You ship code you never chose → an SBOM, with VEX to cut noise.
- The installer takes a stranger's 99.0.0 → internal names from the private index only (dependency confusion).
- Typos and swapped bytes → lockfiles with hashes.
- Who built it, and how? → provenance, SLSA levels.
- Was it changed? → Sigstore / cosign signatures.
- Does the release match the source? → reproducible builds; judge projects with OpenSSF Scorecard.
Common mistakes (and the fix)
| Mistake | What you see | Why | Fix |
|---|---|---|---|
"web-kit": ">=3.0", no lockfile |
a new, unreviewed version on the next build | floating versions | commit a lockfile with hashes |
| internal name not reserved publicly | acme-billing 99.0.0 from PUBLIC index |
dependency confusion | scopes, private-only rule, reserve names |
| "it's signed, so it's safe" | SolarWinds' signed updates carried SUNBURST | signature = who + unchanged | provenance, protected builds, monitoring |
| scan only direct dependencies | a deep vulnerable component goes unseen | ignores transitive ones | full SBOM + SCA on every build |
pip install reqeusts |
a typosquatted package runs its install script | typo | copy names from the docs; lockfile; allowlist |
| trusting the release tarball blindly | xz-style hidden code | release ≠ source | reproducible builds, compare with source |
| SBOM produced but never read | still "are we affected?" panic | no process | store SBOMs, match them against advisories automatically |
Mini project: an SBOM checker
Write sbom_check.py that (1) reads a tiny CycloneDX-style JSON ({"components": [{"name": ..., "version": ...}]}), (2) reads an advisories.json list (name, bad_versions, severity), (3) reads a vex.json with not_affected entries and reasons, and (4) prints affected components, skipping those VEX marks not affected (showing the reason). Add a test where a VEX entry hides one advisory and another advisory still fails the build.
Practice
1. In Demo 1, how many components would you ship if templater also needed tls-lite 0.8?
Solution
Still 7. seen is a set, so tls-lite 0.8 is counted once, although the tree prints it three times.
2. Make the toy installer in Demo 2 refuse to install any name that exists in both indexes unless the company has approved it.
Solution
APPROVED_PUBLIC = set()
def install_v3(name):
if name in PRIVATE and name in PUBLIC and name not in APPROVED_PUBLIC:
return f"REFUSED {name}: same name on both indexes, check it"
return install_v2(name)
3. Why does a hash in the lockfile stop the attack in Demo 3 even when the version number is correct?
Solution
The version is just a label anyone can reuse; the hash is computed from the bytes. One extra line changes the bytes, so sha(data) != want_h and the install is refused.
4. Which SLSA Build level does a package reach if it has provenance generated on a developer's laptop?
Solution
Build L1 at most: provenance exists, but it isn't produced by a hosted build platform, so it is easy to forge.
5. In Demo 4, break reproducibility a second way without using the clock.
Solution
Remove sorted(...) and iterate files in a different order (e.g. reversed(list(SOURCE)) on the second build). The archive bytes change, so the hashes differ. That's why real reproducible builds fix file order.
6. A scanner flags a CVE in a library function your app never calls. What document can the vendor publish?
Solution
A VEX statement with status not affected and justification "vulnerable code not in execute path".
Quick quiz
A: typosquatting
B: dependency confusion
C: a reproducible build
D: a compromised maintainer
Your build installed acme-billing 99.0.0 from the public index; your real one is 1.4.0 on your private index. What happened?
Answer
B. A public package with the same name and a higher version won because the installer searched both indexes. Fix: internal names from the private index only, scopes, reserved names.
Interview questions
- What is a software supply chain attack? Compromising a component, tool or channel that many others trust (a dependency, a build system, an update server) to reach all of its users.
- What is a transitive dependency and why does it matter? A dependency of a dependency; most of your shipped code is transitive and often unreviewed.
- What is an SBOM? Name two formats. A machine-readable inventory of components; SPDX and CycloneDX.
- What is VEX? A statement of whether a known vulnerability actually affects a product, used to filter SBOM-based findings.
- Explain dependency confusion and its fixes. A same-named public package with a higher version beats an internal one; fix with scopes, single-index resolution, reserved names and hash-pinned lockfiles.
- What did SolarWinds and xz-utils teach us? Signed official updates can be malicious if the build is compromised; trusted maintainers can be patient attackers; releases must match their source.
- What is SLSA? A framework of levels for build integrity; Build L1 provenance, L2 hosted builds, L3 hardened builds.
- How does Sigstore avoid key management? Short-lived certificates bound to an OIDC identity (Fulcio), ephemeral keys, and a public transparency log (Rekor).
- What is a reproducible build? Building the same source gives identical bytes, so anyone can verify a release.
- What changed between OWASP A06:2021 and A03:2025? Vulnerable and outdated components grew into software supply chain failures, also covering build systems and distribution.
Glossary
| Term | Meaning |
|---|---|
| dependency | a library your software uses that someone else wrote |
| direct dependency | one you chose and listed |
| transitive dependency | a dependency of a dependency |
| dependency tree | all dependencies and what pulled each in |
| package | a bundled, versioned piece of software ready to install |
| package index / registry | a server packages are downloaded from (PyPI, npm) |
| private index | a company's own package server |
| software supply chain | everything that turns source into the software you run |
| supply chain attack | poisoning one link to reach everyone downstream |
| advisory | a notice that a component version is vulnerable |
| SBOM | software bill of materials: a full parts list |
| SPDX | SBOM format from the Linux Foundation, ISO/IEC 5962:2021 |
| CycloneDX | SBOM format from OWASP, security-focused, supports VEX |
| VEX | Vulnerability Exploitability eXchange: is this CVE really exploitable here? |
| A06:2021 | OWASP: vulnerable and outdated components |
| A03:2025 | OWASP: software supply chain failures (an expansion of A06:2021) |
| A08:2025 | OWASP: software or data integrity failures |
| version number | major.minor.patch label of a release |
| dependency confusion | a public package with an internal name and higher version wins |
| scope / namespace | a prefix that ties names to one owner (@acme/...) |
| typosquatting | a package named one typo away from a popular one |
| malicious package | a package written to cause harm |
| install script | code a package manager runs during installation |
| maintainer | a person who can publish a project's releases |
| compromised maintainer | a stolen maintainer account or a bad insider |
| compromised build | clean source, poisoned output from the build system |
| backdoor | hidden code that gives secret access |
| SUNBURST | the backdoor in trojanised SolarWinds Orion updates (2020) |
| trojanised | legitimate software altered to hide malicious code |
| DLL | Windows dynamic-link library |
| XZ Utils / liblzma | a Linux compression tool and library |
| CVE-2024-3094 | the xz-utils backdoor in versions 5.6.0 and 5.6.1 |
| SSH / sshd | secure remote login / its server program |
| tarball | a .tar.gz release archive |
| version range | a rule like >=3.0 allowing many versions |
| pinning | fixing an exact version |
| hash | a fingerprint of bytes; any change alters it |
| lockfile | exact versions and hashes of all dependencies |
| hash pinning | refusing bytes that don't match the recorded hash |
| artifact | something a build produces |
| provenance | who built an artifact, how, and from which inputs |
| SLSA | Supply-chain Levels for Software Artifacts (Build L0–L3) |
| hosted build platform | a managed build service, not a personal machine |
| artifact signing | a digital signature on a build output |
| Sigstore | open-source project for keyless signing and verification |
| cosign | Sigstore's sign/verify tool |
| Fulcio | Sigstore's certificate authority issuing short-lived certificates |
| Rekor | Sigstore's append-only transparency log |
| ephemeral key | a key used once and discarded |
| keyless signing | signing tied to an identity instead of a long-term key |
| transparency log | a public, append-only record of events |
| reproducible build | same source → byte-for-byte identical output |
| build timestamp | time stored inside a build output |
| OpenSSF Scorecard | automated 0–10 checks of an open-source project's security practices |
| SCA | software composition analysis (episode 60) |
Summary
- Most shipped code is other people's: direct and transitive dependencies form your software supply chain.
- Know every part with an SBOM (SPDX, CycloneDX); use VEX to say which findings really affect you.
- OWASP's A06:2021 grew into A03:2025 Software Supply Chain Failures; A08 covers unchecked integrity.
- Attackers use dependency confusion, typosquatting, malicious packages, compromised maintainers (xz-utils) and compromised builds (SolarWinds).
- Defend with private-only internal names, lockfiles with hashes, provenance and SLSA, Sigstore signatures, reproducible builds, Scorecard checks and fewer dependencies.
- Next episode: CI/CD pipeline security.
Sources (fetched 13 Nov 2026)
- OWASP Top 10:2025 introduction: https://owasp.org/Top10/2025/0x00_2025-Introduction
- The Hacker News, dependency confusion (Feb 2021): https://thehackernews.com/2021/02/dependency-confusion-supply-chain.html
- The Hacker News, nearly 18,000 SolarWinds customers (Dec 2020): https://thehackernews.com/2020/12/nearly-18000-solarwinds-customers.html
- Mandiant (Google Cloud), SUNBURST backdoor: https://cloud.google.com/blog/topics/threat-intelligence/evasive-attacker-leverages-solarwinds-supply-chain-compromises-with-sunburst-backdoor
- Rapid7, backdoored XZ Utils (CVE-2024-3094): https://www.rapid7.com/blog/post/2024/04/01/etr-backdoored-xz-utils-cve-2024-3094/
- SLSA v1.0 levels: https://slsa.dev/spec/v1.0/levels
- Sigstore documentation: https://docs.sigstore.dev/
- Wiz, standard SBOM formats: https://www.wiz.io/academy/application-security/standard-sbom-formats
- DevGuard, SBOM standards: https://docs.devguard.org/explanations/compliance/sbom-standards/
- Sonar, OpenSSF Scorecard: https://www.sonarsource.com/learn/openssf-scorecard