Sub topic 3
What build provenance is and how SLSA frames it
This chapter assumes you can write a Dockerfile, push an image to a registry, and read JSON with jq. It explains what provenance records and how the SLSA framework uses it. Later chapters cover how to generate and inspect it.
What provenance answers
An image digest tells you what the bytes are. It does not tell you where they came from. Build provenance is metadata that answers three questions about an artifact:
- Which source did it come from (repository, commit, Dockerfile)?
- Which build system produced it, and with what parameters?
- When and how did the build run?
A consumer can compare those answers with what they expect. If a deployment policy says "only run images built from main of our repository by our CI", provenance is the data that policy checks.
An SBOM and provenance are complementary. The SBOM describes the contents of the image. Provenance describes the process that made it.
SLSA in brief
SLSA (Supply-chain Levels for Software Artifacts, pronounced "salsa") is a framework that describes how trustworthy a build process is. It defines a provenance format and a set of build levels. Each level adds requirements about how the build runs and how the provenance is produced.
| Level | Rough meaning |
|---|---|
| Build L1 | Provenance exists and describes how the artifact was built. |
| Build L2 | A hosted build service generates and signs the provenance. |
| Build L3 | The build runs in a hardened, isolated environment, so one build cannot tamper with another's provenance. |
The level depends on the build platform and how you run it, not on a flag alone. BuildKit produces the provenance document, which is the L1 starting point. Higher levels need a trusted builder and signing, which later chapters discuss.
What a provenance document contains
BuildKit emits provenance as a SLSA provenance predicate. A predicate is the typed payload of an attestation, covered in the next chapter. The main parts are:
- Subject: the image digest the statement is about.
- Builder: the identity of the build system.
- Build definition: the entry point, such as the Dockerfile, and the build arguments.
- Materials: the inputs, such as the base image and its digest, and the source repository revision.
- Metadata: start and finish times, and whether the build was reproducible.
The flow below shows how these pieces relate.
A minimal example
Take the Dockerfile from this tutorial:
FROM alpine:3.20
RUN apk add --no-cache curl
CMD ["curl", "--version"]Building it with provenance enabled records alpine:3.20 as a material, resolved to its digest, so you can later see exactly which base image was used even though the tag may have moved.
docker buildx build \
--provenance=mode=max \
--tag registry.example.com/demo/app:1.0 \
--push .Provenance has two detail levels, min and max. The max mode records more, including build arguments and the full Dockerfile source. Chapter on provenance modes covers the trade-off.
Common mistakes
- Treating provenance as proof. Unsigned provenance is a claim made by the build, not a verified fact. Anyone who can write to the registry could attach a different document.
- Assuming a SLSA level. Generating provenance does not by itself give you L2 or L3.
- Putting secrets in build arguments. In
maxmode, build arguments are recorded. Use build secrets instead of--build-argfor sensitive values.
Exercise
Why does a provenance attestation list the base image by digest and not only by tag, and why does that matter?
Show answer
A tag such as alpine:3.20 can be moved to point at a different image later. The digest identifies the exact content that was used. Recording the digest lets a consumer verify which base image went into the build, even after the tag changes.