Sub topic 8
How attestations are stored next to the image
This chapter assumes you can read JSON with jq, and that you know how a manifest, a digest and a multi-platform image index relate. You should also have pushed an image with --sbom=true or --provenance=mode=max as shown in the previous chapter.
The image index carries the attestations
BuildKit does not add a separate artifact or a registry tag for attestations. It stores them in the same OCI image index that lists the platform images. When you build with attestations enabled, the tag points to an index, even for a single-platform build. Each attestation lives in its own manifest, next to the image manifest it describes.
What an attestation manifest looks like
You can see the structure by reading the raw index:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 --raw \
| jq '.manifests[] | {digest, platform, annotations}'The output has two kinds of entries. The first is the normal image manifest, with a platform such as linux/amd64. The second is the attestation manifest. It is recognizable by these properties:
- Platform. It is
unknown/unknown, so runtimes skip it when choosing an image to run. - Annotation
vnd.docker.reference.type. Its value isattestation-manifest. - Annotation
vnd.docker.reference.digest. It holds the digest of the image manifest that the attestation describes.
The link goes from the attestation to the image, not the other way around. With a multi-platform build, the index contains one attestation manifest for each platform manifest.
Each attestation manifest is a small OCI manifest. Each of its layers is one in-toto statement. A layer has the media type application/vnd.in-toto+json and an annotation in-toto.io/predicate-type. That annotation tells you what kind of statement it is:
| Predicate type | Content |
|---|---|
| `https://spdx.dev/Document` | The SBOM, in SPDX format |
| `https://slsa.dev/provenance/v0.2` | The SLSA provenance. Newer builds can use a later version, such as `v1`. |
Each statement names the image manifest digest as its subject. A signing or verification tool can therefore tie the statement to exactly one image.
Walking from the tag to a statement
To read the statements yourself, follow the references by hand. The imagetools formats you used earlier do this for you. This sketch shows what happens underneath:
IMAGE=registry.example.com/demo/app
# 1. Find the attestation manifest digest in the index
ATT=$(docker buildx imagetools inspect "$IMAGE:1.0" --raw \
| jq -r '.manifests[]
| select(.annotations["vnd.docker.reference.type"] == "attestation-manifest")
| .digest' | head -n 1)
# 2. List its layers and their predicate types
docker buildx imagetools inspect "$IMAGE@$ATT" --raw \
| jq '.layers[] | {digest, type: .annotations["in-toto.io/predicate-type"]}'Each layer digest is a blob in the same repository. You can fetch it from the registry's blob endpoint to get the statement JSON.
Consequences of this design
- The tag digest changes. The tag now resolves to an index digest, not an image manifest digest. Pipelines that pin or compare digests need to expect this.
- No extra tags to manage. The attestations are pushed and deleted with the index, and they are copied with it by tools that copy whole indexes.
- Consumers must understand indexes. The registry must accept OCI indexes and the attestation media types. Tools that assume every index entry is a runnable platform may show
unknown/unknownentries, or fail on them. This is the usual reason to use--provenance=false, as in an earlier example. - Local image stores may not hold them. An image loaded into a store that supports only single manifests cannot keep the attestation manifests. Push to a registry, or export to an OCI layout, to keep them.
Exercise
A build for linux/amd64 and linux/arm64 pushes with --sbom=true and --provenance=mode=max. How many manifests does the index list, and how can you tell which attestation belongs to which platform image?
Show answer
The index lists six manifests: two image manifests, and one SBOM and one provenance attestation for each platform. The attestation manifests have platform unknown/unknown. Each one has a vnd.docker.reference.digest annotation holding the digest of the image manifest it describes. Wait, SBOM and provenance share one attestation manifest per platform, as separate layers. So the correct count is four manifests: two image manifests and two attestation manifests, each with an SBOM layer and a provenance layer.