Dev tools
Software Supply Chain Security: A Practical Guide
Software supply chain security in practice: how attacks on dependencies, builds and CI work, real incidents, SBOMs, SLSA, signing and a step-by-step plan.
Software supply chain security is the practice of protecting everything that goes into your software before it reaches users: the open-source packages you depend on, the tools and CI pipelines that build it, the containers and registries it ships through, and the accounts and secrets that control all of those. Most applications are mostly other people's code. If an attacker compromises one popular package, build tool or CI action, every project that uses it can be hit at once, without anyone attacking you directly.
This guide explains what a software supply chain attack is, walks through real incidents and what each one teaches, covers the frameworks and regulations that now shape the field (SBOMs, SLSA, NIST SSDF, the EU Cyber Resilience Act), and gives a practical, step-by-step plan with tools and commands you can use this week. It's written for developers and small teams, not just security departments.
Software Supply Chain Security at a Glance
| Link in the chain | What can go wrong | Main defences |
|---|---|---|
| Source code | Malicious commits, stolen developer credentials, compromised maintainers | Phishing-resistant MFA, branch protection, required reviews, signed commits |
| Dependencies | Malicious or hijacked packages, typosquatting, vulnerable versions | Lockfiles, pinning, vulnerability scanning, dependency review, minimal dependencies |
| Build and CI | Compromised CI actions, poisoned build steps, leaked secrets | Pin actions by commit, least-privilege tokens, isolated builds, provenance |
| Artifacts and registries | Tampered packages or images, stolen publish tokens | Signing, provenance attestations, trusted publishing, registry access controls |
| Deployment | Unverified images running in production | Signature and policy checks at deploy time |
| Knowing what you run | No inventory when a new vulnerability lands | SBOMs, dependency inventory, continuous monitoring |
What Is a Software Supply Chain Attack?
A software supply chain attack compromises something upstream of the target, such as a library, a build tool, an update server or a vendor, so that malicious code reaches many victims through normal, trusted channels. Users install it themselves because it arrives as a routine update or dependency.
Common techniques:
- Account takeover: stealing a maintainer's or publisher's credentials and releasing a malicious version.
- Malicious maintainer: an attacker earns trust over months or years, then adds a backdoor.
- Typosquatting and lookalike packages: publishing
reqeustsorlodahsand waiting for typos. - Dependency confusion: publishing a public package with the same name as a company's internal one, so the build fetches the attacker's version.
- Build system compromise: altering the build so the source looks clean but the shipped binary isn't.
- CI/CD compromise: hijacking a widely used CI action or plugin to steal secrets from every pipeline that runs it.
- Install-time scripts: packages that run code when installed, before anyone reviews what they do.
Not every supply chain risk is malicious. A critical vulnerability in a popular library, such as Log4Shell, spreads through the same dependency graph and needs the same visibility to fix.
Real Incidents and What They Teach
| Incident | What happened | Lesson |
|---|---|---|
| SolarWinds Orion (2020) | Attackers compromised the vendor's build system and inserted a backdoor into signed updates shipped to thousands of customers | Signed doesn't mean safe if the build itself is compromised; protect and verify builds |
| Codecov (2021) | An attacker modified Codecov's Bash uploader script, which many CI pipelines downloaded and ran, to send environment variables (including secrets) out | Scripts fetched and run in CI are dependencies too; pin and verify them |
| Log4Shell (2021) | A critical remote code execution flaw in the widely used Log4j Java library | You can't patch what you can't find; you need an inventory of every component |
| xz Utils backdoor (2024, CVE-2024-3094) | A backdoor was hidden in xz/liblzma versions 5.6.0 and 5.6.1 by a contributor who had gained maintainer trust over a long period; it was caught shortly before reaching most stable Linux releases | Long-running social engineering against small, overworked open-source projects is a real threat |
| tj-actions/changed-files (2025, CVE-2025-30066) | A popular GitHub Action was modified so its tags pointed to a malicious commit that printed CI secrets into workflow logs; CISA added it to its Known Exploited Vulnerabilities catalog | Referencing actions by tag trusts whoever controls the tag; pin to full commit SHAs |
| "Shai-Hulud" npm worm (2025) | A self-replicating worm stole npm tokens and republished infected versions of the victims' other packages; CISA reported more than 500 packages affected | Long-lived publish tokens and install-time scripts let attacks spread automatically |
The pattern across these: attackers go where one compromise reaches many targets, and they increasingly target developer accounts, tokens and CI, not just code.
Frameworks and Rules You'll Hear About
SBOM (software bill of materials). What is SBOM in software? It's a machine-readable list of every component in a piece of software: packages, versions, licences and where they came from, like an ingredients label. The two main formats are SPDX (an ISO/IEC standard) and CycloneDX (an Ecma standard). An SBOM doesn't make software safer by itself, but when the next Log4Shell lands it turns "are we affected?" from days of searching into a query.
SLSA (Supply-chain Levels for Software Artifacts). An OpenSSF framework that defines increasing levels of build integrity. At higher levels, builds run on a hardened, hosted build platform and produce signed provenance: a record of what source, build steps and inputs produced an artifact. Consumers can then check that a package really came from the expected repository and pipeline.
Sigstore. Open-source tools (including cosign) and public services for signing and verifying software artifacts without managing long-lived signing keys. Signing uses short-lived certificates tied to an identity, and signatures are recorded in a public transparency log.
OpenSSF Scorecard. An automated check that rates open-source projects on security practices such as branch protection, pinned dependencies, maintained status and dangerous CI workflows. It's useful for evaluating dependencies before adopting them.
NIST SSDF (SP 800-218). The US Secure Software Development Framework: a set of practices for preparing the organisation, protecting software, producing well-secured software and responding to vulnerabilities. US federal software suppliers are asked to attest to these practices.
EU Cyber Resilience Act (CRA). EU law for products with digital elements, which entered into force on 10 December 2024. From 11 September 2026, manufacturers must report actively exploited vulnerabilities and severe incidents. Most other obligations, including secure-by-design requirements, vulnerability handling and technical documentation, apply from 11 December 2027. If you sell software or connected products in the EU, supply chain practices like SBOMs and vulnerability handling are becoming legal requirements, not just good hygiene.
Software Supply Chain Security Best Practices
Here are software supply chain security best practices, ordered roughly by effort versus payoff for a typical team.
1. Lock down accounts and tokens
- Require phishing-resistant MFA (security keys or passkeys) for source control, package registries and cloud accounts.
- Replace long-lived publish tokens with trusted publishing (OIDC-based, short-lived credentials from CI) where your registry supports it.
- Give CI tokens the least privilege they need. In GitHub Actions, set
permissions:explicitly instead of relying on defaults. - Rotate any secret that has ever appeared in logs.
2. Control what you depend on
- Commit lockfiles (
package-lock.json,poetry.lock,Cargo.lock,go.sum) and install from them in CI (npm ci, notnpm install). - Review new dependencies before adding them: maintainer activity, download history, Scorecard results, and whether you really need them.
- Reduce the count. Every dependency is code you trust; a small helper you can write in ten lines may not be worth a package.
- Use hash checking where available. For Python, pip's
--require-hashesmode refuses any package whose hash isn't listed. - Disable install scripts where you can (
npm ci --ignore-scripts), and allow them only for packages that truly need them. - Use internal or proxied registries with explicit scoping to block dependency confusion.
3. Scan continuously
- Run vulnerability scanning on every pull request and on a schedule, not only at release.
- Turn on automated update pull requests (Dependabot, Renovate) so fixes are small and routine.
- Watch for malicious package advisories as well as vulnerabilities; they're published in the same databases.
4. Harden CI/CD
- Pin third-party actions to a full commit SHA, not a tag:
uses: some-org/some-action@<40-character-sha>. Tags can be moved; commits can't. - Don't run untrusted pull request code with access to secrets.
- Keep build steps reproducible and isolated; avoid
curl | bashin pipelines, or pin and verify what you download. - Separate build and deploy credentials.
5. Sign and record provenance
- Sign release artifacts and container images (for example with Sigstore's
cosign). - Generate provenance attestations in CI. Many registries now support publishing them, and npm can verify signatures and provenance of installed packages.
- Verify at deploy time: an admission policy that refuses unsigned or unknown images closes the loop.
6. Know what you ship
- Generate an SBOM for every release and container image, and store it with the artifact.
- Keep an inventory you can search across services when a new vulnerability is announced.
7. Prepare to respond
- Decide in advance who triages a supply chain alert, how fast critical fixes ship, and how you'll notify customers.
- Practise the drill: "a dependency we use was backdoored yesterday. Which services include it, and which tokens might have leaked?"
Worked Example: How Dependency Confusion Happens
Dependency confusion is one of the simplest supply chain attacks to understand, and one of the easiest to prevent.
- A company publishes an internal package called
acme-billing-utilsto its private registry. Its build tool is configured to look in both the private registry and the public one. - An attacker sees the name in a leaked
package.json, an error message or a public job posting, and publishes a package with the same name to the public registry with a higher version number, such as99.0.0. - The next time a developer or CI runs an install without a lockfile, the resolver picks the highest version it can find, which is the attacker's public package.
- The package's install script runs, collects environment variables and CI secrets, and sends them out.
What would have stopped it:
- Scoped package names (
@acme/billing-utils) bound to the private registry, so the resolver never looks publicly for that scope. - A lockfile and `npm ci`, which installs exactly the recorded version and source.
- Registry configuration that proxies public packages through the private registry and blocks public packages from shadowing internal names.
- Disabled install scripts by default, so even a wrong package can't run code at install time.
None of these needs a commercial tool. They're configuration choices, which is why they're among the highest-value fixes.
How to Vet a New Dependency
Before adding a package, spend five minutes on these questions:
- Is it maintained? Look at recent releases, open issues and how quickly security reports get fixed.
- Who maintains it? One unpaid maintainer is a different risk from a foundation-backed project.
- How popular is it, and is this the real one? Check the exact name, publisher and download history to avoid lookalikes.
- What does it pull in? A tiny feature that adds forty transitive dependencies is a large new attack surface.
- Does it run code on install? Install scripts deserve a closer look.
- What does OpenSSF Scorecard say? Low scores on branch protection, code review or pinned dependencies are warning signs.
- Is the licence acceptable? Licence problems are a supply chain risk too, especially for products you sell.
- Can you write it yourself? For small utilities, owning ten lines can beat trusting a stranger's release process.
Record the decision in the pull request that adds the dependency, so the next person knows why it was accepted.
Supply Chain Risks in AI Models and Data
AI features add new links to the chain:
- Model files can run code. Older model formats based on Python's pickle can execute arbitrary code when loaded. Prefer formats designed to hold only weights, such as safetensors, and load models only from sources you trust.
- Model hubs are registries. Typosquatted or hijacked model repositories work like malicious packages. Pin a model to a specific revision instead of "latest", and record which model version each release uses.
- Training and retrieval data can be poisoned. Data pulled from the web or from user uploads can carry instructions or biased content into your system. Track where data came from and validate it.
- AI tools in CI and editors hold credentials. Coding agents and assistants that can run commands or open pull requests need the same least-privilege treatment as any other CI token.
The same principles apply as for code: pin versions, verify sources, keep an inventory and limit what each component can access.
Software Supply Chain Security Tools
Here are common software supply chain security tools, most of them free and open source:
| Job | Tools | Example command or setting |
|---|---|---|
| Generate SBOMs | Syft, CycloneDX tools, SPDX tools, built-in registry features | syft ./my-project -o cyclonedx-json |
| Scan for vulnerabilities | OSV-Scanner, Grype, Trivy, npm audit, pip-audit, GitHub Dependabot alerts | osv-scanner scan source -r . |
| Verify package signatures and provenance | npm audit signatures, Sigstore cosign | npm audit signatures |
| Sign artifacts | Sigstore cosign, registry-native signing | cosign sign on an image in CI |
| Rate dependencies | OpenSSF Scorecard | Run on candidate dependencies before adoption |
| Keep dependencies current | Dependabot, Renovate | Weekly grouped update pull requests |
| Detect leaked secrets | Gitleaks, TruffleHog, platform secret scanning | Pre-commit and CI scans |
| Enforce policy at deploy | Kubernetes admission controllers (Kyverno, OPA Gatekeeper, Sigstore policy controller) | Reject unsigned images |
Commercial platforms bundle many of these with dashboards, reachability analysis (whether vulnerable code is actually called) and malicious package detection. They're worth considering at scale, but the free tools cover a lot for small teams.
A 30-Day Plan for a Small Team
Week 1: accounts and secrets
- Enforce phishing-resistant MFA on GitHub/GitLab, package registries and cloud.
- Inventory CI secrets; remove unused ones; rotate anything old.
- Turn on secret scanning.
Week 2: dependencies
- Make sure every project has a committed lockfile and CI installs from it.
- Enable Dependabot or Renovate and vulnerability alerts.
- Add OSV-Scanner or an equivalent to pull request checks.
Week 3: CI/CD
- Pin all third-party actions to commit SHAs.
- Set minimal
permissions:in every workflow. - Move package publishing to trusted publishing.
Week 4: artifacts and inventory
- Generate an SBOM for each release and image.
- Sign container images and verify signatures before deploy.
- Write a one-page incident playbook for compromised dependencies.
Common Mistakes
- Trusting tags and "latest". Mutable references let an attacker swap what you run without changing your code.
- Treating scanner output as the whole program. Scanners find known vulnerabilities, not fresh malicious packages or stolen tokens.
- Alert fatigue. Hundreds of low-severity findings hide the one that matters. Prioritise by severity, exploitability and whether the code is reachable.
- Long-lived tokens everywhere. A single leaked publish token can turn into a worm.
- Forgetting developer machines. Compromised laptops and editor extensions are part of the chain too.
- Generating SBOMs nobody can query. Store them where you can search across all services.
AI coding assistants add a new twist: they can suggest packages that don't exist, which attackers then register. Our guide to AI generated code security covers reviewing AI-suggested dependencies.
FAQ
What is the difference between software supply chain security and application security?
Application security focuses on flaws in your own code. Software supply chain security covers everything your software is built from and built with: third-party code, build systems, CI, registries and the accounts that control them.
Is open source less secure than proprietary software?
Not inherently. Open source can be inspected by anyone, and many projects are very well maintained. The risk comes from depending on many projects without checking their health, and from small projects with few maintainers.
Do small companies need SBOMs?
They're increasingly expected by customers and, for products sold in the EU, by regulation. Even without a requirement, an SBOM makes it far faster to answer "are we affected?" when a new vulnerability lands.
What is SLSA in simple terms?
SLSA is a framework of levels for how trustworthy a software build is. Higher levels require hardened build systems and signed provenance that records exactly what source and process produced an artifact.
How do container images fit into supply chain security?
Container images bundle an operating system layer, libraries and your app, so they carry many dependencies. Use minimal base images, scan them, generate SBOMs, sign them and verify signatures before they run. Our guide to Docker vs Kubernetes covers how images move from build to cluster.