Sub topic 9
Inspecting SBOM and provenance of a pushed image
This chapter shows how to read the SBOM and provenance attestations that an earlier build attached to a pushed image. It assumes you can run docker buildx build, push to a registry, and filter JSON with jq. It also assumes the image was built with --sbom=true and --provenance=mode=max (or --attest), as in the earlier chapters on enabling attestations.
Why inspect after pushing
Attestations live in the registry next to the image, not inside the image filesystem. Running the container will not show them. You need a tool that reads the image index and follows the links to the attestation manifests. Buildx provides this through docker buildx imagetools inspect.
Inspecting the pushed image checks what a consumer will actually receive. It confirms that:
- the attestations were pushed with the image
- the SBOM lists the packages you expect
- the provenance records the source, base image, and build parameters you expect
Where the data comes from
The command you push to a tag resolves to an image index. The index lists one image manifest per platform. It also lists one attestation manifest per platform. Each attestation manifest points to layers that hold in-toto statements (the SBOM and the provenance). The imagetools inspect command walks that structure and prints the parts you ask for.
Listing the index
Start with the plain form of the command. It prints the index and its manifests.
docker buildx imagetools inspect registry.example.com/demo/app:1.0For an image built with attestations, the output lists the usual platform manifests. It also lists extra entries with the platform unknown/unknown. Those entries are the attestation manifests. Each carries an annotation vnd.docker.reference.type: attestation-manifest and an annotation that names the image manifest it describes.
If you see no unknown/unknown entries, the attestations were not pushed. The usual causes are:
- the build ran without
--sbomor--provenance - the build was loaded to the local image store instead of being pushed
- a tool in your pipeline re-copied the image and dropped the extra manifests
Printing the SBOM
Use the --format flag with a Go template. The .SBOM field holds the parsed SBOM.
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .SBOM }}'The output is one JSON document. For a multi-platform image, the top-level keys are platform names such as linux/amd64. Under each platform you find an SPDX object, which is the SBOM in SPDX format. For a single-platform image, the platform level may be absent. Check the shape before you write filters:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .SBOM }}' | jq 'keys'Piping through jq . makes the document readable:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .SBOM }}' | jq .Reading the SPDX document
The SPDX document has document-level fields and a packages array. These are the fields you will use most:
| Field | Meaning |
|---|---|
| `spdxVersion` | The SPDX specification version, such as `SPDX-2.3` |
| `creationInfo` | When the document was created and by which tool |
| `packages[].name` | The package name, such as `curl` |
| `packages[].versionInfo` | The package version |
| `packages[].externalRefs` | Extra identifiers, usually a package URL (purl) |
| `relationships` | Links between packages and files, such as which package contains which file |
For the Alpine example from earlier, with curl installed through apk, list the detected packages like this. This version assumes the platform-keyed shape, so adjust the path if keys showed otherwise:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .SBOM }}' \
| jq -r '."linux/amd64".SPDX.packages[] | "\(.name)\t\(.versionInfo)"' \
| sortYou should see curl plus its dependencies (such as libcurl and openssl-related libraries) and the base Alpine packages. A package that appears here but that you did not intend to ship is a finding. Remove it from the Dockerfile and rebuild.
To search for one package, filter on the name:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .SBOM }}' \
| jq '."linux/amd64".SPDX.packages[] | select(.name == "curl")'Printing the provenance
The .Provenance field works the same way.
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .Provenance }}'The result holds a SLSA object per platform. That object is the SLSA provenance predicate. List the keys first, then read the parts you need:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .Provenance }}' | jq 'keys'docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .Provenance }}' \
| jq '."linux/amd64".SLSA | keys'Reading the provenance fields
The fields depend on the provenance mode used at build time.
| Field | In `min` mode | In `max` mode | What it tells you |
|---|---|---|---|
| `builder` | yes | yes | Which builder produced the image |
| `buildType` | yes | yes | The kind of build, which identifies the BuildKit format |
| `invocation.parameters` | yes | yes | Build arguments, frontend, and target, with values depending on mode |
| `materials` | yes | yes | Inputs such as the base image reference and digest |
| `metadata` | partial | full | Timestamps, completeness flags, and BuildKit-specific data |
| `buildConfig` | no | yes | The LLB build steps that ran |
| Dockerfile source | no | yes | The Dockerfile text and its source location |
The materials entry is the most useful for audits. It records the exact base image digest that the build resolved, not just the tag. Use it to answer "which Alpine build went into this image?" even after alpine:3.20 has moved on.
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .Provenance }}' \
| jq '."linux/amd64".SLSA.materials'Checking the subject digest
An attestation is only useful if it describes the image you think it does. Each in-toto statement has a subject that names an image manifest by digest. To compare, get the digest of the platform manifest you plan to deploy, then compare it with the digest named by the attestation manifest's annotation (vnd.docker.reference.digest) in the raw index:
docker buildx imagetools inspect registry.example.com/demo/app:1.0 --raw | jq .Compare by digest, never by tag. Tags can be moved after the attestations were created.
Common errors
.SBOMprintsnullor nothing. The image has no SBOM attestation, or your tool failed to find the attestation manifest for that platform. Check the index forunknown/unknownentries.- A jq path fails on a single-platform image. The platform level may be missing. Print
keysand adjust the path. - Attestations vanish after you copy the image. Some copy tools and registries copy only the platform manifests. Use a tool that copies the whole index, such as
docker buildx imagetools create. - You built locally and found nothing. The classic Docker image store cannot hold attestation manifests. Push to a registry, or use a builder and image store that support them.
- The SBOM seems incomplete. The scanner reads the final image filesystem and known package databases. Software copied in as a plain binary may not be detected. A later chapter covers this limit.
Practice run
This sequence builds, pushes, and verifies in one pass. It uses the placeholder registry from earlier chapters.
docker buildx build \
--sbom=true \
--provenance=mode=max \
--tag registry.example.com/demo/app:1.0 \
--push .
docker buildx imagetools inspect registry.example.com/demo/app:1.0
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .SBOM }}' | jq 'keys'
docker buildx imagetools inspect registry.example.com/demo/app:1.0 \
--format '{{ json .Provenance }}' | jq 'keys'Exercise
You push an image built with --sbom=true and --provenance=mode=max. Running docker buildx imagetools inspect on the tag shows the platform manifests but no unknown/unknown entries. Name two likely causes and one way to confirm which one applies.
Show answer
Likely causes: the build did not push the attestations (for example, it loaded into a local image store instead of using --push), or a copy step re-published only the platform manifests and dropped the attestation manifests. To confirm, rebuild with --push and the attestation flags, then inspect the new tag. If the unknown/unknown entries appear, the earlier build or copy step was at fault. Also check the registry copy path with imagetools inspect --raw on the source and the destination.
Exercise
You inspect the provenance of a published image and want to know which exact base image went into it. Which field do you read, and why not rely on the FROM line alone?
Show answer
Read the materials list in the SLSA provenance. It records the base image reference with its resolved digest. The FROM line has only a tag, such as alpine:3.20, and a tag can point to different content over time.