{"meta":{"title":"Using artifact attestations to establish provenance for builds","intro":"Artifact attestations enable you to increase the supply chain security of your builds by establishing where and how your software was built.","product":"GitHub Actions","breadcrumbs":[{"href":"/en/actions","title":"GitHub Actions"},{"href":"/en/actions/how-tos","title":"How-tos"},{"href":"/en/actions/how-tos/secure-your-work","title":"Secure your work"},{"href":"/en/actions/how-tos/secure-your-work/use-artifact-attestations","title":"Use artifact attestations"},{"href":"/en/actions/how-tos/secure-your-work/use-artifact-attestations/use-artifact-attestations","title":"Use artifact attestations"}],"documentType":"article"},"body":"# Using artifact attestations to establish provenance for builds\n\nArtifact attestations enable you to increase the supply chain security of your builds by establishing where and how your software was built.\n\n## Prerequisites\n\nBefore you start generating artifact attestations, you need to understand what they are and when you should use them. See [Artifact attestations](/en/actions/concepts/security/artifact-attestations).\n\n## Generating artifact attestations for your builds\n\nYou can use GitHub Actions to generate artifact attestations that establish build provenance for artifacts such as binaries and container images.\n\nTo generate an artifact attestation, you must:\n\n* Ensure you have the appropriate permissions configured in your workflow.\n* Include a step in your workflow that uses the [`attest` action](https://github.com/actions/attest).\n\nWhen 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`](https://github.com/actions/attest) repository.\n\n### Generating build provenance for binaries\n\n1. In the workflow that builds the binary you would like to attest, add the following permissions.\n\n   ```yaml\n   permissions:\n     id-token: write\n     contents: read\n     attestations: write\n   ```\n\n2. After the step where the binary has been built, add the following step.\n\n   ```yaml\n   - name: Generate artifact attestation\n     uses: actions/attest@v4\n     with:\n       subject-path: 'PATH/TO/ARTIFACT'\n   ```\n\n   The value of the `subject-path` parameter should be set to the path to the binary you want to attest.\n\n### Generating build provenance for container images\n\n1. In the workflow that builds the container image you would like to attest, add the following permissions.\n\n   ```yaml\n   permissions:\n     id-token: write\n     contents: read\n     attestations: write\n     packages: write\n   ```\n\n2. After the step where the image has been built, add the following step.\n\n   ```yaml\n   - name: Generate artifact attestation\n     uses: actions/attest@v4\n     with:\n       subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}\n       subject-digest: 'sha256:fedcba0...'\n       push-to-registry: true\n   ```\n\n   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.\n\n   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`](https://github.com/docker/build-push-action?tab=readme-ov-file#outputs) output from that step to supply the value. For more information on using outputs, see [Workflow syntax for GitHub Actions](/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs).\n\n## Generating an attestation for a software bill of materials (SBOM)\n\nYou can generate signed SBOM attestations for workflow artifacts.\n\nTo generate an attestation for an SBOM, you must:\n\n* Ensure you have the appropriate permissions configured in your workflow.\n* Create an SBOM for your artifact. For more information, see [`anchore-sbom-action`](https://github.com/marketplace/actions/anchore-sbom-action) in the GitHub Marketplace.\n* Include a step in your workflow that uses the [`attest` action](https://github.com/actions/attest) with the `sbom-path` input.\n\nWhen 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`](https://github.com/actions/attest) repository.\n\n### Generating an SBOM attestation for binaries\n\n1. In the workflow that builds the binary you would like to attest, add the following permissions.\n\n   ```yaml\n   permissions:\n     id-token: write\n     contents: read\n     attestations: write\n   ```\n\n2. After the step where the binary has been built, add the following step.\n\n   ```yaml\n   - name: Generate SBOM attestation\n     uses: actions/attest@v4\n     with:\n       subject-path: 'PATH/TO/ARTIFACT'\n       sbom-path: 'PATH/TO/SBOM'\n   ```\n\n   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.\n\n### Generating an SBOM attestation for container images\n\n1. In the workflow that builds the container image you would like to attest, add the following permissions.\n\n   ```yaml\n   permissions:\n     id-token: write\n     contents: read\n     attestations: write\n     packages: write\n   ```\n\n2. After the step where the image has been built, add the following step.\n\n   ```yaml\n   - name: Generate SBOM attestation\n     uses: actions/attest@v4\n     with:\n       subject-name: ${{ env.REGISTRY }}/PATH/TO/IMAGE\n       subject-digest: 'sha256:fedcba0...'\n       sbom-path: 'sbom.json'\n       push-to-registry: true\n   ```\n\n   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.\n\n   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`](https://github.com/docker/build-push-action?tab=readme-ov-file#outputs) output from that step to supply the value. For more information on using outputs, see [Workflow syntax for GitHub Actions](/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idoutputs).\n\n   The value of the `sbom-path` parameter should be set to the path to the JSON-formatted SBOM file you want to attest.\n\n## Uploading artifacts to the linked artifacts page\n\nWe 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](/en/code-security/concepts/supply-chain-security/linked-artifacts).\n\nThe [attest](https://github.com/actions/attest) action automatically creates storage records on the linked artifacts page if both:\n\n* The `push-to-registry` option is set to `true`\n* The workflow that includes the action has the `artifact-metadata: write` permission\n\nFor an example workflow, see [Uploading storage and deployment data to the linked artifacts page](/en/code-security/how-tos/secure-your-supply-chain/establish-provenance-and-integrity/upload-linked-artifacts#generating-an-attestation).\n\n## Verifying artifact attestations with the GitHub CLI\n\nYou can validate artifact attestations for binaries and container images and validate SBOM attestations using the GitHub CLI. For more information, see the [`attestation`](https://cli.github.com/manual/gh_attestation) section of the GitHub CLI manual.\n\n> \\[!NOTE]These commands assume you are in an online environment. If you are in an offline or air-gapped environment, see [Verifying attestations offline](/en/actions/security-guides/verifying-attestations-offline).\n\n### Verifying an artifact attestation for binaries\n\nTo verify artifact attestations for **binaries**, use the following GitHub CLI command.\n\n```bash copy\ngh attestation verify PATH/TO/YOUR/BUILD/ARTIFACT-BINARY -R ORGANIZATION_NAME/REPOSITORY_NAME\n```\n\n### Verifying an artifact attestation for container images\n\nTo 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.\n\n```bash copy\ndocker login ghcr.io\n\ngh attestation verify oci://ghcr.io/ORGANIZATION_NAME/IMAGE_NAME:test -R ORGANIZATION_NAME/REPOSITORY_NAME\n```\n\n### Verifying an attestation for SBOMs\n\nTo verify SBOM attestations, you have to provide the `--predicate-type` flag to reference a non-default predicate. For more information, see [Vetted predicates](https://github.com/in-toto/attestation/tree/main/spec/predicates#vetted-predicates) in the `in-toto/attestation` repository.\n\nFor example, the [`attest` action](https://github.com/actions/attest) 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.\n\n```bash copy\ngh attestation verify PATH/TO/YOUR/BUILD/ARTIFACT-BINARY \\\n  -R ORGANIZATION_NAME/REPOSITORY_NAME \\\n  --predicate-type https://spdx.dev/Document/v2.3\n```\n\nTo view more information on the attestation, reference the `--format json` flag. This can be especially helpful when reviewing SBOM attestations.\n\n```bash copy\ngh attestation verify PATH/TO/YOUR/BUILD/ARTIFACT-BINARY \\\n  -R ORGANIZATION_NAME/REPOSITORY_NAME \\\n  --predicate-type https://spdx.dev/Document/v2.3 \\\n  --format json \\\n  --jq '.[].verificationResult.statement.predicate'\n```\n\n## Next steps\n\nTo keep your attestations relevant and manageable, you should delete attestations that are no longer needed. See [Managing the lifecycle of artifact attestations](/en/actions/how-tos/security-for-github-actions/using-artifact-attestations/managing-the-lifecycle-of-artifact-attestations).\n\nYou can also generate release attestations to help consumers verify the integrity and origin of your releases. For more information, see [Immutable releases](/en/code-security/supply-chain-security/understanding-your-software-supply-chain/immutable-releases)."}