capsule_sig_refused(), the one decision at v4's boot and v3's three births: INVALID always; MISSING and NO_ROOT_KEY on a signed build (CAPSULE_SIGNED_BUILD, set exactly when the Makefiles sign). A developer build warns and boots. test_capsule_sig, built both ways, did not build without it; 4 checks each way now. nightly.sh capsule-trust, a nightly step: signed, v4:centre.4th left unsigned (test only), amd64 must refuse it -- CI's, as ruled, since only CI has the key. No root check, as ruled; the step-4 trust model (blobs signed by their authors, MANIFEST.md hashes, contributors' intermediates, snakeoil) recorded as given. FABRIC-3 XLIX. Gates pass, POST 992/992. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017RzZgrf7V7Zk2iczBXDRbm
95 lines
6.2 KiB
Markdown
95 lines
6.2 KiB
Markdown
# Capsule trust: no unsigned capsule on a signed build (#139) -- design, for ruling
|
|
|
|
Written 2026-11-20. **Built 2026-11-20** (section "Built", below; FABRIC-3 XLIX).
|
|
|
|
## The rulings (Captain Bob, 2026-11-20, one at a time)
|
|
|
|
1. **The anchor: "Intermediate is the anchor; no root check."** The "StarshipOS Capsule Signing"
|
|
certificate built into the image (`capsules/pki/starshipos-intermediate.der`, FABRIC-3 XLVI, ruled
|
|
2026-11-07) is what the capsules are trusted by. The kernel does not check it against the StarshipOS
|
|
Root CA, and no root key is put in the kernel or in CI.
|
|
- First ruled "Yes, verify at boot". Then, asked where CI should take the root's public certificate
|
|
from, Captain Bob: "Actually we decided to include an intermediate certificate in the kernel" --
|
|
XLVI's decision -- and the root check was withdrawn.
|
|
- On the way it was found that the root's private key is on the CI server, beside its certificate, in
|
|
`/var/lib/starshipos-ca/root/` (mode 700). The root's public certificate is also in the tree,
|
|
`ci/pki/starshipos-root-ca.pem`.
|
|
2. **"Refuse on signed builds."** A kernel built with the signing key (CI, releases) refuses an unsigned
|
|
capsule at boot. A developer build without the key keeps the warning, so local work still boots.
|
|
3. **A certificate that cannot be read: "NO_ROOT_KEY, by build."** If the image's signing certificate is
|
|
missing or does not parse, every capsule is NO_ROOT_KEY, with a line saying why. A signed build
|
|
refuses it, as it refuses MISSING; an unsigned build warns and boots.
|
|
|
|
## What is there
|
|
|
|
- `kernel/src/capsule/capsule_sig.c` gives each capsule a result: OK, MISSING, INVALID or NO_ROOT_KEY.
|
|
The callers refuse INVALID only (`capsule_sig.h`, ruled 2026-08-26, when CI had no key).
|
|
- The callers: v4's boot (`v4/system/boot.c:345`, each capsule it loads) and v3's birth
|
|
(`kernel/src/capsule/capsule_birth.c`, three places).
|
|
- The build signs only when `SIGN_KEY` is set (`kernel/Makefile`, `v4/Makefile`): CI sets it from the
|
|
secret `CAPSULE_SIGN_KEY`. The gate into master and a release already refuse an unsigned build (#174).
|
|
|
|
## The design
|
|
|
|
1. **One decision, in one place:** `capsule_sig_refused(result)` in `capsule_sig.c`. INVALID is always
|
|
refused. MISSING and NO_ROOT_KEY are refused when the build is signed, and warned of otherwise. Every
|
|
caller asks it, instead of testing for INVALID itself. Each caller still says why: "missing
|
|
(unsigned)", "invalid", "no signing certificate".
|
|
2. **A signed build** is compiled with `-DCAPSULE_SIGNED_BUILD=1`, set by the kernel's and v4's Makefiles
|
|
exactly when they pass `--sign-key` to mkcapsule. So the flag and the signatures always agree.
|
|
3. **`capsule_sig.h`'s comment** (the 2026-08-26 reason MISSING was a warning) is corrected, dated, and
|
|
FABRIC-3 gets the ruling.
|
|
4. **Tests, written first:**
|
|
- A host test of `capsule_sig_refused` built both ways: on a signed build MISSING, INVALID and
|
|
NO_ROOT_KEY are refused and OK is not; on an unsigned build only INVALID is.
|
|
- **The boots on the three architectures:** the acceptance runs, signed in CI, show a signed build
|
|
booting, as today. A signed build with one capsule unsigned is refused at that capsule. An unsigned
|
|
developer build still boots, with its warnings.
|
|
|
|
## Ruled
|
|
|
|
4. **The refused-capsule boot: "Left to CI".** CI has the real key. A job builds signed, strips one
|
|
capsule's signature, and expects the boot refused at that capsule. This container has no key, so that
|
|
boot is CI's, and the host test and the boots here cover the rest. Asked: that, or a throwaway CA made
|
|
here, its intermediate standing in for the real one in a test build.
|
|
|
|
## Built (2026-11-20)
|
|
|
|
As the design, with one difference in step 4: the refused-capsule boot is CI's (ruling 4).
|
|
`scripts/nightly.sh capsule-trust`, in `nightly.yml`, builds signed with `CAPSULE_TEST_UNSIGN=v4:centre.4th`
|
|
(`scripts/capsule_unsign.py` takes that one signature out after mkcapsule), and boots amd64 in the session's
|
|
`unsigned_capsule` mode. It expects the capsule's "missing (unsigned)" line, `POST: FAILED` and no prompt.
|
|
- **Checked here:** the mode refuses to run without `SIGN_KEY`. The script unsigns only the capsule named,
|
|
and refuses one that is not signed and one that is not there.
|
|
- **To see in CI:** the boot itself, in the first nightly after the merge.
|
|
|
|
`kernel/tests/test_capsule_sig.c` (and `_signed.c`) was written first and did not build without
|
|
`capsule_sig_refused`. It now passes 4 checks on each build (`logs/20261120-capsule-trust/`).
|
|
|
|
|
|
## Given for ADR step 4, when capsules carry trains (Captain Bob, 2026-11-20)
|
|
|
|
Recorded as given, to design from at step 4 ("Integrity, provenance, and reproducibility checks" and the
|
|
carrying of artifacts in capsules). Nothing of it is built.
|
|
|
|
- **The capsule is a train:** "we are evolving to capsules with the v4 runtime engine towing rolling stock
|
|
named blobs". The engine is the train's `.f18a`, and the cars are its named blobs (ABI.md, "one train
|
|
per capsule").
|
|
- **Each blob is signed by its author and hashed:** "Each blob in the capsule is signed by the author and
|
|
hashed. The MANIFEST.md inside the capsule will hold each named blobs hash."
|
|
- **The authors:** "Bonafide contributors will have their own intermediate certificate and 'casual' users
|
|
get a snakeoil cert." StarshipOS's own trains are signed with the StarshipOS Capsule Signing certificate,
|
|
as today.
|
|
- **How they are told apart:** "It can tell the intermediate cert from a snakeoil because it has an
|
|
intermediate chained to the CA." So at step 4 the kernel checks an author's intermediate against the
|
|
StarshipOS Root CA's public key, anchored in the kernel. The public certificate is in the tree
|
|
(`ci/pki/starshipos-root-ca.pem`, with its published hash); the root's private key stays on the server.
|
|
This is the chain check ruling 1 leaves out for now, for the one system certificate. It comes in with
|
|
contributors' trains.
|
|
|
|
**For step 4's design, to be asked one at a time then:**
|
|
- whether `MANIFEST.md` is itself a signed blob, so its hashes are trusted;
|
|
- what placement does with a blob whose hash differs from its manifest's;
|
|
- what each tier is allowed: StarshipOS, a contributor, a snakeoil user. `contrib_capsule_refused()`
|
|
(`capsule_birth.c`, FABRIC-2 I.5) is where tiers began.
|