Sub topic 1
Why image supply chain metadata matters
A container image is a pile of files that you trust enough to run in production. This chapter explains why the image alone is not enough to justify that trust, and which two kinds of metadata fill the gap: the Software Bill of Materials (SBOM) and build provenance. Later chapters cover how to generate, store, inspect and verify them with BuildKit and Docker Buildx.
Prerequisites
This chapter assumes you can do the following:
- Write a basic Dockerfile and run
docker build. - Push an image to a container registry.
- Read image tags and digests, and know that a multi-platform image is a set of per-platform images behind one tag.
- Read JSON on the command line, for example with
jq.
You do not need prior knowledge of SLSA, in-toto or signing. Those terms are introduced as they come up.
The problem: an image digest says little
A digest such as sha256:3f1c... identifies exact bytes. If two images have the same digest, they are the same image. That is useful for integrity, but it answers very few of the questions a security or release team asks:
- Which packages and libraries are inside this image, and at which versions?
- Which source commit and which Dockerfile produced it?
- Was it built by your CI system, or pushed from a laptop?
- Which base image did it start from, and was that base image the one you expected?
Without answers, you work from guesses. When a new vulnerability is announced, you cannot tell which of your running images contain the affected library. When an image behaves strangely, you cannot tell how it was built.
Supply chain incidents that shaped the field
Three well-known events show why this metadata is now expected.
- SolarWinds (2020). Attackers modified the build process of a commercial product so that signed, official releases carried a backdoor. The source code in the repository looked normal. The problem was in the build.
- Log4Shell (December 2021). A critical flaw in the Java logging library Log4j was disclosed. The library was often bundled deep inside other software. Many teams spent days finding out whether they used it at all.
- The xz backdoor (2024, CVE-2024-3094). A maintainer of the xz compression library was impersonated over time, and malicious code was added to release tarballs. The code was caught by chance, before it reached most stable distributions.
The first and third cases are about how software is built and delivered. The second is about knowing what you ship. These two concerns map onto the two kinds of metadata this tutorial covers.
Two questions, two documents
| Question | Document | What it records |
|---|---|---|
| What is inside the image? | SBOM | Packages, libraries, versions, licenses and identifiers for each component |
| How was the image made? | Provenance | Source repository and commit, builder, build arguments, base images, timestamps |
An SBOM is an inventory, much like an ingredients list. You can feed it to a vulnerability scanner or a license checker later, without pulling and unpacking the image again. Provenance is a build record. It lets a consumer ask whether an artifact came from the expected source and pipeline.
The two documents are complementary. An SBOM can be accurate while the image was built from tampered source. Provenance can show a clean pipeline while the SBOM reveals a vulnerable dependency.
Where the metadata comes from, and why timing matters
You could produce this information after the fact. A scanner can unpack a finished image and guess at what is inside. That works, but it has limits:
- The scanner sees only the final filesystem. It cannot see what happened in earlier build stages, which build arguments were used, or which commit was checked out.
- Each consumer repeats the work, and different scanners can disagree.
- Information about the build itself is gone once the build finishes.
BuildKit, the build engine behind docker build and Docker Buildx, runs the build, so it knows the inputs while they are used. It can record them at build time and attach the result to the image. That is the idea behind BuildKit attestations. An attestation is a statement about an artifact, for example "this image contains these packages" or "this image was built from this commit by this builder."
The shape of the solution
The attestations are produced as part of the build and stored in the registry next to the image, so they travel with it. In the simplest case, you ask for them with flags on the build command:
docker buildx build \
--sbom=true \
--provenance=mode=max \
--tag registry.example.com/demo/app:1.0 \
--push .You do not need to understand every flag yet. Chapter by chapter, you will learn what --sbom scans, what the provenance modes min and max contain, and why --push matters. For now, notice the workflow:
The consumer in the last box can be a vulnerability scanner, an admission controller in a Kubernetes cluster, an auditor, or you at three in the morning during an incident.
What this buys you in practice
Concrete uses of the metadata include:
- Fast impact analysis. When a new CVE appears, you search stored SBOMs for the affected package and version instead of re-scanning every image.
- License review. The SBOM lists the licenses of bundled components, so legal checks can run before release.
- Build auditing. Provenance shows the source commit and the builder. If an image in production has no provenance, or provenance that points to an unknown repository, that is a signal worth investigating.
- Policy enforcement. A deploy pipeline can refuse images that lack an SBOM or whose provenance does not name your CI system.
- Compliance. Regulations and customer contracts increasingly ask for an SBOM. In the United States, Executive Order 14028 (2021) pushed federal suppliers in this direction, and the EU Cyber Resilience Act has similar aims.
A first look at the vocabulary
You will meet these terms throughout the tutorial. Short definitions now, with detail in later chapters:
- SBOM. A machine-readable list of the components in a piece of software. BuildKit produces it in the SPDX format by default.
- Provenance. A record of how an artifact was built. BuildKit emits provenance that follows the SLSA provenance format.
- SLSA. Supply-chain Levels for Software Artifacts, a framework that describes increasing levels of build integrity, from basic documentation to hardened, tamper-resistant builds.
- Attestation. A statement about an artifact, wrapped in a standard envelope. BuildKit uses the in-toto attestation format.
- Predicate. The type-specific content of an attestation, such as the SBOM or the provenance data.
What metadata does not do
Be careful about what you claim. Metadata generated during a build is evidence, and its value depends on who can alter it.
Three limits are worth remembering from the start:
- Detection is imperfect. An SBOM scanner finds components it knows how to recognize, such as OS packages and many language ecosystems. A statically linked binary or a file copied in by hand may not be listed.
- Provenance can contain sensitive data. Build arguments, source URLs and file paths may reveal things you did not intend to publish. The
minandmaxmodes exist partly for this reason. - Unsigned is not verified. Generating attestations is the first step. Cryptographic signing and policy checks, which come near the end of this tutorial, turn recorded facts into verified trust.
How the rest of the tutorial is organized
The next chapters cover the SBOM and provenance in depth, then the in-toto envelope that wraps them. After that you will enable attestations with Buildx, check builder and registry support, look at how attestations sit in the image index, and inspect them. Later chapters cover provenance modes, the scanner's blind spots, scanning intermediate stages, signing, and the trust model.
If you want a quick preview of the end result, this is the kind of command you will use to read the metadata from a pushed image:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .SBOM }}' | jq .Do not worry about the output yet. The goal for this chapter is to understand why the output exists.
Exercise
An image is deployed in production. A new vulnerability is announced in a library, and you must find out which of your images contain it. Name the document that answers this most directly, and explain why a stored copy is better than re-scanning each image. Then name the document you would use to check that the image came from your CI pipeline.
Show answer
The SBOM answers it, because it lists every component and version in the image. A stored SBOM can be searched without pulling and unpacking each image, and it was created at build time, so it can include information a post-hoc scan of the final filesystem may miss. To check that the image came from your CI pipeline, use the provenance, which records the source, the builder and the build parameters.
Exercise
A teammate says, "Our images have SBOM and provenance attestations, so they are secure." Give two reasons this conclusion is not justified.
Show answer
Any two of the following. The attestations are unsigned, so someone with registry write access could replace the image and its attestations together. An SBOM only lists components and does not say whether they are vulnerable or safe. Provenance records how the build ran, and a clean pipeline can still build malicious or flawed source. The SBOM scanner can miss components, such as statically linked or manually copied files, so the list may be incomplete.