Sub topic 9
From Build Level 2 to Level 3 with reusable workflows
This chapter assumes you can write GitHub Actions workflows and have generated and verified a build provenance attestation with actions/attest-build-provenance and gh attestation verify. It explains why that setup reaches SLSA Build Level 2 and how a reusable workflow raises it to Level 3.
Where a basic workflow stands
A workflow that calls actions/attest-build-provenance produces signed provenance. The signing certificate comes from the GitHub Actions OIDC identity, and the signature is recorded in a transparency log. The build platform generates the provenance, not your own script. That meets Build Level 2: the provenance is signed and authentic, and a consumer can tell which repository and workflow produced the artifact.
Level 2 has a gap. The same workflow file that builds the artifact also requests the signing token. Anyone who can change that workflow, or any step inside the job, can change the build and still get a valid attestation. A malicious step could alter dist/app after make build and before the attest step. The provenance would still verify, because it is signed under the repository's workflow identity.
What Level 3 adds
Build Level 3 requires a hardened build platform. Two properties matter here:
- Isolation between builds and from the caller. One build cannot influence another, and the caller's own steps cannot reach the signing material.
- Unforgeable provenance. The user-defined build steps cannot forge the provenance or tamper with the signing identity.
For GitHub Actions, you meet these by moving the build and the attestation into a reusable workflow. A reusable workflow is a workflow with an on: workflow_call trigger, which other workflows invoke with uses:. The caller supplies inputs, but it cannot inject steps into the called workflow.
The signing certificate records the reusable workflow's identity (its repository, path and ref). So a verifier can require that the artifact was built by a specific, controlled workflow, not by whatever workflow a contributor wrote.
Writing the reusable workflow
Put this file in a repository that few people can change, for example OWNER/build-workflows.
name: reusable-build
on:
workflow_call:
inputs:
build-command:
required: true
type: string
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
attestations: write
steps:
- uses: actions/checkout@v4
- name: Build
run: ${{ inputs.build-command }}
- name: Attest build provenance
uses: actions/attest-build-provenance@v2
with:
subject-path: dist/appThen call it from the application repository.
name: release
on:
push:
tags: ['v*']
jobs:
build:
permissions:
contents: read
id-token: write
attestations: write
uses: OWNER/build-workflows/.github/workflows/reusable-build.yml@v1
with:
build-command: make buildThe caller must grant id-token: write and attestations: write, because a called workflow cannot hold more permission than its caller gives it. Pin the reference (@v1, or better a full commit SHA) so the identity in the certificate names a fixed version.
Verifying the stronger claim
Level 3 only helps if consumers check for it. Without a check, a Level 2 attestation from any workflow still passes.
gh attestation verify dist/app \
--repo OWNER/app \
--signer-workflow OWNER/build-workflows/.github/workflows/reusable-build.yml--repo confirms the artifact came from the application repository. --signer-workflow confirms the signing identity is the reusable workflow, which is the control that Level 3 depends on.
Level summary
| Setup | Who defines the build | Level reached |
|---|---|---|
| Script run by hand, no provenance | The developer | No level |
| Same workflow builds and attests | Repository contributors | Build Level 2 |
| Reusable workflow builds and attests, verified with `--signer-workflow` | A controlled, separate workflow | Build Level 3 |
Exercise
A repository's workflow builds a binary and then runs actions/attest-build-provenance in the same job. A contributor adds a step between them that modifies the binary. Does the attestation still verify, and what change gives consumers protection against this?
Show answer
Yes, it still verifies, because the signature is issued to the repository's own workflow identity, which the modified workflow still holds. This is the Build Level 2 gap. Moving the build and attestation into a reusable workflow in a separately controlled repository keeps the caller from adding steps. Consumers then verify with --signer-workflow set to that reusable workflow, so an attestation from any other workflow is rejected.