Provenance: the SLSA Predicate
Provenance is a signed statement about how an artifact was produced: which build platform ran which build definition, with which inputs, from which source. SLSA defines it as an in-toto predicate with type https://slsa.dev/provenance/v1. This lesson writes one by hand, attests it to an image, and checks it with a policy, the same steps a build platform and a deploy gate perform automatically.
The predicate
{
"buildDefinition": {
"buildType": "https://actions.github.io/buildtypes/workflow/v1",
"externalParameters": {
"workflow": { "ref": "refs/tags/v1.4.2", "repository": "https://github.com/acme/shop", "path": ".github/workflows/release.yml" }
},
"internalParameters": { "github": { "event_name": "push", "runner_environment": "github-hosted" } },
"resolvedDependencies": [
{ "uri": "git+https://github.com/acme/shop@refs/tags/v1.4.2", "digest": { "gitCommit": "3f2a9c1…" } }
]
},
"runDetails": {
"builder": { "id": "https://github.com/actions/runner/github-hosted" },
"metadata": { "invocationId": "https://github.com/acme/shop/actions/runs/123456789/attempts/1" }
}
}| Field | Answers | Who controls it |
|---|---|---|
buildDefinition.buildType |
how to interpret the parameters (a URI documenting the build platform's format) | the platform |
externalParameters |
what the user asked for: repository, ref, workflow, inputs. The parameters a verifier should check | the user, as recorded by the platform |
internalParameters |
platform settings that don't come from the user | the platform |
resolvedDependencies |
inputs actually fetched: the source commit, base images, tools, each with a digest | recorded by the platform |
runDetails.builder.id |
which build platform produced this; the identity a verifier trusts | the platform |
runDetails.metadata |
invocation id, start and finish times | the platform |
byproducts (optional) |
logs, other outputs | the platform |
The design rule: everything a user could influence is in externalParameters, and a verifier compares it to expectations ("built from acme/shop at a v* tag by the release workflow"). Everything else is either the platform's word (trusted because the builder is trusted) or informational.
Attesting provenance to an image
A build platform does this automatically. Doing it by hand shows that there's no magic: write the predicate, cosign attest --type slsaprovenance1.
crane push /opt/samples/images/alpine-3.18.0.tar localhost:5000/shop/app:1.4.2 > /dev/null 2>&1
DIGEST=$(crane digest localhost:5000/shop/app:1.4.2)
IMG=localhost:5000/shop/app@$DIGEST
cat > provenance.json <<JSON
{
"buildDefinition": {
"buildType": "https://example.com/buildtypes/crane-append/v1",
"externalParameters": {
"repository": "https://git.example.com/acme/shop",
"ref": "refs/tags/v1.4.2"
},
"internalParameters": {},
"resolvedDependencies": [
{ "uri": "git+https://git.example.com/acme/shop@refs/tags/v1.4.2", "digest": { "gitCommit": "3f2a9c1e5b7d4a6f8c0e2b4d6f8a0c2e4b6d8f0a" } },
{ "uri": "pkg:oci/alpine@sha256:c0669ef34cdc14332c0f1ab0c2c01acb91d96014b172f1a76f3a39e63d1f0bda", "digest": { "sha256": "c0669ef34cdc14332c0f1ab0c2c01acb91d96014b172f1a76f3a39e63d1f0bda" } }
]
},
"runDetails": {
"builder": { "id": "https://ci.example.com/builders/release-runner" },
"metadata": { "invocationId": "build-1042", "startedOn": "2026-01-01T00:00:00Z", "finishedOn": "2026-01-01T00:02:10Z" }
}
}
JSON
cosign attest --key /opt/keys/cosign.key --signing-config /opt/sigstore/offline-signing-config.json \
--type slsaprovenance1 --predicate provenance.json "$IMG" > /dev/null 2>&1 && echo "provenance attested"
cosign verify-attestation --key /opt/keys/cosign.pub --insecure-ignore-tlog --type slsaprovenance1 "$IMG" 2> /dev/null \
| jq -r '.payload' | base64 -d \
| jq '{predicateType, subject: .subject[0].digest.sha256[0:12], builder: .predicate.runDetails.builder.id,
source: .predicate.buildDefinition.externalParameters, inputs: [.predicate.buildDefinition.resolvedDependencies[].uri]}'provenance attested
{
"predicateType": "https://slsa.dev/provenance/v1",
"subject": "f04ffda0b140",
"builder": "https://ci.example.com/builders/release-runner",
"source": {
"ref": "refs/tags/v1.4.2",
"repository": "https://git.example.com/acme/shop"
},
"inputs": [
"git+https://git.example.com/acme/shop@refs/tags/v1.4.2",
"pkg:oci/alpine@sha256:c0669ef34cdc14332c0f1ab0c2c01acb91d96014b172f1a76f3a39e63d1f0bda"
]
}
The statement's subject is the image digest (cosign filled it in) and the predicate is exactly the file we wrote. With a key pair, the provenance is only as trustworthy as whoever holds the key, which here is "anyone with the CI secret": Build L1 at best. On GitHub, the platform signs keylessly with its own workflow identity, which is what makes L2/L3 possible (GitHub Attestations).
Verifying provenance against expectations
The deploy-time question is never "is there provenance?" but "does it say what we require?". A CUE policy expresses the expectations; the second run shows the same check rejecting provenance from a different builder and branch:
crane push /opt/samples/images/alpine-3.18.0.tar localhost:5000/shop/app:1.4.2 > /dev/null 2>&1
crane push /opt/samples/images/alpine-3.18.0.tar localhost:5000/shop/app-dev:main > /dev/null 2>&1
SC=/opt/sigstore/offline-signing-config.json
prov() { # prov <builder> <ref>
printf '{"buildDefinition": {"buildType": "https://example.com/buildtypes/crane-append/v1", "externalParameters": {"repository": "https://git.example.com/acme/shop", "ref": "%s"}}, "runDetails": {"builder": {"id": "%s"}}}\n' "$2" "$1"
}
prov https://ci.example.com/builders/release-runner refs/tags/v1.4.2 > release.json
prov https://ci.example.com/builders/shared-runner refs/heads/main > dev.json
REL=localhost:5000/shop/app@$(crane digest localhost:5000/shop/app:1.4.2)
DEV=localhost:5000/shop/app-dev@$(crane digest localhost:5000/shop/app-dev:main)
cosign attest --key /opt/keys/cosign.key --signing-config $SC --type slsaprovenance1 --predicate release.json "$REL" > /dev/null 2>&1
cosign attest --key /opt/keys/cosign.key --signing-config $SC --type slsaprovenance1 --predicate dev.json "$DEV" > /dev/null 2>&1
cat > release-policy.cue <<'CUE'
predicateType: "https://slsa.dev/provenance/v1"
predicate: {
buildDefinition: externalParameters: {
repository: "https://git.example.com/acme/shop"
ref: =~"^refs/tags/v[0-9]+\\.[0-9]+\\.[0-9]+quot;
}
runDetails: builder: id: "https://ci.example.com/builders/release-runner"
}
CUE
for img in "$REL" "$DEV"; do
echo "--- ${img%@*}"
cosign verify-attestation --key /opt/keys/cosign.pub --insecure-ignore-tlog --type slsaprovenance1 \
--policy release-policy.cue "$img" 2>&1 > /dev/null | grep -E '^(- |Error)'
echo "exit ${PIPESTATUS[0]}"
done--- localhost:5000/shop/app
exit 0
--- localhost:5000/shop/app-dev
- predicate.buildDefinition.externalParameters.ref: invalid value "refs/heads/main" (out of bound =~"^refs/tags/v[0-9]+\\.[0-9]+\\.[0-9]+quot;)
Error: 1 validation errors occurred
exit 1
Both images are the same bytes and both provenance documents are validly signed by the same key, but only one was built the way the release policy requires.
What to check, always
- Signature / identity of the provenance: the builder you trust signed it.
- Subject digest equals the artifact you're about to use.
- Builder id is the one you expect (not just "some GitHub runner").
- Source: repository and ref (
refs/tags/v…for releases), and the workflow path if the platform records it. - Optionally, resolved dependencies: the base image digest is one you approve.
slsa-verifier (for slsa-github-generator provenance) and gh attestation verify (for GitHub artifact attestations) implement checks 1–4 with flags; for anything else, a policy like the one above.
Test yourself
Which provenance field records what the *user* asked the build platform to build (repository, ref, workflow inputs)?
- runDetails.builder
- buildDefinition.externalParameters
- internalParameters
- byproducts
Two images' provenance documents are signed by the same key, but one names builder shared-runner and ref refs/heads/main. What rejects it?
- The signature check
- A policy on builder id and ref
- The SBOM
- Rekor
Why is provenance signed with a key from a CI repository secret weak?
- Keys in secrets are public
- Any build step that can read the secret could sign false provenance
- cosign rejects it
- It has no subject