Prove what you built with an SBOM and provenance
In this task you'll record what went into a build and prove where it was built.
Two documents make a build trustworthy. An SBOM (software bill of materials) lists every package inside it, so when a new vulnerability is announced you can tell in seconds whether you're affected. Build provenance is a signed statement saying which repository, workflow and commit produced a file.
GitHub's artifact attestations sign provenance with a short-lived certificate tied to the workflow run (no keys to look after). Anyone can then run gh attestation verify on the file to check it came from your repository's pipeline and hasn't been changed. This is the core of the SLSA levels for supply-chain security.
Example. Ironbridge Payments' auditors asked how they knew the API in production was built from reviewed code. The team now attests every release file and image, and the deploy job runs gh attestation verify before it deploys anything.
Before you start
You need: A free GitHub account and a public test repository (Actions minutes are free for public repositories). Time: 30 minutes.
Where to look
- Repository
- .github/workflows/release.yml
- Actions tab
- Attestations
Steps
- Add an SBOM step and an attestation step to the release workflow from the earlier task (see Commands).The job needs
id-token: writeandattestations: write. - Push a new tag and open the run. The SBOM is uploaded as an artifact and the attestation step prints a link.
- Download the release file and verify it:
gh attestation verify app-1.2.0.tgz -R OWNER/REPO.It reports the workflow, commit and repository it came from. - Change one byte of the file (for example, append text) and verify again: it fails.The digest no longer matches anything that was signed.
- Open the SBOM and find the Python version and packages it lists.
Commands
permissions:
contents: write
id-token: write
attestations: write
steps:
- uses: anchore/sbom-action@v0
with:
path: .
format: spdx-json
output-file: sbom.spdx.json
- uses: actions/attest-build-provenance@v3
with:
subject-path: app-*.tgz
# On your computer
gh attestation verify app-1.2.0.tgz -R OWNER/REPO
Watch out for
- Cost
- Free for public repositories. Attestations in private repositories need GitHub Enterprise Cloud.
- Security
- Verify in the deploy step, not only in a report; an attestation nobody checks proves nothing.
- Common mistakes
- Attesting a file, then rebuilding it before upload, so the digest no longer matches.
Clean up
Delete test releases with gh release delete <tag> --cleanup-tag --yes.
Words to know
- SBOM
- A list of every component in a piece of software.
- Provenance
- A record of where, how and from what a file was built.
- Attestation
- A signed statement about a file, such as its provenance.
- SLSA
- A framework of levels for supply-chain security, from basic build records to hardened builds.
Tick off each step and track your progress in the guide.
Open this task in DevOps, Hands On