Build pipelines and the software supply chain

The build is an environment with production rights. Dependencies, runners, and release tokens deserve the same attention as the app.

Lesson 3 of 29 · 11 min read · practice only with authorization

Diagram

What you ship, and where it came from

Follow the path. One example at a time.

Step 1 of 4

Dependencies

Packages you pull, pinned in lockfiles.

Illustration: Dependencies
# Dependencies
# Packages you pull, pinned in lockfiles.

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Pinned inputs

    What fails
    Floating versions and tags let inputs change silently.
    Who is affected
    Every build.
    What you would notice
    npm install in CI, latest tags.
    What you change
    Lockfiles, frozen installs, and digest pins.
  2. CI privilege

    What fails
    Pipelines hold deploy keys and cloud access.
    Who is affected
    Production.
    What you would notice
    Workflows with write-all tokens.
    What you change
    Least-privilege tokens and OIDC.
  3. Knowing what shipped

    What fails
    Without SBOMs, advisories take days to answer.
    Who is affected
    Responders.
    What you would notice
    No SBOM per release.
    What you change
    Generate and store SBOMs.

You run other people's code on purpose

An application is your code plus a graph of libraries, base images, actions, and install scripts. A change in that graph runs during install and often runs again in production. Supply-chain compromise means that change was not yours, whether a maintainer's account was stolen, a new package shadowed a private name, or a build plugin was altered.

Lockfiles and pinned versions make the graph explicit. They do not make it safe. They make review possible. Dependabot-style updates are useful and also a path: read what changed in a release that touches install scripts or native code. Private package names should not be resolvable from the public registry. That mix-up is dependency confusion.

CI is a privileged user

A pipeline that can deploy, push images, or mint cloud credentials is an admin console triggered by a git push. Fork pull requests, untrusted tags, and third-party actions can execute on that runner if the workflow is careless. Secrets printed in logs are secrets.

Split the identity. A job that runs tests on a pull request should not hold the production deploy key. Protect the environments that do. Require review before those jobs run. Prefer short-lived cloud credentials over static keys stored in the CI settings. Self-hosted runners on a developer laptop inherit that laptop's network. Treat them as production-adjacent machines.

Knowing what you shipped

Provenance is evidence that this artifact came from this source through this build. Signed tags, signed images, and an SBOM you can compare during an incident turn a bad dependency from a rumor into a list of services. You will want that list at two in the morning.

Source control hosting is part of the estate. Branch protection, required reviews, and hardware-key requirements for administrators stop the quiet push that changes both the app and the check that should have caught it. The older lessons predate a lot of this. If you work on a product team, this lesson is closer to your daily risk than a wireless chapter.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

Which file answers “do we ship log4j 2.14?” fastest?

Go deeper

Specific techniques, exercises, and glossary cards for this topic.

  1. 01Pull requests from outside the trust boundaryCode from a fork or an untrusted branch is not your code yet. Includes the diagram and a defensive fix.
  2. 02Software supply-chain compromise: where builds get tampered withSupply-chain attacks target the path from source to shipped artifact: repositories, dependencies, build systems, and registries. Includes the diagram and a defensive fix.
  3. 03Dependency confusion: when a public package shadows a private oneIf a build can pull from public and private registries, a public package with your internal name and a higher version may win. Includes the diagram and a defensive fix.
  4. 04Typosquatted packages: one wrong letter in an install commandTyposquats copy popular package names with small changes to catch mistyped installs. Includes the diagram and a defensive fix.

Exercises

  1. 01Control benchA failure is on the table. Choose the control that changes the outcome.
  2. 02Terminal mission: A build change from someone not on the teamA release build began downloading a script at build time. Review the authors in recent history, find the commit from outside the team, and read exactly what it added to the Makefile.
  3. 03Terminal mission: A workflow that runs forks with secretsReview a repository’s GitHub Actions workflows. Find the one that checks out untrusted pull request code under pull_request_target, the secret it exposes, and the unpinned action.
  4. 04Terminal mission: Version 99 of an internal packageA build installed an internal Python package from the public index instead of the company one. Read pip.conf, the requirements, and the install log to see how and why.
  5. 05Terminal mission: One letter off, with an install scriptA developer added a dependency by hand. Compare package names with what the team normally uses, find the typosquat, and read the postinstall script it runs on every npm install.

Glossary

  1. 01Supply-chain compromiseA trusted dependency, build plugin, or vendor update carries a change you did not write.
  2. 02Dependency confusionA package manager pulls a public package whose name matches a private one, and the install runs that code.
  3. 03Typosquatted packagesA public package name is one character off a real one, and the install runs it.