diff --git a/docs/v4.0.0/plans/2026-11-20-capsule-trust.md b/docs/v4.0.0/plans/2026-11-20-capsule-trust.md new file mode 100644 index 00000000..f70913e5 --- /dev/null +++ b/docs/v4.0.0/plans/2026-11-20-capsule-trust.md @@ -0,0 +1,54 @@ +# Capsule trust: no unsigned capsule on a signed build (#139) -- design, for ruling + +Written 2026-11-20. **Nothing here is built.** + +## 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.