Sub topic 8
How attestations are stored next to the image
This chapter explains where BuildKit puts the SBOM and provenance attestations once a build finishes, and why that placement affects tags, digests, registries, and the tools that consume your images. It assumes you can read JSON with jq, know the difference between a tag and a digest, and have pushed a multi-platform image before.
The image index is the container
A registry stores an image as a tree of content-addressed objects. A tag points to a digest. That digest is either a single image manifest or an image index. An image index (also called a manifest list) is a JSON document that lists several manifests, usually one per platform.
BuildKit stores attestations as extra manifests in that same index. It does not use a separate repository, a separate tag, or a sidecar file. When you build with --sbom=true or --provenance=mode=max and push, the tag you pushed points to an index. The index lists:
- one image manifest for each platform you built
- one attestation manifest for each of those image manifests
A build for a single platform with attestations enabled therefore still produces an index, with two entries instead of one.
Anatomy of the index
Run the build from the previous chapter, then fetch the raw index. The --raw flag prints the manifest bytes exactly as the registry stores them.
docker buildx imagetools inspect registry.example.com/demo/app:1.0 --raw | jq .A trimmed result for a one-platform build looks like this. The digests are placeholders.
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.index.v1+json",
"manifests": [
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:1111111111111111111111111111111111111111111111111111111111111111",
"size": 1054,
"platform": { "architecture": "amd64", "os": "linux" }
},
{
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"digest": "sha256:2222222222222222222222222222222222222222222222222222222222222222",
"size": 566,
"annotations": {
"vnd.docker.reference.digest": "sha256:1111111111111111111111111111111111111111111111111111111111111111",
"vnd.docker.reference.type": "attestation-manifest"
},
"platform": { "architecture": "unknown", "os": "unknown" }
}
]
}Three details identify the attestation entry:
- Platform
unknown/unknown. No runtime can use this entry, so it is never selected when you pull or run the image. Runtimes match the platform of the host and skip it. vnd.docker.reference.type: attestation-manifest. This annotation marks the entry as an attestation and not an image.vnd.docker.reference.digest. This is the link from attestation to subject. It holds the digest of the image manifest the attestation describes.
The link is a field inside the index, not something in the image manifest. The image manifest does not know it has attestations.
Inside an attestation manifest
The attestation manifest is an ordinary OCI image manifest whose layers are not filesystem layers. Each layer is one in-toto statement stored as a JSON blob. Fetch it by digest, using the digest of the unknown/unknown entry.
docker buildx imagetools inspect \
registry.example.com/demo/app@sha256:2222222222222222222222222222222222222222222222222222222222222222 \
--raw | jq .The result has the usual config and layers keys. The interesting parts are in layers:
{
"schemaVersion": 2,
"mediaType": "application/vnd.oci.image.manifest.v1+json",
"layers": [
{
"mediaType": "application/vnd.in-toto+json",
"digest": "sha256:3333333333333333333333333333333333333333333333333333333333333333",
"size": 48210,
"annotations": {
"in-toto.io/predicate-type": "https://spdx.dev/Document"
}
},
{
"mediaType": "application/vnd.in-toto+json",
"digest": "sha256:4444444444444444444444444444444444444444444444444444444444444444",
"size": 9120,
"annotations": {
"in-toto.io/predicate-type": "https://slsa.dev/provenance/v0.2"
}
}
]
}| Field | Meaning |
|---|---|
| `mediaType: application/vnd.in-toto+json` | The blob is an in-toto statement, the envelope described earlier in the tutorial. |
| `in-toto.io/predicate-type` | Names the kind of predicate inside. SPDX documents use `https://spdx.dev/Document`. Provenance uses a SLSA URI, whose version depends on your BuildKit release. |
| Layer count | One layer per attestation type you enabled. SBOM only gives one layer. SBOM plus provenance gives two. |
Each blob is a statement whose subject lists the image manifest digest and whose predicate holds the SBOM or provenance data. The statement is stored as plain JSON. Nothing signs it at this point.
To list only the attestation entries of an index, filter on the annotation:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 --raw \
| jq '.manifests[]
| select(.annotations["vnd.docker.reference.type"] == "attestation-manifest")
| {digest, subject: .annotations["vnd.docker.reference.digest"]}'Multi-platform builds
With several platforms, the index grows by one attestation manifest per platform image. Each attestation describes only its own platform, since the SBOM of the arm64 build can differ from the amd64 one.
| Build | Entries in the index |
|---|---|
| `linux/amd64`, no attestations | 1 image manifest (no index is required) |
| `linux/amd64`, SBOM and provenance | 1 image manifest, 1 attestation manifest |
| `linux/amd64,linux/arm64`, SBOM and provenance | 2 image manifests, 2 attestation manifests |
The SBOM and provenance of one platform share a single attestation manifest, so adding provenance to an SBOM build adds a layer and not a manifest.
Consequences you will notice
Because the attestations live in the index, several behaviors follow from the layout.
The tag's digest changes
Before attestations, a single-platform build pushed an image manifest and the tag pointed straight at it. Now the tag points at an index, which has a different digest. The image manifest, its config, and its layers keep the same digests they would have had. Anything that pins the tag's digest, such as a deployment manifest, sees a new value after you turn attestations on.
Pulling and running ignore them
docker pull and docker run resolve the index to the manifest that matches the host platform. They never download the attestation blobs. Attestations cost registry storage but add no pull time or runtime size.
The attestations are tied to one build
Provenance describes how a specific build ran. If you retag the image or copy the whole index to another registry with a tool that preserves indexes, the attestations travel with it. If a tool copies only the matching platform manifest, the attestations are dropped silently. Verify the destination with the inspect command after any copy.
Some consumers cannot handle the index
Some registries, orchestrators, and image-handling tools assume an index contains only runnable platforms. They may reject the unknown/unknown entry or fail to list the image. The usual symptoms are an error about an unsupported manifest or a tag that appears with an extra untagged entry. The workaround is to build without provenance for those targets, as shown in the earlier --provenance=false example, or to push attestations only to a registry that supports them.
Where attestations go with other exporters
Pushing to a registry is the common case, but other output types behave differently.
--loadwith the classic Docker image store. The classic store holds single-platform images and cannot represent an index, so the attestations cannot be kept. With the containerd image store enabled in Docker Engine,--loadkeeps the index and its attestations.--output type=oci,dest=image.tar. The OCI layout tarball contains the full index, including attestation manifests and their blobs.--output type=local,dest=out. This writes a filesystem and no image. The attestation statements are written as files in the output directory instead of as manifests.
If you plan to inspect attestations in CI, push to a registry or write an OCI layout. Those are the two outputs that keep the manifest structure intact.
How this differs from referrers and sidecar tags
Other tooling attaches signatures and attestations to an image after the build, either as extra tags named after the image digest or through the OCI referrers API. In that model the attestation is a separate artifact that points at the image.
BuildKit's model is reversed. The index points at both. The advantage is that the attestation is created in the same push as the image and needs no later step. The cost is that the index digest changes and that consumers must understand the layout. Signing tools, covered in a later chapter, can still attach signatures to the index digest or to the attestation manifest using either mechanism.
Exercise
You build a two-platform image (linux/amd64 and linux/arm64) with --sbom=true --provenance=mode=max and push it. How many entries does the image index list, and how do you tell which attestation manifest belongs to which platform image?
Show answer
Four entries: two image manifests and two attestation manifests. Each attestation manifest has platform unknown/unknown and the annotation vnd.docker.reference.type: attestation-manifest. Its annotation vnd.docker.reference.digest holds the digest of the image manifest it describes, so you match that digest to the digest of the amd64 or arm64 entry.
Exercise
After enabling provenance, your deployment pipeline reports that the digest of app:1.0 changed, although the Dockerfile and sources are identical. Why did this happen, and which digests did not change?
Show answer
The tag now points to an image index that includes the attestation manifest, and the index has a different digest from the bare image manifest it replaced. The image manifest, config, and layer digests for each platform are unchanged, so the runnable content is the same.
Exercise
Write a command that prints the digest of each attestation manifest in registry.example.com/demo/app:1.0 together with the image manifest digest it describes.
Show answer
docker buildx imagetools inspect registry.example.com/demo/app:1.0 --raw | jq '.manifests[] | select(.annotations["vnd.docker.reference.type"] == "attestation-manifest") | {digest, subject: .annotations["vnd.docker.reference.digest"]}'