Repository navigation
feat(bep): T129 — Refuse a TPM key the proxy cannot load, and keep a key that may come back - #3412
Conversation
A proxy key in the TPM that does not load at start now stops the start with a refusal that says whether the key is kept or lost (BEP-089). Kept: the TPM cannot be reached, answers with a temporary or any other response that does not say the key is lost, or a key file or authorization file this user cannot read. These refusals name no replacement. Lost: a missing key file or authorization file, or TPM_RC_INTEGRITY or TPM_RC_HIERARCHY on the key file. These refusals name `bep --replace-key <role>`. Each refusal logs one error line with the role, store=tpm, the response code and whether the key is kept or lost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
|
Approved: every review thread resolved at @norrietaylor resolved the last thread, which releases the approval this review had withheld. Nothing to do. |
There was a problem hiding this comment.
arch-review: CONDITIONS · 2 conditions · the full ruling
Most of the change conforms to Gatehouse §6.10, and the store and refusal code are in the right files. Two paths report the wrong state of the key. First, load_error treats a TPM_RC_HIERARCHY from tpm2_createprimary as a lost key. A disabled owner hierarchy returns that code, and the key still works after a TPM reset. Section 6.10 line 839 says the key persists across restarts, so C1 keeps that case. Second, generate_files now passes TpmKept/TpmLost out of a failed generation after it removes the files. C2 maps them to KeyError::Store.
Outside the diff
crates/bep/src/tpm.rs:910: C2 · MapKeyError::TpmKeptandKeyError::TpmLosttostore_err(..)here, asRefusedis mapped. A failed generation must beKeyError::Store, asKeyStore::generate_insays. The BEP-088 store choice (§6.10 line 837) depends on it.
Ruled at d99e74f against gominimal/arch@15b603e6afb8 by claude-opus-5-5.
A hierarchy error from tpm2_createprimary says the owner hierarchy is off now, not that the key file is bad, so the start keeps the key and names no replacement. Only tpm2_load can report a lost key. A replacement over a key whose key file is gone now treats the label as empty, and reports that no key is in use when generation fails. read_key no longer passes a missing-file case that it cannot reach. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Round 1 of 10 on the runtime's review findings, pushed as
Verify Review threads the coder judged:
A proxy whose TPM is unreachable, busy, or whose owner hierarchy is off, or whose key file this user cannot read, refuses to start and keeps the key. A proxy whose key file or authorization file is gone, or whose key file the TPM refuses as not its own, refuses to start and names Notes from the agent: Revise round 1. The full bep suite also passed once after the change (309 passed). No new test pins the replace_outcome change for a lost key file. That state reaches recover_interrupted, which finds no side-slot key because lost_key_file needs both side slots empty, so held becomes false. MissingAuthFile and NotThisTpm set held to false without recovery, because a key file is still under the label. |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The change conforms to Gatehouse §6.10 line 839. A TPM key that does not load at start refuses the start. The proxy never regenerates the key silently and never falls back to another store. The commit 92d780e7 keeps a key when tpm2_createprimary returns a hierarchy error, and when a key file exists but the read fails. Only a missing file or a tpm2_load integrity or hierarchy error names bep --replace-key. No conditions are open.
Ruled at 92d780e against gominimal/arch@15b603e6afb8 by claude-opus-5-5.
There was a problem hiding this comment.
minimal-review — approval withheld
Verdict COMMENT — APPROVE withheld: 5 unresolved threads — minimal-foundry[bot] crates/bep/src/tpm.rs:217, minimal-foundry[bot] crates/bep/src/tpm.rs:1184, minimal-foundry[bot] crates/bep/src/tpm.rs:821, minimal-arch[bot] crates/bep/src/tpm.rs, minimal-arch[bot] crates/bep/src/tpm.rs:1000. No findings.
Panel: 3 of 3 personas ran (correctness, security, supply-chain).
|
/revise arch C2 (thread PRRT_kwDOPdfcxM63UKOJ): a fresh key that does not load is reported as kept or lost after its files are removed. Evidence at Do:
|
generate_files removes the key and authorization files when the new key does not load. The kept and lost sorting is for a stored key at start, so map every load error there to KeyError::Store for the role.
|
Round 2 of 10 on a /revise note, pushed as
Verify Review threads the coder judged:
A proxy whose TPM is unreachable, busy or whose key file it cannot read refuses to start and keeps the key. A proxy whose key is gone refuses and names Notes from the agent: Revise round 2. generate_files now maps every error from open() to KeyError::Store for the role, after it removes the files. The detail of the original error stays in the message. find does not change. The new unit test needs fake tpm2-tools, so TpmStore has a private |
There was a problem hiding this comment.
arch-review: PASS · the full ruling
The change conforms to the design. The new commit makes a failed load of a just-generated TPM key a store error, and it removes both files. Thus the kept and lost refusals apply only to a stored key, as section 6.10 line 839 requires. The test seam for tpm2-tools is private and is None in production. The PASS on 92d780e7 stands for the rest of the change.
Ruled at d4269e5 against gominimal/arch@15b603e6afb8 by claude-opus-5-5.
There was a problem hiding this comment.
minimal-review — approved
Verdict APPROVE — every review thread is resolved; @norrietaylor closed the last one. The review of d4269e5fd013 withheld this approval on the threads open then. Posted as a comment: the App cannot approve its own pull request; the check and the label carry it.
T129 — Refuse a TPM key the proxy cannot load, and keep a key that may come back
slice: S18
kind: task
covers: BEP-089
size: M
est: 180 code, 240 tests
executor: agent
difficulty: needs care
model: standard
diagnostics: each refusal prints to the person who started
bep, pinned by its test: "The proxy did not start: the TPM cannot load the proxy's key now (<the TPM's response>). The key is kept; start the proxy again when the TPM is available." for an unreachable TPM or a temporary response; "The proxy did not start: this user cannot read , which holds the proxy's key. The key is kept." for an unreadable file; "The proxy did not start: <the key file|the authorization file> of the proxy's key is missing: . Runbep --replace-key <role>to make a new one. Boxes created before then must be re-created." for a missing file; and "The proxy did not start: this TPM no longer holds the proxy's key. Runbep --replace-key <role>to make a new one. Boxes created before then must be re-created." for a key file the TPM refuses as not its ownobservability: each refusal also logs one error line with the role,
store=tpm, the TPM's response code and whether the key is kept or lostlayers:
- store:
- crates/bep/src/tpm.rs: sorts a failed load into kept (the TPM cannot be reached, or answers with a temporary response such as
TPM_RC_OBJECT_MEMORYorTPM_RC_RETRY, or a file this user cannot read) and lost (a missing key or authorization file, or an integrity or hierarchy error on the key file), as aKeyErrorthat names the role and the case- crates/bep/src/keys.rs:
StartErrorcarries the kept and lost TPM cases, and itsDisplayprints the four refusals abovetest: cargo nextest run -p bep an_unreachable_tpm_refuses_start_and_keeps_the_key
test: cargo nextest run -p bep a_tpm_key_the_tpm_cannot_load_refuses_start
test: cargo nextest run -p bep an_unreadable_tpm_key_file_refuses_start_and_keeps_the_key
produces: none
consumes:
- crates/bep/src/tpm.rs
proof: A proxy whose TPM is unreachable, busy or whose key file it cannot read refuses to start and keeps the key, and one whose key is gone refuses and names
bep --replace-keyfor that role.depends on:
- blocked by #3324
Proof
A proxy whose TPM key does not load at start now refuses to start with one of four messages. If the TPM is unreachable or busy, or this user cannot read the key file or the authorization file, the message says the key is kept and does not name
bep --replace-key. If the key file or the authorization file is missing, or the TPM refuses the key file as not its own (TPM_RC_INTEGRITY or TPM_RC_HIERARCHY), the message namesbep --replace-key <role>for that role. The tests in crates/bep/src/tpm.rs pin each message.Notes from the agent: Design: keys.rs adds KeyError::TpmKept / TpmLost, which carry the role and a TpmKept or TpmLost case, and matching StartError variants. StartError::from_store is now pub(crate) so that the tpm.rs tests can use it. It logs one error line with role, store=tpm, response and key=kept|lost. Only the load at start (TpmKey::load, called from find) is sorted. A reload during use after a TPM reset still gives Refused or Store, as before. Sorting: only TPM_RC_INTEGRITY and TPM_RC_HIERARCHY (layer 0, any parameter or handle) are lost. Every other load failure is kept: TCTI or tool errors, warnings such as 0x902 and 0x922, and other codes such as TPM_RC_INITIALIZE and TPM_RC_BAD_AUTH from an owner authorization. This avoids naming a replacement for a key that is not proven lost. A key file that fails to parse or fails check_public is still KeyError::Refused, as before. The TPM never sees such a file, so the task's cases do not cover it. A missing key file counts as lost only when the held authorization file exists and no key file is in the New or Old slot. Otherwise find returns None, so the interrupted-move recovery and the missing-role logic keep their behaviour. The unreadable test chmods the files to 000 for its end-to-end part, and skips that part when the files stay readable (root). The read_error part runs for any user. Printed text: the kept-TPM message comes from the task's diagnostics line and contains a semicolon ("The key …[truncated]
Tests
cargo nextest run -p bep an_unreachable_tpm_refuses_start_and_keeps_the_keycargo nextest run -p bep a_tpm_key_the_tpm_cannot_load_refuses_startcargo nextest run -p bep an_unreadable_tpm_key_file_refuses_start_and_keeps_the_keyVerify
min task run agent-verifypassed ([tasks.verify]).Closes #3326