Lesson 3 of 10
Supply Chain Attacks
Supply chain attacks compromise software, hardware, or services before they reach the target. They exploit the inherent trust organizations place in their vendors and developers - making them extremely hard to detect and devastatingly effective.
Supply Chain Attack Categories
- Software build system compromise (SolarWinds style): Attacker injects malicious code into the build process - the released software is signed by the vendor (legitimate signature) but contains backdoor code. Detection: Build reproducibility - compare compiled output from isolated build environment to released binaries
- Open source package poisoning (npm/PyPI): Publish malicious package with similar name (typosquatting): 'requets' instead of 'requests', 'colourama' instead of 'colorama'. Or compromise maintainer accounts of legitimate popular packages
- Dependency confusion attack (reported by Alex Birsan, 2021): If a private internal package name (company-auth-lib) is uploaded to a public registry with a higher version number, many package managers will prefer the public version. Birsan earned $130,000 in bug bounties from Apple, Microsoft, PayPal, and Uber
- Hardware implants: Nation-state level - malicious chips implanted in server hardware during manufacturing or transit. Bloomberg 'Big Hack' report (disputed) alleged this against Supermicro servers
Defending the Software Supply Chain
# SLSA (Supply-chain Levels for Software Artifacts) - Google framework
# and practical supply chain security controls
# 1. Software Bill of Materials (SBOM)
# SBOM: inventory of all components in your software (like a nutrition label)
# Generate SBOM for every build:
syft myapp:latest -o spdx-json > sbom.spdx.json
# SPDX or CycloneDX format - query for CVEs in any component
# 2. Dependency pinning + hash verification
# Python - pin exact versions AND verify hashes
pip install requests==2.31.0 --hash=sha256:58cd2187423d... --hash=sha256:f9291a5...
# requirements.txt with hashes:
pip-compile --generate-hashes requirements.in
# npm - use package-lock.json integrity hashes
npm install # Generates package-lock.json with checksums
npm ci # STRICT mode - fails if package-lock.json doesn't match
# 3. Private registry mirror
# Mirror public registries internally - review before making available
# npm: Verdaccio, Azure Artifacts
# Python: devpi, PyPI mirror
# Only approved packages accessible to internal developers
# 4. Code signing + build provenance (SLSA Level 3)
# Sign build artifacts: prove specific code produced specific binary
cosign sign --key cosign.key myimage:latest
cosign verify --key cosign.pub myimage:latest
# 5. Vendor security assessment
# Before integrating any vendor:
# - Request their security questionnaire/SOC 2 report
# - Review what access they require to your systems
# - Establish vendor offboarding procedure
# - Monitor vendor access logsCommon Mistakes
- Using unpinned dependencies (requests>=2.0.0) - any new version of requests could be malicious; pin to exact versions with hash verification
- No review process for new dependencies - establishing a dependency review gate (security team approval for new third-party packages) prevents most typosquatting
- Giving vendors excessive access - supply chain attackers target vendors specifically to inherit their customer access; review all vendor permissions quarterly
Tip
Tip
Practice Supply Chain Attacks in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
The foundational security model: Confidentiality (privacy), Integrity (trust), and Availability (uptime).
Practice Task
Note
Practice Task - (1) Write a working example of Supply Chain Attacks from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Supply Chain Attacks is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready cybersecurity code.
Key Takeaways
- Supply chain attacks compromise software, hardware, or services before they reach the target.
- Software build system compromise (SolarWinds style): Attacker injects malicious code into the build process - the released software is signed by the vendor (legitimate signature) but contains backdoor code. Detection: Build reproducibility - compare compiled output from isolated build environment to released binaries
- Open source package poisoning (npm/PyPI): Publish malicious package with similar name (typosquatting): 'requets' instead of 'requests', 'colourama' instead of 'colorama'. Or compromise maintainer accounts of legitimate popular packages
- Dependency confusion attack (reported by Alex Birsan, 2021): If a private internal package name (company-auth-lib) is uploaded to a public registry with a higher version number, many package managers will prefer the public version. Birsan earned $130,000 in bug bounties from Apple, Microsoft, PayPal, and Uber
Finished this lesson?