8000 fix(bep): never make a key while a locked keyring can hold it · gominimal/minimal@6f7019b · GitHub
[go: up one dir, main page]

Skip to content

fix(bep): never make a key while a locked keyring can hold it

Minimal Arch / arch-review completed Nov 14, 2026 in 0s

PASS_WITH_CONDITIONS

Baseline. This re-reviews 6f7019b1 against the PASS_WITH_CONDITIONS on b1c27df6 (this PR), on arch 15b603e6. The checkout has no arch-map.md, so I found the sections by search, as the earlier rulings did. The ledger cuts the baseline's conditions. The compare commit (6f7019b1, "never make a key while a locked keyring can hold it") answers the open point the PR body names: a locked keyring with keys and no identity file looked like a first start. since.diff is that one commit. It changes keys.rs (UnreadStore::can_hide_a_key, and a new Kept refusal before generation in load_with) and linux_store.rs (secret_service_holds in generate_in, remove_in and relabel, plus tests). No merge is in the compare. The baseline stands for main.rs, lib.rs and the rest.

Governs. Gatehouse §6.10 Hardware-backed custody, line 837: keys are generated in the host's hardware where it offers it, TPM 2.0 on Linux. §6.10 Lifecycle, un-enrolled, line 839: keys persist across restarts and are never regenerated silently.

Ruling. The compare is a correct fail-closed fix for the locked keyring, and it agrees with line 839. Two points remain. (C1) secret_service_answer sorts every non-Locked Secret Service error as "cannot be reached", and can_hide_a_key() lets a first start make TPM keys for that bucket. A Secret Service that answers with an error can hold the key, so that path still regenerates silently. Only a real absence of Secret Service (no bus or daemon, or no secret-tool) can let a first start proceed. (C2) The code now refuses a locked first start with Kept, but spec line 308 still asks for the no-usable-TPM refusal in that case, and the compare relaxed that test. The design supports the code, so the spec changes (rule 9).

Precedent. This follows the baseline's PASS_WITH_CONDITIONS and does not depart from it. The baseline accepted a wider version of the C1 hole as mergeable. The compare's new can_hide_a_key() is now the point that decides it, so I name it here. It follows #3412 on line 839.

Not checked. I did not compile or run the tests. I did not check whether secret-tool returns other messages that the UNREACHABLE patterns miss on some desktops. Such a message falls into C1's refusal, which fails closed.

Conditions

  • C1: crates/bep/src/linux_store.rs LinuxStore::secret_service_answer: mark UnreadStore::SecretServiceUnreachable only for KeyError::Unreachable and for the spawn NotFound error that crates/bep/src/secret_service.rs returns when secret-tool is not installed. Recognise that case by a typed marker, not by a match on the detail text, so a headless TPM host still starts (BEP-088). Every other Secret Service lookup error (KeyError::Store from a failed secret-tool run, KeyError::Refused) stops the lookup with that error, so find, held_anywhere, kid_in and secret_service_holds return it and load_with refuses through StartError::from_store before it makes any key. Add a case to the linux_store.rs tests: on a first start, a Secret Service lookup that fails with KeyError::Store refuses, and tpm.generated() stays 0.
  • C2: Amend docs/specs/24-spec-box-egress-proxy/24-spec-box-egress-proxy.md to match the code, as rule 9 requires. Line 308 (the BEP-088 refusal) covers only a TPM that cannot generate the key while Secret Service cannot be reached, so drop "is locked or". Under BEP-089, add an unwanted requirement: IF no key store that answers holds a key for any role, the published identity names no role, and Secret Service is locked, THEN THE SYSTEM SHALL refuse to start, report that Secret Service is locked, generate no key, and not name bep --replace-key. Set its verify line to a test that holds the locked half of no_tpm_and_no_secret_service_refuses_start (crates/bep/src/linux_store.rs line 429), or move that half into a test named for the new line. The compare no longer proves the locked case of line 308. Its test now asserts StartError::Kept for it.

Ruled at 6f7019b against gominimal/arch@15b603e6afb8 by claude-opus-5-5; arch_rulings 1279, job 478fc63a-3bc0-4530-877b-6846d83cba9e.

0