Time: 25 minutes. Track: security and compliance. Before this: security lesson 1.
By the end of this lesson you will be able to:
- say what a receipt is, and what checking one proves;
- verify a released file against its provenance, with the organization’s keys and the repository’s log alone;
- say what the first verification pins, and what a later one refuses;
- show that a changed file, a wrong name and an unpublished release all fail, each saying why.
A receipt, and what checking one proves
Everything the forge does is recorded as a receipt: a signed statement, an in-toto Statement in a DSSE envelope, signed by the organization’s receipts key, put in a receipt log. Lesson 1 read them in a report. This lesson checks one by hand, the strongest there is: a release’s provenance, which says which commit was built, by which build, into which files.
Checking a receipt proves four things, and needs nothing from whoever handed you the file:
- The log is the one you trust. Its origin and keys are those you pinned.
- The receipt is in it. A checkpoint of the log, signed by the log’s key, covers it: a Merkle proof shows the receipt at its place in the log’s tree, as Certificate Transparency’s and the Go checksum database’s do. The checkpoint carries the cosignatures of the witnesses the forge is configured with.
- The receipt is the organization’s. Its envelope is signed by the receipts key, which no person and no agent can use.
- It says what you need. For a release: SLSA’s build provenance of this release, of this repository, at its commit, naming your file’s SHA-256 as the artifact you named.
A log is append-only, and its checkpoints grow: a checkpoint commits to everything before it, so a forge cannot later take back or change a receipt that a checkpoint covered. Witnesses, other parties that cosign each checkpoint only once they have checked it extends the last one they saw, make sure everyone sees the same log. A development forge has none.
A release to verify
Start a forge with one runner, as From a test to a release does:
$ af-server --dev
...$ source ~/af-dev/dev/env
$ af-runner key ~/runner.key > ~/runner.pub
$ af enroll-runner "$(cat ~/runner.pub)" --name build-01 | tee ~/runner.id
done: it took effect at once, on your word as an administrator
born 679e7c0784a6c0b85cf11a0ee340bb085118e157680eafdb07e59435572434b2The runner runs until it is stopped, so it goes in a terminal of its own:
$ af-runner run --address "$AF_ADDRESS" --cert-hash "$AF_CERT_HASH" \
> --id "$(sed -n 's/^born //p' ~/runner.id)" --key ~/runner.key --work ~/runner-work \
> --system /usr --system /bin --system /lib --system /lib64 --capacity 1
af-runner: 679e7c0784a6c0b85cf11a0ee340bb085118e157680eafdb07e59435572434b2 runs up to 1 job at onceLand a release program, .forge/release. What it writes under $FORGE_OUT is the release; here, one file, tool. A change to .forge/ waits for a person’s approval, so grant yourself approver and approve it:
$ af workspace add ~/w > /dev/null
$ cd ~/w
$ af new -m "Build a release"
Working on change ykunqtzoutzkqlkmlzruuwovkoormsyl at commit 70298bd1a946a9ef263e9bdc49962183974cbece3beac9bebf8c8f0071bfabce
$ mkdir -p .forge
$ printf '#!/bin/sh\nset -eu\nprintf "audited build of %%s\\n" "$FORGE_COMMIT" > "$FORGE_OUT/tool"\n' > .forge/release
$ chmod +x .forge/release
$ af submit
Submitted commit 332f1daa6ff47105ee992ee7f973e63095e4e89600b4d8af0a61f92f0692e505, 1 edit in its last snapshot
$ af grant dev@localhost approver --reason "lesson three"
done: it took effect at once, on your word as an administrator
$ af approve-change @
approved commit 332f1daa6ff47105ee992ee7f973e63095e4e89600b4d8af0a61f92f0692e505 of change ykunqtzoutzkqlkmlzruuwovkoormsyl$ af status
Change ykunqtzoutzkqlkmlzruuwovkoormsyl (landed) at commit 332f1daa6ff47105ee992ee7f973e63095e4e89600b4d8af0a61f92f0692e505Ask for a release of main as it is. The runner builds it in its sandbox, and the forge hashes what it uploads, itself:
$ af release request v1.0
v1.0 requested 332f1daa6ff47105ee992ee7f973e63095e4e89600b4d8af0a61f92f0692e505$ af release show v1.0
v1.0 built 332f1daa6ff47105ee992ee7f973e63095e4e89600b4d8af0a61f92f0692e505
8d055e0b598fce0665f3d07bc51466be2619921384a6f04ab01f2c56e38ecb34 82 toolApproving the build publishes it: the forge writes the provenance, signs it with the receipts key, and puts it in the repository’s log with the approval:
$ af release approve v1.0
v1.0 published 332f1daa6ff47105ee992ee7f973e63095e4e89600b4d8af0a61f92f0692e505
8d055e0b598fce0665f3d07bc51466be2619921384a6f04ab01f2c56e38ecb34 82 tool
provenance: entry 8 of the repository's logYou approved your own release. The forge allows that by default, and every compliance report lists it as an exception; a forge that requires another person refuses it.
Verify the file
Fetch the file, as anyone who uses the release would, and verify it:
$ af release get v1.0 tool -o ~/tool
$ af release verify v1.0 tool ~/tool
pinned the receipt log of main at 127.0.0.1:7777: localhost/atoll-forge/operator/main
verified v1.0 tool 8d055e0b598fce0665f3d07bc51466be2619921384a6f04ab01f2c56e38ecb34: provenance at entry 8 of the repository's log, witnesses 0 of 0The first line is the pin. The first time you verify against a repository at an address, af keeps the log’s origin, the log’s key and the receipts key, as SSH keeps a host’s key the first time you connect. Every later verification holds the log to them:
$ af release verify v1.0 tool ~/tool
verified v1.0 tool 8d055e0b598fce0665f3d07bc51466be2619921384a6f04ab01f2c56e38ecb34: provenance at entry 8 of the repository's log, witnesses 0 of 0If the forge at that address ever names other keys, af refuses, shows the keys it pinned and the keys it sees, and verifies nothing until you run it again with --accept-new-log, which you should do only once you know the new keys are good some other way. A pin worth trusting is one you made against a forge you knew to be the real one, or checked against keys its operator published.
The second line is the proof. The provenance is at entry 8 of the repository’s log, a checkpoint signed by the pinned log key covers it, and it names the file’s SHA-256 as tool. The checkpoint carries none of the witnesses’ cosignatures, because a development forge has no witnesses, and needs none.
Verification waits for the log’s next checkpoint to cover the provenance, a moment after publication: the log checkpoints within a second. It waits ten seconds at most.
What fails
Change the file, and verification fails: the provenance names the file’s SHA-256, and a changed file has another:
$ printf 'audited build, changed\n' > ~/changed
$ af release verify v1.0 tool ~/changed
Error: not verified: release v1.0's provenance names no tool of SHA-256 e57131dccc941a017498d54b40095a2dfde997defb1bf544b724adb35910d706
[1]The same file under another name fails too. A provenance names each file it vouches for, and a file is vouched for only under its own name:
$ af release verify v1.0 other ~/tool
Error: not verified: release v1.0's provenance names no other of SHA-256 8d055e0b598fce0665f3d07bc51466be2619921384a6f04ab01f2c56e38ecb34
[1]Every refusal starts not verified:, and says what did not hold.
Exercises
-
Verify a copy of the file that reached you another way. Only its bytes count, not where they came from:
$ cp ~/tool ~/from-a-mirror $ af release verify v1.0 tool ~/from-a-mirror verified v1.0 tool 8d055e0b598fce0665f3d07bc51466be2619921384a6f04ab01f2c56e38ecb34: provenance at entry 8 of the repository's log, witnesses 0 of 0 -
Ask for a second release, and verify its file before anyone approves it:
$ af release request v1.1 v1.1 requested 332f1daa6ff47105ee992ee7f973e63095e4e89600b4d8af0a61f92f0692e505$ af release show v1.1 v1.1 built 332f1daa6ff47105ee992ee7f973e63095e4e89600b4d8af0a61f92f0692e505 8d055e0b598fce0665f3d07bc51466be2619921384a6f04ab01f2c56e38ecb34 82 tool$ af release verify v1.1 tool ~/tool Error: not verified: release v1.1 is not published, so it has no provenance [1]A build is not a release until a person approves exactly it: until then there is no provenance to check, however good the build.
-
Find the pin.
afkeeps one file for each address and repository it has verified against, under its configuration directory:$ ls ~/.config/atoll-forge/logs | grep -c 'json$' 1
Check your understanding
The forge holds the receipts key. What does verifying add to the forge’s word?
Three things. The file in your hand is the one the forge built and a person approved, whoever handed it to you: a mirror, a cache or a download page cannot change it unnoticed. The provenance is in an append-only log the forge cannot rewrite once a checkpoint covers it. And with witnesses, everyone who checks sees that same log, so the forge cannot show one history to an auditor and another to everyone else.
Your first verification pinned the log. What if the forge you first asked was not the real one?
Then you pinned the wrong keys, and later verifications would hold you to them. As with SSH, the first use is the moment to check: compare the keys with those the forge’s operator published, or pin against a forge you know is the real one. After that, a forge naming other keys is refused until you accept them.
A release was approved by the person who asked for it. Does it verify?
Yes: its provenance is as sound as any. What differs is the record: the approval is on its asker’s own word, and every compliance report lists it as an exception. A forge configured to require another person refuses the approval in the first place.
Next
Security lesson 4: The landing scan stops a secret before it lands. What the forge records explains receipts, checkpoints and witnesses in depth, and Search, caches and releases explains releases on SLSA Build Level 3.