Artifact attestations enable you to increase the supply chain security of your builds by establishing where and how your software was built.
Before you start generating artifact attestations, you need to understand what they are and when you should use them. See Artifact attestations.
You can use GitHub Actions to generate artifact attestations that establish build provenance for artifacts such as binaries and container images.
To generate an artifact attestation, you must:
attest action.When you run your updated workflows, they will build your artifacts and generate an artifact attestation that establishes build provenance. You can view attestations in your repository's Actions tab. For more information, see the attest repository.
In the workflow that builds the binary you would like to attest, add the following permissions.
permissions:
id-token: write
contents: read
attestations: write
After the step where the binary has been built, add the following step.
- name: Generate artifact attestation
uses: actions/attest@v4
with:
subject-path: 'PATH/TO/ARTIFACT'
The value of the subject-path parameter should be set to the path to the binary you want to attest.
In the workflow that builds the container image you would like to attest, add the following permissions.
permissions:
id-token: write
contents: read
attestations: write
packages: write
After the step where the image has been built, add the following step.
- name: Generate artifact attestation
uses: actions/attest@v4
with:
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
subject-digest: 'sha256:fedcba0...'
push-to-registry: true
The value of the subject-name parameter should specify the fully-qualified image name. For example, ghcr.io/user/app or acme.azurecr.io/user/app. Do not include a tag as part of the image name.
The value of the subject-digest parameter should be set to the SHA256 digest of the subject for the attestation, in the form sha256:HEX_DIGEST. If your workflow uses docker/build-push-action, you can use the digest output from that step to supply the value. For more information on using outputs, see Workflow syntax for GitHub Actions.
You can generate signed SBOM attestations for workflow artifacts.
To generate an attestation for an SBOM, you must:
anchore-sbom-action in the GitHub Marketplace.attest action with the sbom-path input.When you run your updated workflows, they will build your artifacts and generate an SBOM attestation. You can view attestations in your repository's Actions tab. For more information, see the attest repository.
In the workflow that builds the binary you would like to attest, add the following permissions.
permissions:
id-token: write
contents: read
attestations: write
After the step where the binary has been built, add the following step.
- name: Generate SBOM attestation
uses: actions/attest@v4
with:
subject-path: 'PATH/TO/ARTIFACT'
sbom-path: 'PATH/TO/SBOM'
The value of the subject-path parameter should be set to the path of the binary the SBOM describes. The value of the sbom-path parameter should be set to the path of the SBOM file you generated.
In the workflow that builds the container image you would like to attest, add the following permissions.
permissions:
id-token: write
contents: read
attestations: write
packages: write
After the step where the image has been built, add the following step.
- name: Generate SBOM attestation
uses: actions/attest@v4
with:
subject-name: ${{ env.REGISTRY }}/PATH/TO/IMAGE
subject-digest: 'sha256:fedcba0...'
sbom-path: 'sbom.json'
push-to-registry: true
The value of the subject-name parameter should specify the fully-qualified image name. For example, ghcr.io/user/app or acme.azurecr.io/user/app. Do not include a tag as part of the image name.
The value of the subject-digest parameter should be set to the SHA256 digest of the subject for the attestation, in the form sha256:HEX_DIGEST. If your workflow uses docker/build-push-action, you can use the digest output from that step to supply the value. For more information on using outputs, see Workflow syntax for GitHub Actions.
The value of the sbom-path parameter should be set to the path to the JSON-formatted SBOM file you want to attest.
We recommend uploading attested assets to your organization's linked artifacts page. This page displays artifacts' build history, deployment records, and storage details. You can use this data to prioritize security alerts or quickly connect vulnerable artifacts to their owning team, source code, and build run. For more information, see About linked artifacts.
The attest action automatically creates storage records on the linked artifacts page if both:
push-to-registry option is set to true
artifact-metadata: write permissionFor an example workflow, see Uploading storage and deployment data to the linked artifacts page.
You can validate artifact attestations for binaries and container images and validate SBOM attestations using the GitHub CLI. For more information, see the attestation section of the GitHub CLI manual.
Note
These commands assume you are in an online environment. If you are in an offline or air-gapped environment, see Verifying attestations offline.
To verify artifact attestations for binaries, use the following GitHub CLI command.
gh attestation verify PATH/TO/YOUR/BUILD/ARTIFACT-BINARY -R ORGANIZATION_NAME/REPOSITORY_NAME
To verify artifact attestations for container images, you must provide the image's FQDN prefixed with oci:// instead of the path to a binary. You can use the following GitHub CLI command.
docker login ghcr.io
gh attestation verify oci://ghcr.io/ORGANIZATION_NAME/IMAGE_NAME:test -R ORGANIZATION_NAME/REPOSITORY_NAME
To verify SBOM attestations, you have to provide the --predicate-type flag to reference a non-default predicate. For more information, see Vetted predicates in the in-toto/attestation repository.
For example, the attest action currently supports either SPDX or CycloneDX SBOM predicates. To verify an SBOM attestation in the SPDX format, you can use the following GitHub CLI command.
gh attestation verify PATH/TO/YOUR/BUILD/ARTIFACT-BINARY \
-R ORGANIZATION_NAME/REPOSITORY_NAME \
--predicate-type https://spdx.dev/Document/v2.3
To view more information on the attestation, reference the --format json flag. This can be especially helpful when reviewing SBOM attestations.
gh attestation verify PATH/TO/YOUR/BUILD/ARTIFACT-BINARY \
-R ORGANIZATION_NAME/REPOSITORY_NAME \
--predicate-type https://spdx.dev/Document/v2.3 \
--format json \
--jq '.[].verificationResult.statement.predicate'
To keep your attestations relevant and manageable, you should delete attestations that are no longer needed. See Managing the lifecycle of artifact attestations.
You can also generate release attestations to help consumers verify the integrity and origin of your releases. For more information, see Immutable releases.