Securing the pipeline and the supply chain

Advanced · 43 min

Prove what you ship: an SBOM of every dependency, signed provenance tying the artifact to its build, and a deploy step that refuses anything unsigned.

Before thisRegistries, tags and image provenanceBuild artifacts and artifact repositoriesAnatomy of a pipeline: stages, jobs and gates

NDC Conferences · 43 min

Securing the pipeline and the supply chain

The player loads from youtube-nocookie.com when you press play. Nothing reaches YouTube before that.

Taught by NDC ConferencesReport a problem with this video
Not started
Set this lesson's status

What you'll learn

  • The supply chain is every step between a developer's commit and production: source, dependencies, build system, artifact storage and deploy. An attacker only needs the weakest one.
  • An SBOM (software bill of materials) lists every component inside an artifact with versions and identifiers, so when a vulnerability is announced you can answer 'are we affected?' in minutes.
  • Provenance is a signed statement of what was built, from which source commit, by which builder. Signing it ties the artifact's digest to a trusted build.
  • Sigstore's cosign can sign without long-lived keys, using the CI job's OIDC identity and a public transparency log, and the verifier checks who signed rather than which key.
  • Verification has to be enforced at deploy time, by an admission policy or a pipeline gate, or signing changes nothing.

The problem: you ship code you didn’t write, built on machines you don’t watch

A typical web service has a few thousand lines of its own code and hundreds of third-party packages. It is built by a CI runner, pushed to a registry and pulled by a deploy system. Every one of those steps is a place where something can be swapped. Real attacks have hit each one: a hijacked package maintainer account, a typo-squatted package name, a compromised build server injecting code into signed releases, a backdoor slipped into a compression library over two years of patient contribution.

That chain from commit to production is the software supply chain. Securing it comes down to three questions you should be able to answer for any artifact in production: what is in it, where did it come from, and has it changed since?

GitHub-specific hardening, such as pinning actions and limiting token permissions, is in the git-github roadmap’s hardening your workflows and Dependabot lessons. This lesson is the tool-neutral layer on top.

What is in it: SBOMs

A software bill of materials lists every component in an artifact: name, version, a package URL (purl) that identifies it across ecosystems, and hashes. The two standard formats are CycloneDX and SPDX. Tools such as Syft (v1.57.2 when I checked) or Trivy generate them from images or source trees, and registries can store them next to the image.

The payoff comes on the day a vulnerability is announced. With SBOMs stored for every deployed artifact, “are we affected?” becomes a search.

A worked example: an SBOM from a lockfile

I don’t have Syft here, so I built a simplified CycloneDX-shaped SBOM straight from a real npm lockfile, the one for this website’s own build, with a short jq program. For each package it records name, version, purl, whether it is a dev dependency, and npm’s integrity hash. I generated it with jq -f sbom.jq package-lock.json > sbom.json, then ran a few jq queries over the result:

components: 430
runtime (non-dev): 277
names with more than one version: 15
{"purl":"pkg:npm/yaml@2.9.1","scope":"required","integrity":"sha512-3NxN8+78OdzbT7C/WjGsyfP"}
{"purl":"pkg:npm/yaml@2.8.3","scope":"excluded","integrity":"sha512-AvbaCLOO2Otw/lW5bmh9d/W"}

430 packages for a static site, and 15 package names appear at two different versions at once, including yaml. A scanner has to check both. Then I checked that one integrity hash really matches what the registry serves, by downloading the tarball and hashing it:

$ curl -s -o yaml-2.9.1.tgz https://registry.npmjs.org/yaml/-/yaml-2.9.1.tgz
$ echo "sha512-$(openssl dgst -sha512 -binary yaml-2.9.1.tgz | openssl base64 -A)" | cut -c1-40
sha512-3NxN8+78OdzbT7C/WjGsyfPAtJaN3FNDs

It matched the lockfile. That check is what npm ci does for every package. A real SBOM tool reads the built artifact rather than the lockfile and fills in far more fields, such as licences, suppliers and file hashes.

Where it came from: signed provenance

Provenance is a statement about how an artifact was made: its digest, the source commit, the builder, the build command. SLSA (Supply-chain Levels for Software Artifacts) grades build integrity in levels. Build L1 means provenance exists. L2 means it is signed by a hosted build platform. L3 means the build runs hardened and isolated, so even a malicious build step can’t forge it.

To see why the signature matters, I played both builder and attacker with OpenSSL. The build writes provenance.json with the tarball’s SHA-256 and signs it with an Ed25519 key. The deploy step checks the digest and the signature:

== verify at deploy time
8a7909ef8964f689
8a7909ef8964f689
Signature Verified Successfully
== attacker swaps app.js and rebuilds the tarball
d089da8e924f857a
== attacker also edits the digest in the provenance
...:error:030000EA:digital envelope routines:EVP_DigestVerify:provider signature failure:...
Signature Verification Failure

Swapping a file changes the digest, so the first check fails. Editing the digest in the provenance to match breaks the signature. Without the signing key, the attacker is stuck. That is the whole idea, at toy scale.

The real tools

In practice the keys are the weak point, since a signing key on a CI server is one more secret to steal. Sigstore removes it. cosign (v3.1.6 when I checked) can sign “keylessly”: the CI job proves its identity with OIDC, the same mechanism as deploying with OIDC, receives a short-lived certificate, and the signature is recorded in the public Rekor transparency log. The verifier then checks who signed, such as “this repository’s release workflow on main”, not which key. I could not run these here, since cosign isn’t installed and there is no registry to sign into. The shape, from the cosign docs:

cosign sign --yes registry.example.com/shop-web@sha256:<digest>
cosign verify registry.example.com/shop-web@sha256:<digest> \
  --certificate-identity-regexp 'https://github.com/acme/shop-web/.github/workflows/release.yml@.*' \
  --certificate-oidc-issuer https://token.actions.githubusercontent.com

Note the digest, not a tag. Tags move, and digests don’t, as the registries lesson explains. GitHub’s actions/attest-build-provenance and GitLab’s built-in provenance produce SLSA provenance the same way.

Enforce it, or it doesn’t count

Signing only helps if something refuses unsigned artifacts. In Kubernetes, an admission policy (Kyverno, OPA Gatekeeper or Sigstore’s policy-controller) can reject any pod whose image lacks a valid signature from your release workflow. Outside Kubernetes, make verification a pipeline gate before deploy. Add dependency scanning on the SBOM, pinned dependencies and base images, and least-privilege CI credentials, and the cheap attacks stop working.

About the video

“SLSA, SigStore, SBOM & Software Supply Chain Security. What does it all mean?” is a talk by Abdel Sghiouar, recorded at NDC’s Copenhagen Developer’s Festival and published November 2023, 43 minutes 3 seconds. The abstract says it clarifies those terms and surveys the tools and methods organizations use to secure software from development to production. That matches this lesson’s three pillars. It has no chapters, and tool versions have moved on since 2023. English is judged from the title, description and channel. OpenSSF’s three-minute SLSA spotlight and the SLSA specification are linked below.

Where this fits

You can now trust what you deploy. The next question is whether you can get it back after losing it: backups, disaster recovery, RPO and RTO.

Check yourself

  1. 01A critical vulnerability is announced in a logging library. How does an SBOM help?

    You search the SBOMs of everything you have deployed for that package and version range, instead of rebuilding or inspecting each service by hand.

  2. 02An attacker replaces a file in a built artifact and updates the digest in the provenance. Why does deployment still fail?

    The provenance is signed. Changing its digest breaks the signature, and the attacker cannot produce a new valid signature without the builder's key or identity.

  3. 03What does SLSA describe?

    A set of levels for build integrity, from simply producing provenance, through signed provenance from a hosted build platform, to hardened builds that resist tampering even by other tenants or the project's own maintainers.

  4. 04Why is 'keyless' signing with Sigstore attractive for CI?

    There is no long-lived private key to store and leak. The CI job proves its identity with OIDC, gets a short-lived certificate, and the signature is recorded in a public transparency log.

Go deeper

Notes

Private to you

Esc
↑↓ navigate↵ open? shortcuts

Keyboard shortcuts

Press Esc to close

Anywhere

⌘K
Search and commands
/
Search
?
This sheet
Esc
Close

Reading a lesson

J
Next lesson
K
Previous lesson
B
Bookmark