Learning center

What does a build provenance attestation prove about an artifact?

The gh attestation verify command shows which repository, workflow, ref, commit and run built the exact file you hold. It says nothing about whether tests ran or passed on that commit or on that file. Pin the workflow you expect, compare the attested commit with the commit your checks covered, and keep the test record as a separate piece of evidence.

Verify a real artifact#

GitHub CLI release archives carry build provenance. This example downloads one and verifies it with GitHub CLI 2.104.0:

$ sha256sum gh_2.104.0_linux_amd64.tar.gz
98cb101ad87dbbd3f6b2f2bfcbd43197ccd07643140121d8a9cfaa91eadbc24e  gh_2.104.0_linux_amd64.tar.gz
$ gh attestation verify gh_2.104.0_linux_amd64.tar.gz --repo cli/cli
exit 0
$ gh attestation verify ... --repo cli/cli --format json | jq (selected fields)
{
  "sourceRepositoryURI": "https://github.com/cli/cli",
  "sourceRepositoryDigest": "3d5a9e355a837f2f5ee78d7484c118cc1342ad1a",
  "sourceRepositoryRef": "refs/heads/trunk",
  "buildSignerURI": "https://github.com/cli/cli/.github/workflows/deployment.yml@refs/heads/trunk",
  "runInvocationURI": "https://github.com/cli/cli/actions/runs/43283669119/attempts/1",
  "githubWorkflowTrigger": "workflow_dispatch"
}

The command looks up attestations by the file's SHA-256 digest, so a match is about these bytes. sourceRepositoryDigest is the commit, buildSignerURI the workflow file that signed, and runInvocationURI the run and attempt. Asking another repository for the same file failed with HTTP 404: Not Found and exit 1, because that repository holds no attestation for this digest.

Pin what you expect#

--repo alone accepts an attestation from any workflow in the repository. The manual says that the more precisely you specify the identity, the more control you have, and it offers --signer-workflow, --source-ref, --source-digest and --deny-self-hosted-runners. If a reusable workflow produced the attestation, that reusable workflow is the signer. gh attestation verify

$ gh attestation verify gh_2.104.0_linux_amd64.tar.gz --repo cli/cli --signer-workflow cli/cli/.github/workflows/deployment.yml --source-ref refs/heads/trunk
exit 0
$ gh attestation verify gh_2.104.0_linux_amd64.tar.gz --repo cli/cli --source-ref refs/tags/v2.104.0

Error: expected SourceRepositoryRef to be refs/tags/v2.104.0, got refs/heads/trunk
exit 1
$ gh api repos/cli/cli/commits/v2.104.0 --jq .sha
3d5a9e355a837f2f5ee78d7484c118cc1342ad1a

The ref check failed because the build was dispatched from trunk, but the tag names the same commit. A ref mismatch does not show different code. Compare commits, and pin --source-digest when you know the commit you mean to ship.

What it does not establish#

GitHub's documentation warns that an attestation does not show that an artifact is secure. It links the artifact to the source and the build instructions. Artifact attestations

QuestionAnswered by the attestation?
Which commit, workflow and run built these bytesYes
Whether tests ran on that commitNo. Read the commit's check runs
Whether tests ran on these bytesNo. A test job that built its own copy tested another file
Whether the build pulled unpinned inputsNo. Read the workflow at that commit

Produce one#

The actions/attest action generates SLSA build provenance by default and needs the id-token: write and attestations: write permissions; its README also lists artifact-metadata: write for the artifact storage record. Since version 4, actions/attest-build-provenance is a wrapper on top of actions/attest, which its README tells new workflows to use. actions/attest ยท attest-build-provenance

- uses: actions/attest@v4
  with:
    subject-path: dist/app.tar.gz

Attest the file your tests ran on and promote that file. An attestation from a later rebuild describes the rebuilt file.

Worked example#

This example is fictional. Ana's release checklist accepts any verified attestation from the repository. Chen verifies with --signer-workflow and gets a failure: the archive was attested by a manual packaging workflow, not the release workflow. Its commit matches the release tag, so the source is right. The tests ran on the archive the release workflow built, so Ana ships that one instead.

Read promote the tested artifact and the npm provenance guide next.

One month of free code review.

New organizations get one calendar month of hosted code review for private and public GitHub repositories. No card or cloud connection required. Eligibility and fair-use terms.

Start free with GitHub

Related reading