Build attestations (original) (raw)
Build attestations describe how an image was built, and what it contains. The attestations are created at build-time by BuildKit, and become attached to the final image as metadata.
The purpose of attestations is to make it possible to inspect an image and see where it comes from, who created it and how, and what it contains. This enables you to make informed decisions about how an image impacts the supply chain security of your application. It also enables the use of policy engines for validating images based on policy rules you've defined.
Two types of build annotations are available:
- Software Bill of Material (SBOM): list of software artifacts that an image contains, or that were used to build the image.
- Provenance: how an image was built.
The use of open source and third-party packages is more widespread than ever before. Developers share and reuse code because it helps increase productivity, allowing teams to create better products, faster.
Importing and using code created elsewhere without vetting it introduces a severe security risk. Even if you do review the software that you consume, new zero-day vulnerabilities are frequently discovered, requiring development teams take action to remediate them.
Build attestations make it easier to see the contents of an image, and where it comes from. Use attestations to analyze and decide whether to use an image, or to see if images you are already using are exposed to vulnerabilities.
When you build an image with docker buildx build
, you can add attestation records to the resulting image using the --provenance
and --sbom
options. You can opt in to add either the SBOM or provenance attestation type, or both.
The default image store doesn't support attestations. If you're using the default image store and you build an image using the default
docker
driver, or using a different driver with the--load
flag, the attestations are lost.To make sure the attestations are preserved, you can:
- Use a
docker-container
driver with the--push
flag to push the image to a registry directly.- Enable thecontainerd image store.
Provenance attestations are enabled by default, with the
mode=min
option. You can disable provenance attestations using the--provenance=false
flag, or by setting theBUILDX_NO_DEFAULT_ATTESTATIONS environment variable.Using the
--provenance=true
flag attaches provenance attestations withmode=min
by default. See Provenance attestation for more details.
BuildKit generates the attestations when building the image. The attestation records are wrapped in the in-toto JSON format and attached to the image index in a manifest for the final image.
BuildKit produces attestations in the in-toto format, as defined by the in-toto framework, a standard supported by the Linux Foundation.
Attestations attach to images as a manifest in the image index. The data records of the attestations are stored as JSON blobs.
Because attestations attach to images as a manifest, it means that you can inspect the attestations for any image in a registry without having to pull the whole image.
All BuildKit exporters support attestations. The local
and tar
can't save the attestations to an image manifest, since it's outputting a directory of files or a tarball, not an image. Instead, these exporters write the attestations to one or more JSON files in the root directory of the export.
The following example shows a truncated in-toto JSON representation of an SBOM attestation.
To deep-dive into the specifics about how attestations are stored, seeImage Attestation Storage (BuildKit).
Attestations are stored as manifests, referenced by the image's index. Each_attestation manifest_ refers to a single image manifest (one platform-variant of the image). Attestation manifests contain a single layer, the "value" of the attestation.
The following example shows the structure of an attestation manifest:
Attestations as OCI artifacts
You can configure the format of the attestation manifest using theoci-artifact optionfor the image
and registry
exporters. If set to true
, the structure of the attestation manifest changes as follows:
- An
artifactType
field is added to the attestation manifest, with a value ofapplication/vnd.docker.attestation.manifest.v1+json
. - The
config
field is an empty descriptor instead of a "dummy" config. - A
subject
field is also added, pointing to the image manifest that the attestation refers to.
The following example shows an attestation with the OCI artifact format:
Learn more about the available attestation types and how to use them: