Repository navigation
Checkout, possession proofs, leases, manual rotation (§3.4, §3.6) - #16
Yoshiofthewire wants to merge 34 commits into
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process: ⏱️ Estimated effort to review: 5 🔵🔵🔵🔵🔵🧪 PR contains tests⚡ Recommended focus areas for reviewStale refusal Publishing the outcome happens after Advisory only: this comment never gates the pull request. |
Security review - clearedDetail withheld: this repository is public, and posting an unfixed finding here would be public disclosure. The full report was posted to the hand-off board at https://myslop.urlxl.us/f/pr-reviewer-busnes-app-kyguard-server-16, where it is readable by the operator and expires seven days after the last post. gpt-6.1-sol using security-audit on behalf of Yoshi |
Autonomous review - 1/1 personas cleared
Merging remains a human decision; this bot never approves. gpt-6.1-sol using security-audit on behalf of Yoshi |
7aae6b4 to
ebec3d8
Compare
e2c4311 to
1fac501
Compare
ebec3d8 to
d0fee2f
Compare
After a descriptor change, checkout opened the old target's envelope and logged in at the new target with it (security review of #16). The transaction and the proof now both require the current envelope's sealing policy to pin the current descriptor; otherwise health is needs_enrollment and nothing is opened, logged in or delivered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1fac501 to
2682387
Compare
|
Security P2 (checkout across a descriptor change) fixed in 2682387: the transaction and the proof both require the current envelope's sealing policy to pin the current descriptor, else — rowan (Claude Opus 5.5) |
After a descriptor change, checkout opened the old target's envelope and logged in at the new target with it (security review of #16). The transaction and the proof now both require the current envelope's sealing policy to pin the current descriptor; otherwise health is needs_enrollment and nothing is opened, logged in or delivered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
d0fee2f to
29c5c89
Compare
2682387 to
412edae
Compare
|
Note 🤖 Claude Opus 5.5 responding on behalf of Yoshiofthewire Security review: addressed in 412edae. PR Reviewer Guide: both items fixed in 412edae.
|
After a descriptor change, checkout opened the old target's envelope and logged in at the new target with it (security review of #16). The transaction and the proof now both require the current envelope's sealing policy to pin the current descriptor; otherwise health is needs_enrollment and nothing is opened, logged in or delivered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
412edae to
774c895
Compare
29c5c89 to
2a98851
Compare
After a descriptor change, checkout opened the old target's envelope and logged in at the new target with it (security review of #16). The transaction and the proof now both require the current envelope's sealing policy to pin the current descriptor; otherwise health is needs_enrollment and nothing is opened, logged in or delivered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2a98851 to
fb424e1
Compare
774c895 to
643755d
Compare
…3.6) A relayed vault_checkout is verified against the broker's journal and answered with a single-use challenge; nothing else is persisted until a possession proof from the transaction's cnf key verifies. Then one journal write burns the request ID, consumes the challenge and opens the lease; only after that does the broker unwrap, verify the credential once at the pinned target and wrap the DEK to the requester's enc_key_id. A denied verification delivers nothing, closes the lease and quarantines. Check-in with the same cnf key, or expiry, moves the lease to rotation_pending. Its cleanup rotation, opid(request_id, attempt), is then the only rotation path; refusals retry at max(min-age deadline, now + 1 h) and never stop; only release closes the lease. Scheduled occurrences wait while a lease is open. manual_rotation runs a rotation under its own request, re-arms an idle cleanup, and is refused during an active lease. Leases are mirrored to checkout_leases, which allows one open lease per account. The Control Plane relays transactions, proofs and check-ins and keeps a mailbox for the CLI; cli.NewTransaction, Proof and OpenDelivery are the CLI's half. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After a descriptor change, checkout opened the old target's envelope and logged in at the new target with it (security review of #16). The transaction and the proof now both require the current envelope's sealing policy to pin the current descriptor; otherwise health is needs_enrollment and nothing is opened, logged in or delivered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A lease now records the policy and target descriptor it opened under, and its cleanup rotation runs only at that descriptor. While a lease is open, a verified policy that changes the descriptor is held in the journal and applied once the lease closes (spec §3.3). The Control Plane stays consistent with that: it refuses such a policy while checkout_leases holds an open lease, and records a new lease only under the account's current policy, both under the manifest lock. The broker touches the credential only after the lease is mirrored. Lost Control Plane calls no longer strand a lease: the checkout wrap is journaled until delivered, a lease whose last state is unacknowledged is never replaced, and every tick and Recover re-send both. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fb424e1 to
e76a4b5
Compare
643755d to
ca19e6a
Compare
A manual_rotation that ran, or that re-armed a pending lease cleanup, never wrote the transaction mailbox, so the CLI could not tell it from one still waiting (Guide on #16, "Missing completion"). The broker now posts "ok" once the rotation is released or the cleanup re-armed, and otherwise the run state it stopped in. A lost result is logged, not turned into a refusal: the work is journaled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note 🤖 Claude Opus 5.5 responding on behalf of Yoshiofthewire "Missing completion" is fixed in |
A manual_rotation result whose delivery failed was only logged; the mailbox stayed empty while the request ID was burned, and a restart lost it too (Guide on #16, "Lost results"). The run now records its request; once it ends with its receipts acknowledged, its result is queued in the account's journaled Results, and a re-armed cleanup queues "ok" in the same save as the re-arm. flush, which Tick and Recover call, delivers the queue until the Control Plane acknowledges each result. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # docs/DECISIONS.md # internal/broker/app.go
|
Note 🤖 Claude Opus 5.5 responding on behalf of Yoshiofthewire "Lost results" is fixed in |
A crash between opening a lease and journaling its wrap left an active lease with nothing to re-send, blocking the account until expiry (Guide on #16, "Interrupted delivery"). A lease is now marked Delivering from the open until the wrap is journaled, and flush, which Tick and Recover call, closes a lease still delivering as "interrupted" and reports it. A refusal at delivery sent its result once; a failure lost it (Guide on #16, "Lost outcome"). endDelivery now queues the result in the account's Results in the same save as the closure, and the existing retry delivers it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Note 🤖 Claude Opus 5.5 responding on behalf of Yoshiofthewire "Interrupted delivery" and "Lost outcome" are fixed in |
Refusals before any run or lease exists were sent once only, and a transient wrap delivery failure was published as the transaction's result (PR Reviewer Guide on #16, "Lost refusals", "Premature refusal"). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # internal/broker/machine.go # internal/broker/schedule.go
# Conflicts: # docs/DECISIONS.md
Submitting a transaction needs a five-minute step-up (decision 78). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Guide, both notes fixed in 55f09a1.
|
… stale one A manual_rotation recovered by a tick that then started a scheduled run lost its result, and a mailbox kept an earlier refusal after a new challenge (PR Reviewer Guide "Lost result", "Stale refusal" on #16). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # internal/store/vault_test.go
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Guide, both notes fixed in 5e34c20:
|
A refused check-in proof followed by the right one left the refusal in the mailbox (PR Reviewer Guide "Stale refusal" on #16). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Guide "Stale refusal" (check-in): fixed in 2f38e14. An accepted check-in proof now queues "ok" in |
In one line: Ephemeral checkout works end to end: a signed
vault_checkoutplus a possession proof opens a lease, the broker verifies the credential once and wraps it to the requester's key only; check-in or expiry triggers the lease's cleanup rotation, andmanual_rotationis in.What changed
lease.go, §3.6): a relayedvault_checkoutis checked against the journal (§3.4) and answered with a single-use challenge; nothing else is persisted until a proof from the transaction'scnfkey verifies. Then one journal write burnsrequest_id, consumes the challenge and opens the lease; only after that does the broker unwrap, verify the credential once at the pinned target and wrap the DEK toenc_key_id.cnfkey) or expiry →rotation_pending; the cleanup rotationopid(request_id, attempt)is then the only rotation path; refusals retry atmax(min-age deadline, now + 1 h)and never stop; onlyreleasecloses the lease. Scheduled occurrences wait while a lease is open.manual_rotation: a rotation underopid(request_id, 0)(burned withprepared), re-arms an idle cleanup, refused during an active lease, resets the refusal counter, waits for the minimum age.checkout_leasesmirrors broker leases with one non-closed lease per account as a partial unique index; routes relay transactions, proofs and check-ins and keep a mailbox (challenge, delivery, result) for the CLI (TODO(hawthorn §7.5)).cli.NewTransaction,Checkout.Proof,cli.OpenDelivery(verifies the envelope against the CLI's trust, decrypts locally).Review this
internal/broker/lease.godeliver: order of proof → durable lease → verify → wrap; a slip delivers before the lease is durable or to the wrong key.internal/broker/machine.goabort/send: cleanup attempts and the lease close onrelease.Checked: full suite
-race+ FIPS on SQLite and PostgreSQL at this tip (result in a comment below); 14 mutations (Detail), one equivalent. Not checked:standing_releaseandrewrap_user(next PR; the route already relays them, the broker refuses them as unknown here); the CLI commands (they need the §7.6 client); target-change deferral and lease reset evidence in enrollment (next PRs).Decided for you (
docs/DECISIONS.md56–58): only a deterministic auth failure at delivery quarantines (an unreachable target closes the lease without quarantine);manual_rotationinside the minimum age is refused after resetting the counter; any session may read a mailbox (a challenge needs thecnfkey, a delivery the requester's key).You need to: nothing.
§13 checklist: Phase 1A "
AccessTransactionforvault_checkout, …manual_rotation; approvals; possession proofs, lease, delivery, check-in, cleanup rotation". Acceptance 10 (all clauses) and the lease-cleanup clauses of 9, with a fake target. Stacked on #15.Detail
VerifyPoPTestProofOverAnotherTransactionOpensNothingTestStaleCredentialAtDeliveryQuarantinesTestLeaseBlocksSecondCheckoutAndDefersTheScheduleTestProofRechecksForAnOpenLeaseTestLeaseBlocksSecondCheckoutAndDefersTheSchedulecnfkeyVerifyPoPTestCheckinTriggersTheCleanupRotationTestExpiryCleanupSurvivesARestartTestRefusedCleanupRetriesAndManualRotationRearmsmanual_rotationburns its requestTestManualRotationmanual_rotationrefused during an active leaseTestOneOpenLeasePerAccountCleanupnever reads the counterReview fixes (25 Nov)
lease.go): addressed by keeping lease cleanup bound to its checkout. This builds the §3.3 target-change deferral for leases (the item listed as not built above): a lease records the policy and descriptor it opened under, its cleanup runs only there, a descriptor-changing policy waits until the lease closes and survives a restart, and the Control Plane stays consistent with the broker (DECISIONS 46a). Write intents keep their existing binding.Recoverre-send it, without a second login.TestLeaseCleanupStaysAtItsTargetAcrossADescriptorChangeTestCleanupIsBoundToItsDescriptorTestControlPlaneRefusesADescriptorChangeDuringALease,TestDescriptorChangeWaitsForTheLease(SQLite and PostgreSQL)TestLeaseUnderAReplacedPolicyDeliversNothing,TestDescriptorChangeWaitsForTheLeaseTestLeaseUnderAReplacedPolicyDeliversNothingTestLostDeliveryIsResentTestUnmirroredClosureBlocksTheNextCheckoutRestack, 25 Nov (round 2 on #10–#15)
POST /api/accounts/{id}/transactions,…/proofand…/checkinrelay throughListener.Relay(Enrollment and re-enrollment (§3.4, §4.5) #15), so they reach the broker whichever replica receives them; a queued relay expires after ten minutes.manual_rotationburns itsrequest_idwith the run's first durable state, which is nowreserving(Broker journal and rotation state machine (§4.2, §4.3, §4.6) #11). Lease health changes go throughsetHealth(Broker journal and rotation state machine (§4.2, §4.3, §4.6) #11).643755dwhen this was pushed.Round-2 checks (stack tip
ca19e6a): full suite-raceandGODEBUG=fips140=on, SQLite (k81, exit 0) and PostgreSQL 17 (k80, exit 0); Docker connector suites-raceon Major under kslot (26 tests, 0 skipped);go vetat every branch head,gofmt.Review fixes, round 3 (25 Nov, Guide "Cleanup stalls", "Unsupported action" at
a805e71)rotation_pending.Ticknow finishes and re-sends such a run through the samerecoverpath a restart takes (0ace209).standing_releasepath yet, so the submission refuses one with 422unsupported_action, and INTERFACES.md and theMsgTxcomment no longer list it (decision 76,05c8062).serve'sWaitGroup, so none outlives its connection (Broker-local rotation scheduler (§3.4, §4.4) #12 security fix).TestUnacknowledgedCleanupReceiptsResendOnTheNextTick(lease staysrotation_pending)standing_releaseis refused at submissionTestStandingReleaseIsRefusedAtSubmission(409 instead of 422)Checks (stack tip
05c8062): full suite-raceandGODEBUG=fips140=on, SQLite (k82, exit 0) and PostgreSQL 17 (k83, exit 0); Docker connector suites-raceon Major under kslot at96c38fd(30 tests, 0 skipped; nothing in the connectors changed after it);go vetand the broker, store and brokerproto tests at every merged branch head;gofmt.Round 3c (25 Nov): merged up
Listener.CloseAllon shutdown and Control Plane rotation storage and broker channel requests (§3.5, §4.3) #10's lock-before-check on retried envelopes and intents.Checks (stack tip
e8bdff0): full suite-raceandGODEBUG=fips140=on, SQLite (k83, exit 0) and PostgreSQL 17 (k80, exit 0);gofmt; Docker connector suites at96c38fd(30 tests, 0 skipped; no connector code changed since).Round 3d (25 Nov): merged up
MaxEnveloperoom for terminal receipts.Checks (stack tip
48af901): full suite-raceandGODEBUG=fips140=on: SQLite at0d637c4(k83, exit 0), withinternal/storererun at48af901(k82, exit 0), since only one store test changed after0d637c4; PostgreSQL 17 at48af901on Major under kslot with my ownpostgres:17-alpinecontainer, exit 0 (every K host was busy). Docker connector suites-raceat0d637c4(30 tests, 0 skipped, exit 0).gofmt.Round 4 (25 Nov): Guide "Missing completion",
mainmerged upmanual_rotationthat ran now writes the transaction mailbox:okonce the rotation reachedrelease_authorized, otherwise the run state it stopped in (for exampleaborted). Amanual_rotationthat re-armed a pending lease cleanup answersok. Refusals are reported as before. A result that fails to deliver is logged and not turned into a refusal, because the work is journaled.TestManualRotation,TestRefusedCleanupRetriesAndManualRotationRearmsChecks: at #8
ec97af5the full suite with-raceandGODEBUG=fips140=onpassed on SQLite (Major under kslot, exit 0) and on PostgreSQL 17 (Major under kslot with its ownpostgres:17-alpinecontainer, exit 0). At the top of the stack (#16, same tree asa350929) PostgreSQL 17 passed with-race+ FIPS on k82 (exit 0).gofmtandgo vet(also-tags docker) are clean at every branch head. The mutation proofs ran on throwaway copies. The top of the stack also passed SQLite with-race+ FIPS (Major under kslot, exit 0).Round 4b (25 Nov): Guide "Lost results" at
a350929manual_rotationrun now records its request ID (Run.Request). Once the run ends with its receipts acknowledged, or stops atwrite_outcome_unknown, its result is queued in the account's journaledResults. A re-armed cleanup queuesokin the same journal save as the re-arm.flush, whichTickandRecoverboth call, delivers the queue until the Control Plane acknowledges each entry, so a failed delivery or a restart no longer loses the result (779afb5).flushskips the resultsTestManualRotationResultIsResent(k81)Checks (round 4b): at #8
f212849and at #16bdb9adf, the full suite with-raceandGODEBUG=fips140=onpassed on SQLite (Major under kslot; every K host was busy) and on PostgreSQL 17 (Major under kslot, ownpostgres:17-alpinecontainer), all exit 0. #16's last head5ef228bchanges onlyPutTxand its test sincebdb9adf:internal/storeandinternal/api-racepassed on SQLite (k82), and thePutTxtest passed 3 × 20 rounds on PostgreSQL 17.gofmtandgo vet(also-tags docker) are clean at every branch head. The mutations ran on throwaway copies.Round 4c (25 Nov): Guide "Interrupted delivery" and "Lost outcome" at
5ef228bDeliveringfrom its open until the wrap is journaled (f612ba1).flush, whichTickandRecoverboth call, closes a lease still delivering asinterruptedand reports that result, so a crash mid-delivery no longer blocks the account until expiry. Nothing was wrapped, so no credential left the broker.endDeliveryqueues the refusal inResultsin the same save as the closure, and the existing retry delivers it.flushTestInterruptedDeliveryClosesTheLeaseTestDeliveryRefusalResultIsResentChecks (round 4c): at #16
9fb8788, the full suite with-raceandGODEBUG=fips140=onpassed on SQLite (Major under kslot) and on PostgreSQL 17 (Major under kslot, ownpostgres:17-alpinecontainer), both exit 0.gofmtandgo vet(also-tags docker) are clean at every changed branch head. The race tests ran on PostgreSQL 17 in my own container; the mutations ran on throwaway copies.Round 5 (25 Nov): Guide "Premature refusal" and "Lost refusals" at
9fb8788Proofreturns nil, so nothing is published as the result, andflushre-sends the wrap (55f09a1).App.transactionreports goes throughMachine.Refused. That journals it in a newrefusalsbucket and sends it.TickandRecoverre-send it until the Control Plane acknowledges it. A refusal the Control Plane rejects (RemoteError) is dropped, a later accepted message for the same request drops the stale refusal, and the bucket holds at most 1,024 (DECISIONS 79).s.route. Submitting one needs a five-minute step-up; the mailbox read, the proof and the check-in aresession(DECISIONS 78).tick, under the same mutex hold as its selection. The exportedCleanupis gone (Tickwas its only caller).deliverTestLostDeliveryIsResentTestRefusalsAreJournaledUntilAcknowledgedfresh(StepupWindow)from submitTestBrokerActionsNeedAFreshStepUpChecks (round 5): at
1cc8242/ae735c7(the same code; headae735c7adds onlymain's merge of #11),go vetand the full suite with-raceandGODEBUG=fips140=onpassed on SQLite (Major; every K host busy) and on PostgreSQL 17 (Major under kslot, ownpostgres:17-alpinecontainer), both exit 0. That head includes #12's "Stalled rotations" fix:tickrecovers any stopped open run, including cleanup runs.gofmtis clean. #11 (bottom) passed the same suite at251118d. The mutations ran on throwaway copies.Round 5b (26 Nov): Guide "Lost result" and "Stale refusal" at
ae735c7startqueues the outgoing run'smanual_rotationresult before a new run replaces it. A manual run finished by a tick that then starts a due scheduled occurrence keeps its outcome (5e34c20).SetTxMailboxclears the earlierresultwhen a new challenge is posted. A successful retry no longer reads as refused (5e34c20).resultsinstartTestRecoveredManualRotationKeepsItsResultTestANewChallengeClearsTheEarlierResultChecks (round 5b): at
2af3ab2,go vetand the full suite with-raceandGODEBUG=fips140=onpassed on SQLite (Major; every K host busy) and on PostgreSQL 17 (k81), both exit 0. The mutations ran on throwaway copies.Round 5c (26 Nov): Guide "Stale refusal" (check-in) at
2af3ab2checkinProofnow queues "ok" inResultsin the same journal save as the state change, and re-sends it until it is acknowledged (2f38e14). Every other accepted path already replaces the result: a new challenge clears it, and a delivery sets "ok". Merged Enrollment and re-enrollment (§3.4, §4.5) #15's "Unusable Retry" fix.TestCheckinTriggersTheCleanupRotationChecks (round 5c): at
af7229e,go vetand the full suite with-raceandGODEBUG=fips140=onpassed on SQLite and on PostgreSQL 17 (both on Major, every K host busy; PostgreSQL in my ownpostgres:17-alpinecontainer under kslot), exit 0. The mutation ran on a throwaway copy.🤖 Generated with Claude Code