Sub topic 3
What build provenance is and how SLSA frames it
This chapter explains what build provenance is, how the SLSA framework describes it, and what a BuildKit provenance attestation contains. It assumes you can write a Dockerfile, push images to a registry, and read JSON with jq. Later chapters cover how to generate and inspect attestations in detail. This chapter builds the working model that those chapters rely on.
The question provenance answers
An SBOM tells you what is inside an image. Provenance tells you how the image came to exist. It is a record of the build process: which source went in, which builder ran, which instructions it followed, and which inputs it used.
Consider an image registry.example.com/demo/app:1.0. You can ask several questions about it:
- Which Git repository and commit was it built from?
- Which Dockerfile was used?
- Which base image, by digest, did the build start from?
- Which build arguments were set?
- Which builder and which version of it ran the build?
Without provenance, the answers depend on team memory, CI logs that may have expired, or trust in whoever pushed the image. With provenance, the answers are attached to the image as structured data that tools can read.
Provenance helps in three common situations:
- Incident response. A vulnerable base image is announced. You can check which of your images were built from it, by digest, without guessing from tags.
- Reproducibility checks. You can compare the recorded inputs with what you expect, or rebuild from the recorded source.
- Policy enforcement. A deploy gate can require that images come from a trusted repository and a specific CI system.
SLSA in brief
SLSA (Supply-chain Levels for Software Artifacts, pronounced "salsa") is a security framework for build integrity. It defines a vocabulary and a set of levels for how trustworthy a build process is. Docker's provenance attestations use the SLSA provenance format, so SLSA terms appear directly in the output you will read.
SLSA separates two things that are easy to confuse:
- The provenance document describes a build.
- The build platform is the system that produces the document and is trusted to do so honestly.
A provenance document is only as trustworthy as the system that wrote it and the protection around it. This distinction matters later, when we discuss unsigned attestations.
The build track levels
The SLSA build track describes increasing guarantees. The exact wording is maintained by the SLSA project, so check the current specification for details. The overall shape is:
| Level | What it means in short |
|---|---|
| Build L0 | No guarantees. No provenance. |
| Build L1 | Provenance exists and shows how the artifact was built. It may be incomplete or forgeable. |
| Build L2 | The build runs on a hosted platform that signs the provenance, so it is harder to forge. |
| Build L3 | The platform also hardens the build, for example by isolating builds from each other and protecting signing keys from build steps. |
A BuildKit attestation by itself corresponds to the first step: it creates provenance. Reaching higher levels depends on where you run the build and whether the provenance is signed and protected. Do not claim a SLSA level from the --provenance flag alone.
Key terms in SLSA provenance
SLSA provenance uses a small set of terms. The table maps them to what you will see for a container build.
| SLSA term | Meaning | Example in a BuildKit build |
|---|---|---|
| Subject | The artifact the provenance describes. | The image manifest digest. |
| Builder | The system that ran the build. | BuildKit, identified by an ID and version. |
| Build type | The kind of build and how to interpret its parameters. | A Dockerfile build with BuildKit. |
| External parameters | Inputs controlled by the user. | Build arguments, target, frontend source. |
| Materials or resolved dependencies | Inputs the build actually fetched. | Base image digests, Git source. |
| Metadata | Timing and completeness details. | Start and finish times, reproducibility flag. |
Docker's attestation uses the SLSA provenance predicate. Depending on your Buildx and BuildKit versions, the document follows SLSA v0.2 or v1. Check the predicateType field in the output to see which one you have. Field names differ between versions. For example, v0.2 uses invocation and materials, while v1 uses buildDefinition and runDetails.
How the flow works
BuildKit records provenance while it solves the build graph. It sees every input it resolves, so it can describe them accurately. The attestation is then attached to the image.
The key point is that BuildKit produces the attestation as part of the same build that produces the image. The subject of the attestation is the digest of the image, so the two are tied together by content.
Generating provenance
You enable provenance with a flag on docker buildx build. Two forms exist. The first builds and pushes the image with an SBOM and maximum-detail provenance:
docker buildx build \
--sbom=true \
--provenance=mode=max \
--tag registry.example.com/demo/app:1.0 \
--push .The second uses --attest, which lets you set the type and options explicitly. Here provenance uses min mode:
docker buildx build \
--attest type=sbom \
--attest type=provenance,mode=min \
--tag registry.example.com/demo/app:1.0 \
--push .Both forms need a builder and an output that can store attestations. A later chapter covers driver and registry requirements. For now, note that pushing to a registry with --push is the most reliable way to get them.
Reading a provenance document
After a push, you can print the provenance from the registry:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .Provenance }}'The output is JSON. Pipe it through jq to explore it. The exact structure depends on the SLSA version and the mode. A trimmed example of what a v0.2 style document can look like:
{
"_type": "https://in-toto.io/Statement/v0.1",
"predicateType": "https://slsa.dev/provenance/v0.2",
"subject": [
{
"name": "pkg:docker/registry.example.com/demo/[email protected]?platform=linux%2Famd64",
"digest": { "sha256": "<image manifest digest>" }
}
],
"predicate": {
"builder": { "id": "" },
"buildType": "https://mobyproject.org/buildkit@v1",
"materials": [
{
"uri": "pkg:docker/[email protected]?platform=linux%2Famd64",
"digest": { "sha256": "<base image digest>" }
}
]
}
}The placeholders in angle brackets stand for real digests. Your output will contain more fields. Look for these parts first:
subjectnames the image the statement is about, by digest.predicateTypetells you which SLSA version you are reading.buildTypeshows that BuildKit produced the document.materials(v0.2) orresolvedDependencies(v1) lists the inputs, including base images pinned by digest.
Notice that the base image appears by digest even though the Dockerfile said FROM alpine:3.20. A tag can move, but the digest records what the build actually pulled. This is one of the most useful facts in the document.
What min and max add
The provenance mode controls how much detail is recorded.
| Mode | Content |
|---|---|
| `min` | Basic facts such as the build type, materials, and subject. It leaves out information about the build that could be sensitive. |
| `max` | Everything in `min`, plus detail such as the full build parameters, the Dockerfile source, and the build graph. |
Treat max carefully. It can record build arguments and details about your source layout. If a secret is passed as a build argument, it can end up in a provenance document that anyone with pull access can read. Use build secrets (--secret) for sensitive values instead of build arguments. A later chapter covers the choice between modes in more depth.
Disabling provenance
Some registries and consumers cannot handle the extra manifests that attestations add. You can turn provenance off for a build:
docker buildx build \
--provenance=false \
--tag demo/app:no-provenance \
--push .Disabling provenance removes the record described in this chapter, so do it only when you have a concrete compatibility reason.
What provenance does not prove
Provenance is a claim made by the builder. On its own it has limits:
- An unsigned document can be replaced or edited by anyone with write access to the registry repository.
- Provenance says what the builder recorded, not that the source code is safe.
- A compromised build environment can produce false but well-formed provenance.
- Fields such as the builder ID or source location are only meaningful if you know the platform that wrote them.
Provenance becomes strong evidence when it is combined with a trusted build platform, signing, and policy checks that compare the document against what you expect. Later chapters return to each of these.
Summary of the working model
- Provenance records how an image was built, while an SBOM records what it contains.
- SLSA supplies the vocabulary: subject, builder, build type, parameters, and materials.
- BuildKit writes the attestation during the build and ties it to the image digest.
minandmaxmodes trade detail against exposure of sensitive data.- Unsigned provenance is a starting point for trust, not proof.
Exercise
A Dockerfile starts with FROM alpine:3.20. After building with --provenance=mode=max and pushing, you read the provenance and find the base image listed with a sha256 digest. Why is the digest more useful than the tag for an investigation, and what is one risk of using max mode when a build takes a password through --build-arg?
Show answer
A tag such as alpine:3.20 can be re-pointed to different content over time, so it does not say which base image the build actually used. The digest identifies exactly the content that was pulled, so you can match it against a vulnerability announcement. The risk with max mode is that build arguments are recorded in the provenance, so the password can be exposed to anyone who can pull the image. Use --secret for sensitive values instead.
Exercise
Name two reasons why an unsigned provenance attestation does not by itself prove that an image is trustworthy.
Show answer
Any user with write access to the repository could replace or alter an unsigned attestation, and a compromised builder can emit well-formed but false provenance. Provenance also records how the build ran, not whether the source code is free of flaws.