How to Generate SLSA Provenance in CI
Produce SLSA provenance for builds so artifacts carry verifiable evidence of what source produced them and how, enabling policy checks.
On this page
Introduction
A signed artifact proves who built it, but not what it contains or how it was produced. Supply-chain attacks exploit that gap: a compromised build step, a poisoned dependency or a modified pipeline produces an artifact that looks legitimate because the signature is valid. SLSA (Supply-chain Levels for Software Artifacts) provenance is a signed record describing the build: which source revision, which build definition, which platform, and which inputs produced this exact artifact. With provenance, a consumer can verify that the artifact came from the expected source through the expected build, not just that someone signed it.
What Provenance Records
Provenance is a structured, signed statement about a build. It names the build definition (the pipeline), the source repository and revision, the build platform, and the subjects (the artifacts produced) with their digests. It answers “where did this come from” with machine-checkable data rather than a human claim.
The format is an in-toto attestation, a signed statement with a subject (the artifact hashes) and a predicate (the build details in the SLSA provenance schema). It is usually wrapped in a DSSE envelope and signed by the build platform’s identity, which is the trust anchor: consumers verify the signature against the platform they trust and check the predicate against their policy.
{
"_type": "https://in-toto.io/Statement/v1",
"subject": [
{ "name": "app-1.4.2.tar.gz", "digest": { "sha256": "abc123..." } }
],
"predicateType": "https://slsa.dev/provenance/v1",
"predicate": {
"buildDefinition": {
"buildType": "https://example.com/ci@v1",
"externalParameters": { "repository": "https://github.com/example/app", "ref": "refs/tags/v1.4.2" },
"resolvedDependencies": [{ "uri": "git+https://github.com/example/app", "digest": { "gitCommit": "9c1e..." } }]
},
"runDetails": { "builder": { "id": "https://ci.example.com" } }
}
}
Generating Provenance in the Pipeline
The build platform generates provenance, not the application code, because the provenance must reflect what actually ran. A CI system with native support emits the attestation as part of the build; otherwise a generator tool produces it from the environment, and the pipeline signs it. The key is that the signer is an identity the consumer trusts, such as the platform’s OIDC workload identity.
Keep the build definition stable and expressed as code. Provenance records the pipeline that ran, so if the pipeline is defined in the repository and reviewed like code, a change to how artifacts are built is visible. An unpinned, hand-edited pipeline undermines the provenance, because the recorded definition is not what you reviewed.
# GitHub Actions job that generates and signs provenance.
jobs:
build:
permissions:
id-token: write # OIDC identity for signing
contents: read
attestations: write
steps:
- uses: actions/checkout@v4
- run: make build && tar czf app.tar.gz dist/
- uses: actions/attest-build-provenance@v1
with:
subject-path: app.tar.gz # signed provenance bound to this digest
Signing and the Trust Anchor
Provenance is only meaningful if it is signed by an identity the consumer trusts. Keyless signing uses the build platform’s OIDC identity to obtain a short-lived certificate, so there is no long-lived signing key to steal. The signature is recorded in a transparency log such as Rekor, so it cannot be silently forged or backdated.
The consumer verifies the signature against the expected builder identity, not against any signer. Verifying only that the attestation is signed is not enough; it must be signed by the builder you trust for this artifact. Pin the expected identity (issuer and subject) in your policy, so an attestation signed by an attacker’s OIDC identity is rejected.
# Keyless signing binds the signature to the CI identity via OIDC.
cosign sign-blob --yes app.tar.gz
# => ephemeral cert from Fulcio, entry in Rekor transparency log
# Verify with a policy pinning the trusted builder identity.
cosign verify-blob app.tar.gz \
--certificate-identity-regexp '^https://github.com/example/app/.github/workflows/.*$' \
--certificate-oidc-issuer 'https://token.actions.githubusercontent.com'
Verifying Provenance at Consumption
A consumer verifies two things: the signature is valid and from the trusted builder, and the predicate satisfies policy. Policy might require that the source repository is the expected one, that the ref is a signed tag on the main branch, that the build definition is unused beyond the approved workflow, and that the artifact digest matches the one being deployed.
Verification should be enforced at the point of deployment, not left to a human. An admission controller or a pre-deploy check refuses an artifact whose provenance is missing, unsigned by the trusted builder, or built from an unexpected source. If verification is optional, it will be skipped exactly when an attack is in progress.
# deploy-time policy checks on provenance
[ ] attestation present for this artifact digest
[ ] signed by trusted builder identity (issuer + subject pinned)
[ ] source repository == expected repo
[ ] source ref is a protected branch or signed tag
[ ] buildDefinition.buildType is the approved workflow
[ ] artifact digest matches the one being deployed
# any failure => refuse the deploy
SLSA Levels and Their Meaning
SLSA levels describe increasing guarantees. Level 1 is provenance exists and is available. Level 2 is provenance signed by the build platform and generated by a hosted, tamper-resistant build. Level 3 is a hardened build platform with strong isolation between builds and non-falsifiable provenance. Higher levels cost more and defend against stronger adversaries.
Most teams get the most value from moving from “no provenance” to “signed provenance from a hosted CI”, which defeats the common attack of a locally built, hand-signed artifact that does not reflect the reviewed source. Do not chase a level blindly; understand which attack each level defends against and target the one that matches your threat model.
# SLSA progression (attacker intent -> level)
L1 provenance exists -> accidental mistakes
L2 signed by hosted build -> a local "shim" build bypassing CI
L3 hardened, isolated builders -> a compromised build platform step
# value is in the jump from none to L2 for most teams
Storing and Retaining Attestations
Attestations travel with the artifact and should be stored where the consumer can fetch them: alongside the release, in an OCI registry as an attestation, or in a transparency log. A transparency log adds append-only evidence that an attestation existed at a point in time, which defeats backdating.
Retain attestations as long as the artifacts they describe are deployed. An artifact running in production without its attestation available cannot be re-verified, and an incident response that needs to know how a version was built will be missing the evidence. Treat the attestation as part of the release, not as disposable CI output.
# Attach provenance to an OCI image; store alongside the release.
cosign attest --yes --predicate provenance.json --type slsaprovenance \
ghcr.io/example/app:1.4.2
# consumers fetch and verify the attestation for the exact digest they pull
Common Pitfalls and Conclusion
Do not generate provenance inside the application repository in a way the repository can forge; the platform must sign it. Do not verify only that an attestation is signed, without pinning the builder identity. Do not make verification optional. Do not forget to bind the provenance to the artifact digest, or an attestation for one artifact could be presented for another. And do not let the build pipeline be unpinned and hand-edited, which makes the recorded definition meaningless.
SLSA provenance closes the gap between “signed” and “trustworthy”. Generate it in the build platform, sign it with a platform identity via keyless signing, record it in a transparency log, and verify it against a policy that pins the trusted builder and the expected source at deploy time. Then an artifact is accepted not because someone signed it, but because it demonstrably came from the right source through the right build.
Sources: SLSA: Supply-chain Levels for Software Artifacts, SLSA provenance specification, in-toto attestation framework.
FAQ
- Is a signed artifact the same as provenance?
- No. A signature proves who signed; provenance proves what was built, from which source, by which build. An attacker with signing access can sign a malicious artifact, but cannot produce provenance showing it came from your reviewed source via your approved pipeline.
- What does keyless signing add?
- It removes the long-lived signing key that could be stolen, deriving a short-lived certificate from the build platform OIDC identity, and records the signature in a transparency log so it cannot be silently forged or backdated.
Report a problem with this articleOpens a pre-filled issue on GitHub.