Attestations: in-toto Statements & DSSE
A signature says "I vouch for this digest". An attestation says "I vouch for this claim about this digest": this SBOM describes it, it was built by this CI job from this commit, it passed these tests, this CVE doesn't affect it. The claim is structured data that a policy can check, and the signature makes the claim attributable.
The layers of an attestation
The in-toto Attestation Framework defines the format almost everyone uses (cosign, GitHub, SLSA, npm, PyPI):
DSSE envelope ← signature(s) over (payloadType, payload)
└─ payload (base64)
└─ in-toto Statement ← _type, subject[], predicateType
└─ predicate ← the claim: an SBOM, SLSA provenance, test results, VEX, …{
"_type": "https://in-toto.io/Statement/v1",
"subject": [
{ "name": "registry.example.com/shop/app", "digest": { "sha256": "f04ffda0b1406b53…" } }
],
"predicateType": "https://slsa.dev/provenance/v1",
"predicate": { "…": "…" }
}| Field | Meaning |
|---|---|
subject |
what the claim is about, identified by digest (one statement can cover several artifacts) |
predicateType |
what kind of claim, as a URI; consumers dispatch on it |
predicate |
the claim itself, in the schema that predicateType names |
DSSE payloadType |
application/vnd.in-toto+json; signed together with the payload, so a signature can't be replayed as another type of document |
Attest an SBOM
cosign attest --type <type> --predicate <file> wraps the file in a statement whose subject is the image digest, signs it, and stores it as a referrer. Built-in type names map to predicate-type URIs: cyclonedx, spdxjson, slsaprovenance1, openvex, vuln, link, custom, or any URI.
crane push /opt/samples/images/alpine-3.18.0.tar localhost:5000/shop/app:1.4.2 > /dev/null 2>&1
IMG=localhost:5000/shop/app@$(crane digest localhost:5000/shop/app:1.4.2)
syft scan "$IMG" -q -o cyclonedx-json=sbom.cdx.json
cosign attest --key /opt/keys/cosign.key --signing-config /opt/sigstore/offline-signing-config.json \
--type cyclonedx --predicate sbom.cdx.json "$IMG"
echo "exit $?"
cosign verify-attestation --key /opt/keys/cosign.pub --insecure-ignore-tlog --type cyclonedx "$IMG" > att.json 2> /dev/null
echo "verified, exit $?"
jq -r '.payloadType' att.json
jq -r '.payload' att.json | base64 -d > statement.json
jq '{_type, predicateType, subject: [.subject[] | {name, sha256: .digest.sha256[0:12]}]}' statement.json
jq -c '{bomFormat: .predicate.bomFormat, components: ([.predicate.components[].type] | group_by(.) | map({(.[0]): length}) | add)}' statement.jsonUsing payload from: sbom.cdx.json
Signing artifact...
exit 0
verified, exit 0
application/vnd.in-toto+json
{
"_type": "https://in-toto.io/Statement/v0.1",
"predicateType": "https://cyclonedx.org/bom",
"subject": [
{
"name": "localhost:5000/shop/app",
"sha256": "f04ffda0b140"
}
]
}
{"bomFormat":"CycloneDX","components":{"file":79,"library":15,"operating-system":1}}
The image SBOM lists the 15 Alpine packages (library), the operating system itself, and the files Syft recorded with digests (file), for example the apk database. The SBOM is now inside a signed statement whose subject is the image digest. A consumer who verifies it knows three things the bare SBOM file couldn't tell them: it describes this digest, it was signed by this key, and it wasn't modified since.
Note: cosign writes
_type: https://in-toto.io/Statement/v0.1; the current in-toto spec isv1, which differs only in details (av1subject may also carryuri,annotationsand other descriptor fields). Verifiers accept both.
Several claims, one image
Any JSON can be a predicate. A team might attest its test results with its own predicate type, next to the SBOM and the provenance:
crane push /opt/samples/images/alpine-3.18.0.tar localhost:5000/shop/app:1.4.2 > /dev/null 2>&1
IMG=localhost:5000/shop/app@$(crane digest localhost:5000/shop/app:1.4.2)
SC=/opt/sigstore/offline-signing-config.json
cat > tests.json <<'JSON'
{ "suite": "integration", "passed": 214, "failed": 0, "commit": "3f2a9c1", "runner": "ci-linux-7" }
JSON
syft scan "$IMG" -q -o spdx-json=sbom.spdx.json
cosign attest --key /opt/keys/cosign.key --signing-config $SC --type https://example.com/attestations/test-results/v1 --predicate tests.json "$IMG" > /dev/null 2>&1
cosign attest --key /opt/keys/cosign.key --signing-config $SC --type spdxjson --predicate sbom.spdx.json "$IMG" > /dev/null 2>&1
for t in https://example.com/attestations/test-results/v1 spdxjson slsaprovenance1; do
if cosign verify-attestation --key /opt/keys/cosign.pub --insecure-ignore-tlog --type "$t" "$IMG" > out.json 2> /dev/null; then
echo "$t: verified -> $(jq -r '.payload' out.json | base64 -d | jq -r '.predicateType')"
else
echo "$t: none"
fi
done
cosign verify-attestation --key /opt/keys/cosign.pub --insecure-ignore-tlog --type https://example.com/attestations/test-results/v1 "$IMG" 2> /dev/null \
| jq -r '.payload' | base64 -d | jq -c .predicatehttps://example.com/attestations/test-results/v1: verified -> https://example.com/attestations/test-results/v1
spdxjson: verified -> https://spdx.dev/Document
slsaprovenance1: none
{"commit":"3f2a9c1","failed":0,"passed":214,"runner":"ci-linux-7","suite":"integration"}
spdxjson maps to SPDX's predicate type https://spdx.dev/Document. No provenance was attested, so that check found nothing; the Provenance lesson adds it.
Downloading without verifying
cosign download attestation fetches the stored bundles without checking anything. It's useful for debugging and for tools that verify by other means, and dangerous as an input to decisions:
crane push /opt/samples/images/alpine-3.18.0.tar localhost:5000/shop/app:1.4.2 > /dev/null 2>&1
IMG=localhost:5000/shop/app@$(crane digest localhost:5000/shop/app:1.4.2)
printf '{"approved": true}\n' > approval.json
cosign attest --key /opt/keys/cosign.key --signing-config /opt/sigstore/offline-signing-config.json --type custom --predicate approval.json "$IMG" > /dev/null 2>&1
cosign download attestation "$IMG" | jq -r '.mediaType, (.dsseEnvelope.payload | @base64d | fromjson | .predicateType)'application/vnd.dev.sigstore.bundle.v0.3+json
https://cosign.sigstore.dev/attestation/v1
--type custom maps to cosign's generic predicate type https://cosign.sigstore.dev/attestation/v1; a URI of your own (as in the test-results example) says more. The rule: decisions use verify-attestation (with a key or identity you trust); download is for looking.
Attestations for files
The same structure works for release files: cosign attest-blob --predicate p.json --type … --bundle app.att.json app.tar.gz writes a bundle file next to the artifact, and cosign verify-blob-attestation checks it. GitHub's actions/attest-build-provenance and npm's --provenance produce exactly this kind of bundle (GitHub Attestations).
Test yourself
In an in-toto Statement, what identifies the artifact the claim is about?
- The predicate
- The subject's digest
- The predicateType
- The DSSE signature
Why does DSSE sign the payloadType together with the payload?
- To compress it
- So a signed document can't be reinterpreted as a different type of document
- For base64 padding
- It doesn't
Which command should a deployment gate use to read an SBOM attestation?
- cosign download attestation
- cosign verify-attestation --type cyclonedx with a trusted key or identity
- crane blob
- oras pull