Software supply chain security
About this lesson
Your app runs far more code than your team wrote: packages from a registry, the packages those need, and the build server that turns it all into a release. Follow one real Python package, requests, through that chain. Audit it for known flaws, pin its exact file by its SHA-256 hash, and watch a seven-line Python checker accept the genuine wheel and refuse a copy with one changed byte. Then keep an SBOM, lock down the build and sign the release, following NIST's SSDF and OWASP.
Your app's supply chain
Your app is more than your code. It runs packages other people wrote, downloaded from a registry. A build server turns it all into a release, which is deployed. That whole path is the software supply chain, and every link can fail.
your code what your team writes dependencies packages other people wrote registry where they are downloaded from (PyPI) build server turns code + packages into a release production where the release runs supply chain the whole path, every link
Read the lesson step by step
Your app's supply chain
Your app is more than your code. It runs packages other people wrote, downloaded from a registry. A build server turns it all into a release, which is deployed. That whole path is the software supply chain, and every link can fail.
your code what your team writes dependencies packages other people wrote registry where they are downloaded from (PyPI) build server turns code + packages into a release production where the release runs supply chain the whole path, every linkDependencies, and theirs
Your project asks for requests 2.31.0, a popular Python package. pip downloads it from PyPI, the Python Package Index, plus the four packages it needs. Those are transitive dependencies: you never chose them, but their code runs inside your app.
pip install requests==2.31.0 requests 2.31.0 direct: you asked for it urllib3 2.8.0 transitive idna 3.20 transitive certifi 2026.10.23 transitive charset-normalizer 3.5.2 transitive 1 package asked for, 5 installedWhere the chain breaks
OWASP ranks supply chain failures third in its 2025 Top 10. Common mistakes: an old version with known flaws, a look-alike package name, a version that changes without review, a hijacked maintainer account, or a tampered build server.
OWASP Top 10:2025 A03 Software Supply Chain Failures mistake fix old, flawed version audit and update look-alike package name check the exact name version changes silently pin version + hash hijacked maintainer pin hash, verify signature tampered build server locked-down build, provenanceCheck for known flaws
pip-audit compares each version with a public advisory database. It flags requests 2.31.0: CVE-2024-35195 and two more, all fixed in later releases. The fix is to upgrade, here to 2.34.2, then run the check again.
pip-audit requests 2.31.0 CVE-2024-35195 fixed in 2.32.0 CVE-2024-47081 fixed in 2.32.4 CVE-2026-25645 fixed in 2.33.0 upgrade requests 2.34.2 pip-audit no known advisories (checked 2026-11-06) CISA KEV flaws attackers already use: fix firstLines 1–2: pin a hash
Next, pin exactly what you trust. The lock file records each version and the SHA-256 hash of its file: requests==2.34.2 --hash=sha256:2a0d60c1…. Line 2 of the checker reads the file name and that pinned hash.
requirements.txt (the lock file) requests==2.34.2 \ --hash=sha256:2a0d60c172f83ac6ab31e4554906c0f3 b3588d37b5cb939b1c061f4907e278e0 line 1 import hashlib, sys line 2 wheel = the file, pin = that hashLines 3–7: hash and compare
Lines 3 and 4 hash the downloaded wheel with SHA-256. Line 5 compares the result with the pin. They match, so line 7 says install. pip does this for every package when the lock file has hashes (--require-hashes).
wheel requests-2.34.2-py3-none-any.whl 73,075 bytes got 2a0d60c1…78e0 pin 2a0d60c1…78e0 equal → "hash ok: install"One changed byte is caught
Now one byte of the file is changed, say by a hijacked account or a bad mirror. The digest is completely different, so line 5 sees a mismatch and line 6 stops before any of the code inside can run.
same file, last byte changed (XOR 0x01) got 404259fc…7dea pin 2a0d60c1…78e0 not equal → "mismatch: refuse", exit status 1 pip: THESE PACKAGES DO NOT MATCH THE HASHESSBOM: the ingredients list
A software bill of materials (SBOM) lists every component with its supplier and version, transitive ones too. CISA calls it a nested inventory. When a new flaw is announced, like Log4Shell in 2021, you can see at once whether you use it.
SBOM every component, its version and supplier requests 2.34.2 urllib3 2.8.0 idna 3.20 certifi 2026.10.23 charset-normalizer 3.5.2 formats SPDX, CycloneDX use "are we affected?" answered in minutesA locked-down build
Attackers also target the build: in 2020 they slipped malicious code into SolarWinds Orion updates. So build automatically from reviewed code, on an isolated server with few secrets and MFA, and record provenance: which source and steps made the release.
NIST SSDF PO.5 separate and protect each build environment (MFA, access control) automated same steps every time, no hand edits few secrets only what this build needs provenance which source, which steps, which builder (SLSA build provenance)Sign it, verify it
The build signs the release and publishes its hash. NIST's SSDF (practice PS.2) asks makers to give users a way to check integrity. The production server verifies the signature and hash before it runs anything; a mismatch means stop.
SSDF PS.2 a way to verify release integrity: post hashes, sign the code build signs the release production checks signature + hash first mismatch do not run itDefence in depth
No single check is enough. Audit and update dependencies, pin and verify hashes, keep an SBOM, lock down the build and sign releases. NIST SP 800-218 (the SSDF) and SP 800-161 describe these practices for software makers and buyers.
audit + update known flaws fixed pin + verify only the exact files you trust SBOM know what you run locked-down build provenance recorded sign + verify production runs only real releases NIST SP 800-218 (SSDF) · NIST SP 800-161 Rev. 1
5 quick questions
Choose one answer per question. You can change your choices before checking them.
01You add requests to your project and pip installs five packages. What are the other four called?
requests itself needs urllib3, idna, certifi and charset-normalizer. You never asked for them, but their code runs in your app: they are transitive dependencies.
02A lock file pins requests==2.34.2 with --hash=sha256:2a0d60c1…. A mirror serves a copy of that file with one byte changed. What happens?
Changing even one byte gives an unrelated digest. In hash-checking mode pip compares it with the pin and stops before any code from the file can run, just like lines 5 and 6 of the checker.
03pip-audit reports that your pinned version of a package has a known advisory, fixed in a later release. What is the usual fix?
Known flaws are fixed by upgrading to a release that contains the fix. The new file gets a new hash, so the pin is updated too, and the audit runs again on every build.
04A new flaw is announced in a widely used library. Which record helps you answer "do we use it, and where?" fastest?
An SBOM lists every component and version in your software, transitive ones included, so you can search it as soon as an advisory such as Log4Shell is published.
05What does NIST SSDF practice PS.2 ask software makers to provide?
PS.2 is "Provide a Mechanism for Verifying Software Release Integrity": for example, post hashes for release files on a well-secured site, and sign the code so tools can check the signature before use.
Glossary
- Software supply chain
- Everything that goes into the software you run: your code, the packages it uses, where they are downloaded from, and the tools and servers that build and ship it. OWASP's 2025 Top 10 lists failures here as A03.
- Dependency (direct and transitive)
- A package your code uses. A direct dependency is one you asked for; a transitive dependency is one that a package you use needs in turn.
- Package registry
- A public store of packages that tools download from. PyPI, the Python Package Index, is Python's registry; pip installs from it by default.
- Pinning and lock file
- Pinning means fixing an exact version (==) and the SHA-256 hash of its file. A lock file, such as a requirements.txt with --hash lines, records the pins for every package.
- Hash check
- Hashing a downloaded file and comparing the digest with the pinned one. Any change to the file gives a different digest, so the install is refused. pip does this in hash-checking mode (--require-hashes).
- Advisory and pip-audit
- An advisory is a public record of a known flaw in a package version, often with a CVE number and the version that fixes it. pip-audit checks installed or pinned versions against an advisory database.
- SBOM
- A software bill of materials: a list of every component in a piece of software, with versions and suppliers. CISA calls it a nested inventory, a list of ingredients.
- Provenance and code signing
- Provenance records which source, steps and build machine produced a release. Code signing attaches a digital signature so users can check who made the release and that it is unchanged.
Notes and sources
- The digests are real: SHA-256 of requests-2.34.2-py3-none-any.whl (73,075 bytes) as listed on PyPI and re-hashed on 2026-11-06. The "changed" digest is that same file with its last byte flipped. The figure shows the first 8 of the 32 bytes.
- Versions and advisories were checked against PyPI and the OSV database on 2026-11-06. New advisories appear all the time, so audits run again on every build, not once.
- pip's hash-checking mode is all-or-nothing: once any line has --hash, every package, transitive ones included, must be pinned with == and hashed, or pip refuses to install.
- A hash only proves the file matches the pin. If the pin was taken from a file that was already bad, the check passes. Signatures and provenance add who built it and how.
- SolarWinds Orion (2020, CISA ED 21-01), Log4Shell (CVE-2021-44228) and XZ Utils (CVE-2024-3094) are named only as real examples of each failure.
- This course is about defence. It names supply chain weaknesses only at the level of the mistake and the fix, and never shows how to attack a real system.
- OWASP Top 10:2025, A03 Software Supply Chain Failures
- NIST SP 800-218: Secure Software Development Framework (SSDF) Version 1.1
- NIST SP 800-161 Rev. 1: Cybersecurity Supply Chain Risk Management Practices
- CISA: Software Bill of Materials (SBOM)
- CISA: Known Exploited Vulnerabilities Catalog
- CISA ED 21-01: Mitigate SolarWinds Orion Code Compromise
- CISA: Reported Supply Chain Compromise Affecting XZ Utils (CVE-2024-3094)
- CISA: Apache Log4j Vulnerability Guidance
- pip documentation: Secure installs (hash-checking mode)
- pip-audit (Python Packaging Authority)
- OSV: GHSA-9wx4-h78v-vm56 / CVE-2024-35195 (requests)
- PyPI: requests 2.34.2 files and hashes
- NIST FIPS 180-4: Secure Hash Standard
- SLSA v1.0: Build provenance
- Python docs: hashlib
Quiz Unlocks after the last step.