← Blog

Software supply chain attacks and how builds stop them

· 13 min read

A software supply chain attack does not break into your application. It breaks into something your application trusts: a package, a maintainer account, a build server, a CI action, an image in a registry. Your pipeline then delivers the attacker's code to production for them, signed and versioned like any other release.

Software supply chain security is the work of checking each of those trust points so that what runs in production is provably what you meant to ship. This guide covers how the attacks work, four incidents that shaped current practice, and the build controls that stop them.

What the software supply chain is

Every release passes through four hops:

  1. Source. Developers commit code to a repository. Reviews, branch rules and commit signing decide what gets in.
  2. Build. A CI runner checks out the source, pulls dependencies from package registries, runs third-party actions or plugins, and compiles the result.
  3. Package. The output is stored as an artifact: a container image, a wheel, a tarball, a binary in a registry.
  4. Deploy. Something pulls that artifact and runs it in production.

Dependencies enter at the build hop, and they bring their own supply chains with them. Each dependency has its own source, build and publish steps, run by people you have never met.

The SLSA framework maps this into threats lettered A to I, from the producer and the source repository through the build process, artifact publication and the distribution channel, to package selection and usage. Dependency threats are the same list applied recursively to every package you pull. It is a useful checklist when you ask "where could someone change what we ship?"

The fastest way to see these trust boundaries is to follow one commit end to end. Our free lab (open from 12 January 2027) Trace one commit from push to production has you do exactly that on a Git server, CI runner, registry, package index and production host, marking who can change what at each hop. It opens free on 12 January 2027; join the launch list to get it first.

How software supply chain attacks work

OWASP groups the dependency side of this under CICD-SEC-3, Dependency Chain Abuse: flaws in how workstations and build environments fetch code dependencies. The build and artifact side has its own entries. Together they give five classes worth knowing.

Dependency confusion

Your build pulls internal packages from a private index but can also reach a public one. An attacker publishes a public package with the same name as one of your internal packages and a higher version number. If the package manager merges both sources and picks the highest version, your build installs the attacker's package.

Alex Birsan made this widely known in February 2021, when he used it against more than 35 organisations, including Apple, Microsoft and PayPal, under their bug bounty programmes. pip's own documentation now warns that using --extra-index-url to find private packages is unsafe for this reason. We cover the mechanics in detail in Dependency confusion: how a public package hijacks a private build.

Typosquatting and install scripts

Typosquatting relies on a typo. A package called something one keystroke away from a popular name waits for a developer, or an AI assistant, to get it wrong. The damage comes from install scripts: npm runs preinstall and postinstall hooks the moment a package is installed, so the attacker gets code execution on the laptop or the CI runner before anyone imports anything.

Install scripts are also what turn a single compromised package into a worm, as the npm incidents below show.

Compromised maintainers

Here the package name is right, and so is the publisher account. The attacker has taken over the maintainer, through phishing, a stolen token or years of patient social engineering, and publishes a malicious version through the normal channel. OWASP calls this dependency hijacking.

In September 2025, the maintainer of chalk, debug and other widely used npm packages was phished through an email from a lookalike npmjs.help domain, and malicious versions carrying a browser crypto stealer were published to npm (The Register). Nothing about the package name looked wrong.

Compromised build systems and third-party actions

The build hop runs code from many owners: the CI platform, the runner image, every third-party action or plugin a workflow calls, and every tool those actions download. Compromise any of them and your build runs the attacker's code with your secrets in memory.

Tags make this worse. A workflow that says uses: some/action@v4 trusts whoever controls that tag today, and tags can be moved to point at a different commit.

Artifact tampering between build and deploy

Once an artifact leaves the build, it sits in caches, artifact stores and registries. If a low-trust job can write to a cache that a release job reads, or if anyone with registry write access can push a new image under an existing tag, production can end up running something the pipeline never built. OWASP lists this as CICD-SEC-9, Improper Artifact Integrity Validation.

Real supply chain attacks and what each one broke

The xz-utils backdoor (CVE-2024-3094)

On 29 March 2024, Andres Freund reported to oss-security that xz/liblzma versions 5.6.0 and 5.6.1 contained a backdoor. He found it because SSH logins on a Debian sid machine were using unusual CPU and producing valgrind errors. CISA issued an alert the same day.

Two details matter for builders:

  • The attacker was a maintainer. Russ Cox's timeline traces the account "Jia Tan" from a harmless first patch in October 2021 to maintainer status in late 2022, helped along by other accounts pressuring the original maintainer. The malicious releases came through the project's normal process.
  • The backdoor was not all in git. Part of it sat in obfuscated test files in the repository, and the part that activated it, a modified build-to-host.m4, existed only in the release tarballs. Freund's post notes that line "is not in the upstream source of build-to-host."

Hash pinning would not have helped here: the tarball was the official release, so its hash was the official hash. What helps is building from the tagged source rather than a hand-made tarball, and having provenance that records which source a release was built from, so the difference between "what is in git" and "what was shipped" is visible.

The tj-actions/changed-files compromise (CVE-2025-30066)

In March 2025, the tj-actions/changed-files GitHub Action, used in over 23,000 repositories, was compromised. According to the GitHub advisory, the attacker retroactively pointed existing version tags at a malicious commit that dumped secrets from the runner's memory into the build log. In public repositories those logs are readable by anyone. StepSecurity detected it on 14 March when a workflow called an unexpected network endpoint.

CISA's alert links it to a second compromise, reviewdog/action-setup (CVE-2025-30154). Palo Alto's Unit 42 analysis traces the chain further back: a token leaked from one project's pull_request_target workflow, used to move a tag in reviewdog, which then leaked the token of the bot account that maintained tj-actions. Unit 42 also found the attack started as a targeted attempt on a Coinbase repository, which failed.

This is the clearest case for pinning actions to a full commit SHA. Workflows that referenced a known-good SHA kept running the known-good code when the tags moved.

SolarWinds Orion and the SUNSPOT build implant

In December 2020, FireEye (now Mandiant) disclosed that a digitally signed SolarWinds Orion component carried a backdoor, SUNBURST. CISA issued Emergency Directive 21-01 on 13 December 2020, ordering federal agencies to disconnect affected Orion versions. In its 8-K filing, SolarWinds said fewer than 18,000 customers may have installed an affected version.

The source repository was not where the backdoor lived. CrowdStrike's analysis of SUNSPOT shows malware on the build server that watched for MsBuild.exe, swapped one source file for a backdoored version during compilation, and restored the original afterwards. It wrapped the injected code in #pragma warning directives to keep it out of build logs.

The release was signed, and the signature was valid. Signing proves who produced an artifact, not that the build was clean. Defending against this class needs a build platform the build steps themselves cannot persistently change, which is what SLSA Build Level 3 asks for, and ideally an independent rebuild to compare against.

Self-spreading npm worms: Shai-Hulud

In September 2025, a worm named Shai-Hulud spread through npm. CISA's alert describes it authenticating to the registry as each compromised developer, injecting code into their other packages and publishing new versions. It compromised over 500 packages and stole GitHub tokens and cloud API keys. GitHub responded with a plan to tighten npm publishing: trusted publishing, short-lived granular tokens and stronger 2FA.

A second wave, Shai-Hulud 2.0, appeared in November 2025. Datadog Security Labs counted at least 796 backdoored packages. It ran from a preinstall script, stole cloud and CI credentials, and registered the victim machine as a self-hosted GitHub Actions runner the attacker could use later.

A worm like this needs three things: a long-lived publish token on the machine, an install script that runs automatically, and builds that pick up new versions without review. Remove any one and it stops spreading through you.

Our written lesson Case studies: xz-utils, the tj-actions compromise and self-spreading package worms walks each incident hop by hop against the pipeline model above.

Controls that stop software supply chain attacks

No single control covers every class. The table shows where each one bites.

ControlStops or limits
Lockfiles and hash pinningDependency confusion, typosquats and malicious new versions entering silently
Actions pinned to a commit SHAMoved tags on third-party actions
SBOMNot knowing what you shipped when the next advisory lands
Signing and verify before deployArtifacts swapped or pushed outside the pipeline
SLSA provenanceArtifacts built from the wrong source, workflow or builder
Ephemeral, isolated runnersPersistence on the build machine, poisoned caches

Lockfiles and hash pinning

A lockfile records the exact version of every direct and transitive dependency. Hash pinning goes further: the build refuses any file whose hash does not match. Together they mean a new release on a public registry, malicious or not, cannot reach your build until someone updates the lockfile in a reviewed change.

For npm, install from the lockfile and fail if it does not match package.json. npm ci "will never write to package.json or any of the package-locks". Adding --ignore-scripts stops install hooks from running, though some packages with native builds need their scripts, so test before enforcing it everywhere.

npm ci --ignore-scripts

For pip, hash-checking mode requires every requirement to be pinned with == and every dependency to carry a hash:

# requirements.txt
requests==2.32.3 \
    --hash=sha256:<hash of the published file>
pip install --require-hashes -r requirements.txt

Lockfiles do not help if the version you locked was already malicious, as with xz-utils. They do turn "the build quietly picked up something new" into "a pull request changed a hash", which is a review you can do.

Pin third-party actions to a full commit SHA

GitHub's secure use reference says to pin actions to a full-length commit SHA, and to check the SHA comes from the action's own repository rather than a fork. A tag can be moved; a commit SHA cannot.

steps:
  # Pin to the full 40-character commit SHA, keep the tag as a comment
  - uses: actions/checkout@<full commit SHA>  # v4

The same page now describes workflow dependency lockfiles, which record the exact commit for every action a workflow depends on, including transitive ones. Either way, the rule is the same: the code your build runs should be named by content, not by a label someone else controls. Dependabot and Renovate can keep pinned SHAs up to date so pinning does not freeze you on old versions.

SBOM: a bill of materials for every release

A software bill of materials lists every component in an artifact. CISA describes it as "a nested inventory, a list of ingredients that make up software components." The NTIA published minimum elements in July 2021 under Executive Order 14028, and CISA has since updated them.

An SBOM does not stop an attack. It answers the first question of every incident: "do we ship the affected version, and where?" With an SBOM stored for every release, that becomes a query instead of a week of digging through images. Generate it in the pipeline (Syft writes CycloneDX and SPDX), store it next to the artifact, and attach it as a signed attestation so it cannot be swapped.

Sign artifacts and verify before deploy

Signing only helps if something checks the signature, and that check has to happen at deploy time, not as a step people can skip. With cosign, a deploy step verifies the image digest against your public key:

cosign verify --key cosign.pub registry.example.com/acme/app@sha256:<digest>

With keyless signing, the CI job's OIDC identity replaces the long-lived key, and you verify the identity of the workflow that signed it:

cosign verify \
  --certificate-identity-regexp '^https://github\.com/acme/app/\.github/workflows/release\.yml@refs/heads/main$' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com \
  registry.example.com/acme/app@sha256:<digest>

Verify by digest, not by tag. On Kubernetes, move the check into an admission policy so the cluster itself refuses unsigned images. Remember SolarWinds, though: a signature on a tampered build is still a valid signature. Signing protects the hop after the build, not the build itself.

SLSA build levels and provenance

SLSA (Supply-chain Levels for Software Artifacts, currently v1.2) defines build levels that describe how much you can trust an artifact's origin:

  • Build L1, provenance exists. The package has provenance showing how it was built. Useful against mistakes, but easy to forge.
  • Build L2, hosted build platform. Provenance is generated and signed by a hosted build platform. This "prevents tampering after the build through digital signatures."
  • Build L3, hardened builds. The build platform isolates builds from each other and keeps signing material away from user-defined build steps. Forging provenance now requires exploiting a vulnerability in the platform.

Provenance is an in-toto attestation that records the builder, the build type, the external parameters such as repository, ref and workflow, and the resolved dependencies. At deploy time you verify it: was this artifact built by our builder, from our repository, on the main branch, by the release workflow? An artifact built on a laptop, or from a fork, fails that check even if someone managed to sign it.

Ephemeral, isolated runners

A runner that is reused between jobs is a place to leave things behind: a modified tool on the PATH, a poisoned cache, a process that waits for the next job's secrets. GitHub's guidance is that self-hosted runners "should almost never be used for public repositories" and that they "can be persistently compromised by untrusted code in a workflow". It recommends just-in-time runners that perform at most one job before they are removed.

Give every job a fresh, isolated environment that is destroyed when the job ends, keep caches per trust level so a pull request job cannot write what a release job reads, and restrict runner egress to the hosts a build actually needs. The tj-actions compromise was caught because a build called a host it never normally calls.

Practise each attack and control

Reading about a moved tag is one thing; watching your own pinned workflow ignore it is another. Each of these is a hands-on lab in our course DevSecOps: CI/CD Pipeline Security, run in the browser against a real Git server, CI runner, registry and package index:

TopicLab
Dependency confusionDependency confusion against a private package index
Typosquatting and install scriptsTyposquatting and install scripts that run on install
Lockfiles, hash pinning, pinned actionsLockfiles, hash pinning and pinning third-party actions to a commit
SBOM and scanningBill of materials, vulnerability scanning and deciding what actually blocks a release
Cache and artifact tamperingPoison the build cache and a shared artifact
Runner persistencePersist on a self-hosted runner and wait for the next job
Ephemeral runnersEphemeral, isolated runners
Signing and verify before deploySign images and verify before deploy with cosign
SLSA provenanceProvenance attestations: prove which pipeline built this artifact
Keyless signingKeyless signing with a local Sigstore stack
Admission controlAdmit only signed images on a single-node Kubernetes cluster

Every defence lab ends the same way: you replay the attack and watch it fail.

If you want a list to work through on your own pipeline first, the CI/CD pipeline hardening checklist maps these controls to the OWASP CI/CD risks.

Learn it by breaking it

Hands-on DevSecOps labs launch 12 January 2027, with the first two modules free.

See the course