Skip to content
Tech Atlas, home
Search
Esc
  • All roadmapsBrowse every learning path
  • ExploreFind a technology area
  • ProjectsGuided projects and builds
  • My AtlasYour learning dashboard
Lesson 2 of 6 · Concept · 20 min · revision 3

SLSA in practice: hardened builds and provenance

Learn the SLSA Build levels, read the provenance that GitHub artifact attestations carry, assess three release pipelines against the levels, and keep digest-pinned inputs fresh with Dependabot pull requests.

Contentsand lesson path

What you will learn

  • Map supply-chain threats across source, dependencies, build and distribution, assess a pipeline against SLSA build levels, and pin dependencies and base images with automated update pull requests.
  • Sign images and attach build provenance with Sigstore cosign in CI, then verify signatures and attestations before deployment with an admission policy.

01. SLSA Framework: Defining Trust Boundaries for Software Artifacts

A signature on a binary proves who held a key. It says nothing about how the binary was made: from which commit, by which build, and whether someone changed it on the build machine before it was signed. SLSA (Supply-chain Levels for Software Artifacts, pronounced "salsa"), an OpenSSF specification, fills that gap with provenance: a machine-readable record of how an artifact was built.

SLSA v1.0 groups its requirements into tracks. The Build track, unchanged in v1.1 and v1.2, has three levels above L0 (no guarantees):

  • Build L1, provenance exists: the build produces provenance that says what was built, by which builder, from which top-level source. It may be unsigned and written by your own script, so it catches mistakes but is trivial to forge.
  • Build L2, hosted build platform: the build runs on a hosted platform (GitHub Actions, GitLab CI, Google Cloud Build) rather than a laptop, and the platform itself generates and signs the provenance, so nobody can change it after the build without breaking the signature.
  • Build L3, hardened builds: the platform also stops runs from influencing one another and keeps the signing material out of reach of user-defined build steps, so even a compromised build step cannot forge provenance.

02. Deconstructing Provenance: In-Toto Predicates and Build Envelopes

Provenance is written in the in-toto attestation format: a JSON statement with three parts, which is then signed.

  1. _type: Declares the in-toto statement schema version (https://in-toto.io/Statement/v1).

  2. subject: The artifacts the build produced, each identified by its name and digest (such as SHA-256). It binds the attestation to those exact bytes.

  3. predicateType and predicate: Declares the specific attestation schema (https://slsa.dev/provenance/v1). The predicate payload contains detailed metadata regarding the build execution:

  • buildDefinition.buildType: the URI of the template that tells a verifier how to read the other fields. GitHub artifact attestations use https://actions.github.io/buildtypes/workflow/v1; the SLSA GitHub generator and other builders use their own.
  • externalParameters: the inputs a user controls. For a GitHub workflow these are the repository, the workflow file and the ref that triggered it.
  • internalParameters: values the platform sets, such as the event name, the numeric repository and owner IDs and whether the runner was GitHub-hosted.
  • resolvedDependencies: inputs identified by digest, at least the source commit (gitCommit).
  • runDetails.builder.id: what produced the provenance, and so what a verifier has to trust. For GitHub artifact attestations it is the URL of the workflow that ran the attest step, at its ref, such as https://github.com/acme/api/.github/workflows/release.yml@refs/tags/v1.4.0; when the attest step runs inside a reusable workflow, it is that workflow. Attestations made before mid-2024 used https://github.com/actions/runner/github-hosted.

The statement below has the fields that actions/attest writes today.

JSON · decoded statement of a GitHub artifact attestation (example names, IDs, digests)
{
  "_type": "https://in-toto.io/Statement/v1",
  "subject": [
    { "name": "app", "digest": { "sha256": "5f0c…e41b" } }
  ],
  "predicateType": "https://slsa.dev/provenance/v1",
  "predicate": {
    "buildDefinition": {
      "buildType": "https://actions.github.io/buildtypes/workflow/v1",
      "externalParameters": {
        "workflow": {
          "ref": "refs/tags/v1.4.0",
          "repository": "https://github.com/acme/api",
          "path": ".github/workflows/release.yml"
        }
      },
      "internalParameters": {
        "github": {
          "event_name": "push",
          "repository_id": "812345678",
          "repository_owner_id": "123456",
          "runner_environment": "github-hosted"
        }
      },
      "resolvedDependencies": [
        {
          "uri": "git+https://github.com/acme/api@refs/tags/v1.4.0",
          "digest": { "gitCommit": "9b2e…07d4" }
        }
      ]
    },
    "runDetails": {
      "builder": {
        "id":
          "https://github.com/acme/api/.github/workflows/release.yml@refs/tags/v1.4.0"
      },
      "metadata": {
        "invocationId":
          "https://github.com/acme/api/actions/runs/1234567890/attempts/1"
      }
    }
  }
}

03. Hermetic Builds and Supply Chain Verification

Two properties of the build itself make provenance more meaningful:

  • Hermetic Execution: a hermetic build has no network access while it runs. Every compiler, library and dependency is declared up front, fetched and checked against its hash before the build starts, so nothing can be swapped in from outside during the build. Bazel, Nix and Linux network namespaces (unshare -n) are common ways to enforce it.

  • Reproducible Builds: if the same source always gives the same bytes, an independent rebuild can confirm a published artifact; What makes a build reproducible shows the techniques.

  • Automated Provenance Generators: On GitHub Actions, teams get L3 provenance from the reusable workflows of the SLSA GitHub Generator project. What makes it L3 is where the provenance is produced: in a reusable workflow from the slsa-framework/slsa-github-generator repository, which your build steps cannot modify, using GitHub's OIDC token to sign an in-toto attestation that your build job never sees. A reusable workflow in your own repository (uses: ./.github/workflows/...) cannot give that guarantee, because whoever controls the repository controls that file too. The generator must be referenced by its full tag (@v2.1.0, not a SHA and not @v2), because slsa-verifier checks the builder ID from that ref.

  • What the generic generator attests to: In the workflow below, your own build job compiles the binary and hands the generator its hashes. base64-subjects must be the base64 encoding of sha256sum output (sha256sum bin/app | base64 -w0), not a raw hash string. The generator makes the provenance unforgeable by your build steps, but the build itself still runs in your job; the project's language-specific builders (Go, Node.js, container-based) also run the build inside the trusted workflow. GitHub's own actions/attest (which actions/attest-build-provenance v4 wraps) is the alternative that the exercise below uses.

  • Verifying it: After a tag push, download the binary and app.intoto.jsonl from the release and run slsa-verifier verify-artifact app --provenance-path app.intoto.jsonl --source-uri github.com/<org>/<repo> --source-tag v1.0.0. It checks the signature, the builder ID and the source repository and tag.

YAML · .github/workflows/slsa-release.yaml: build, then L3 provenance from the trusted generator
name: SLSA L3 provenance for a release
on:
  push:
    tags: ["v*"]
permissions:
  contents: read
jobs:
  build:
    runs-on: ubuntu-latest
    outputs:
      hashes: ${{ steps.hash.outputs.hashes }}
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
      - name: Build
        run: CGO_ENABLED=0 go build -trimpath -o bin/app .
      - name: Hash the artifact (sha256sum output, base64-encoded on one line)
        id: hash
        run: echo "hashes=$(sha256sum bin/app | base64 -w0)" >> "$GITHUB_OUTPUT"
      - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: app
          path: bin/app
          if-no-files-found: error

  provenance:
    needs: [build]
    permissions:
      actions: read    # detect the GitHub Actions environment
      id-token: write  # keyless signing of the provenance
      contents: write  # upload the provenance to the release
    # The trusted generator lives in the slsa-framework repository, which your
    # build steps cannot change. It MUST be referenced by its full tag (not a
    # SHA) so slsa-verifier can check the builder ID. Split only to fit this
    # page: in double quotes, a trailing `\` drops the line break and the next
    # line's leading spaces; without it YAML inserts a space and the ref breaks.
    # In a real workflow keep the whole `uses:` value on one line.
    uses: "slsa-framework/slsa-github-generator/.github/workflows/\
      [email protected]"
    with:
      base64-subjects: ${{ needs.build.outputs.hashes }}
      upload-assets: true  # attach app.intoto.jsonl to the GitHub release

  release:
    needs: [build, provenance]
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      # Split with a trailing `\` as above. In a real workflow keep the value
      # and its tag comment on one line, so Dependabot and Renovate update both.
      - uses: "actions/download-artifact@\
          9000827ccba6bdab643e8b6fd33ac0654aef8333" # v8.0.2
        with:
          name: app
      - name: Attach the binary to the release
        env:
          GH_TOKEN: ${{ github.token }}
        run: gh release upload "$GITHUB_REF_NAME" app --repo "$GITHUB_REPOSITORY"

04. Exercise: Which Build Level Does Each Pipeline Reach?

To assess a pipeline, ask three questions in order. Does the build produce provenance (L1)? Is the provenance generated and signed by a hosted platform rather than by your own scripts (L2)? Can any step that you or your dependencies control reach the signing identity, and can one run affect another (L3)? Read the three release workflows below and decide the highest level each reaches and what it is missing before you read the answers.

YAML · pipeline A: self-hosted runner, provenance from a script
name: Release (pipeline A)
on:
  push:
    tags: ["v*"]
permissions:
  contents: write
jobs:
  release:
    runs-on: [self-hosted, linux]  # one long-lived VM that every job shares
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - run: make release  # writes dist/app
      - run: ./scripts/write-provenance.sh dist/app > dist/app.provenance.json
      - env:
          GH_TOKEN: ${{ github.token }}
        run: gh release upload "$GITHUB_REF_NAME" dist/app dist/app.provenance.json
YAML · pipeline B: GitHub-hosted, build and attest in one job
name: Release (pipeline B)
on:
  push:
    tags: ["v*"]
permissions:
  contents: read
jobs:
  release:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      id-token: write
      attestations: write
      artifact-metadata: write
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - run: make release  # your build steps, in the job that can sign
      - uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
        with:
          subject-path: dist/app
YAML · pipeline C: the caller, which only calls a shared workflow
name: Release (pipeline C)
on:
  push:
    tags: ["v*"]
permissions:
  contents: read
jobs:
  release:
    permissions:
      contents: read
      id-token: write
      attestations: write
      artifact-metadata: write
    # A shared workflow in a repository that only the platform team can change.
    # Use its protected release tag, or its full commit SHA.
    uses: acme/build-platform/.github/workflows/[email protected]
YAML · acme/build-platform/.github/workflows/go-build-attest.yml
# Lives in acme/build-platform, not in the project being built.
name: Build and attest a Go binary
on:
  workflow_call:
jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: read  # no id-token here: the project's code runs in this job
    outputs:
      digest: ${{ steps.hash.outputs.digest }}
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          persist-credentials: false
      - run: CGO_ENABLED=0 go build -trimpath -o app .
      - id: hash
        run: echo "digest=sha256:$(sha256sum app | cut -d' ' -f1)" >> "$GITHUB_OUTPUT"
      - uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
        with:
          name: app
          path: app
  attest:
    needs: build
    runs-on: ubuntu-latest
    permissions:  # this job signs, and it runs no code from the project
      id-token: write
      attestations: write
      artifact-metadata: write
    steps:
      - uses: actions/attest@1e69f48acb82d1966a394da916b4c1698aa569d6 # v4.2.2
        with:
          subject-name: app
          subject-digest: ${{ needs.build.outputs.digest }}

Answers:

  • Pipeline A reaches Build L1 at most. Provenance exists, but write-provenance.sh is your own script and nothing signs its output, so whoever can change the release can change the provenance. Missing for L2: provenance generated and signed by the platform, checked by consumers. Missing for L3 as well: a long-lived self-hosted VM lets one run leave files behind for the next.
  • Pipeline B reaches Build L2, which is what GitHub documents for artifact attestations on their own. GitHub's action generates the provenance and signs it with a short-lived Sigstore certificate tied to the workflow's identity. Missing for L3: make release runs in the job that holds id-token: write, and any step in that job can ask the runner for the job's OIDC token, so a compromised build step could get a valid signature on provenance it wrote itself.
  • Pipeline C can reach Build L3, the level GitHub documents for attestations made in a reusable workflow. The project's code runs in a job without id-token: write, the signing job runs no project code, and both are defined in a repository that the project's own commits cannot change. The certificate names the shared workflow, so consumers must check it, for example with gh attestation verify app -o acme --signer-workflow acme/build-platform/.github/workflows/go-build-attest.yml; without that check nobody enforces the property.

None of the three levels says anything about which code was built. A typosquatted module in go.mod is built and attested faithfully, even at L3. The Build track covers tampering during and after the build; reviewing new dependencies and allow-listing approved ones cover the choice of dependencies, and SLSA's Source track covers changes to your own code.

05. Pinned Inputs With Automated Update Pull Requests

The inputs need pinning too. A base image named only by tag (python:3.13-slim) can point to different bytes tomorrow, and so can an action tag. Pinning by digest or commit SHA fixes the inputs, but pinned inputs age and collect known vulnerabilities, so let a bot propose each update as a pull request that CI tests and a person reviews. This configuration asks Dependabot to check the Dockerfile and the workflows once a week:

YAML · .github/dependabot.yml
version: 2
updates:
  - package-ecosystem: docker  # FROM lines in the Dockerfile at the repo root
    directory: /
    schedule:
      interval: weekly
    cooldown:
      default-days: 7  # skip releases younger than a week
  - package-ecosystem: github-actions  # uses: lines in .github/workflows
    directory: /
    schedule:
      interval: weekly
    cooldown:
      default-days: 7

Dependabot keeps the form you chose. For FROM python:3.13-slim@sha256:… it opens a pull request that changes the tag and the digest together, or only the digest when the image behind the same tag was rebuilt. For uses: actions/checkout@<sha> # v7.0.1 it changes the SHA and rewrites the version comment, which is why the comment must stay on the same line. By default it does not add a digest to a FROM line that has none; Renovate's pinDigests: true option does that for Docker images and GitHub Actions. cooldown makes Dependabot skip releases younger than seven days (its default is three), so a malicious release that is spotted and pulled within those seven days never reaches your pull requests. Each pull request runs your normal CI, so a broken update fails a check instead of reaching main.

06. Check your understanding

Practice check · 3 questions

Generator inputs, Build levels and hermetic builds

Three questions on producing SLSA provenance and assessing a pipeline against the Build levels.

Q1. In the lesson's workflow, the build job passes `base64-subjects` to the generic SLSA generator. What must that input contain?
Q2. Pipeline A from the exercise builds on one long-lived self-hosted runner, and `./scripts/write-provenance.sh` writes the provenance that is uploaded with the binary. Which Build level does it reach, and what is the next gap?
Q3. Why does enforcing network isolation during the compilation step of a hermetic build prevent supply chain attacks?
Practice only: not graded, not saved, not evidence.

07. Apply it

Apply the lesson to your own release pipeline:

  • Assess it: answer the three questions from the exercise and write down its Build level and the gap to the next one.
  • Close the gap: move building and signing into a shared reusable workflow or the SLSA generator, and verify before deploying with gh attestation verify --signer-workflow or slsa-verifier.
  • Pin and refresh inputs: pin base images by digest and actions by SHA, and commit a dependabot.yml or Renovate configuration so that updates arrive as reviewed pull requests.
  • Harden the build: run releases on ephemeral runners and fetch dependencies before the build, so the build itself needs no network.

08. Review prompt

Without looking back, state what each Build level adds, and why a job that builds and signs in the same place stops at L2. Name the provenance fields that identify the builder and the source commit. Then explain which lines of a Dockerfile and a workflow Dependabot rewrites, and why a pin needs a bot.

References

Your progress

Reading state

Sign in to save that you finished reading this lesson.

Sign in to mark reading complete

Prove this skill

6 questions · about 5 minutes · scored automatically. Marking a lesson as read never demonstrates a skill.
Take the skill check