Skip to content

backup: broker CA in the capsule; restore clears every credential (§9.4) - #26

Merged
Yoshiofthewire merged 8 commits into
mainfrom
kyguard/restore
Nov 25, 2026
Merged

Yoshiofthewire merged 8 commits into
mainfrom
kyguard/restore

Conversation

@Yoshiofthewire

@Yoshiofthewire Yoshiofthewire commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

In one line: Capsules now carry the internal broker CA, and a restored copy starts with no leftover credentials: sessions, CLI login codes and unspent broker pairing tokens are all deleted.

What changed

  • backup.Collect packs data/broker-ca.key and data/broker-ca.crt when the data directory has them, sealed with the rest. One without the other refuses to seal (DECISIONS 19d).
  • kyguard-server restore deletes every CLI login code and every unconsumed broker pairing token, along with the sessions it already deleted. Consumed tokens stay as pairing history (19e). Both tables are cleared only when present, so older capsules still restore.
  • A SQLite round-trip test joins the existing PostgreSQL one for acceptance 13: state matches, the audit chain verifies under the restored key, the CA comes back, startup passes and the break-glass admin signs in.
  • Not built: the recovery-manifest seal gate (§9.4 item 2). It needs juniper's verified RecoveryKeyManifest (KyGuard trust root and manifests (§3.2, §3.3, §3.7) with vectors #4), which is not joined to this stack. Built fail-closed here, it would refuse every pin and backup; built fail-open, it would be a hole if merged alone. DECISIONS 19f; it is a join task.

Review this

Checked: full suite with -race, plus the FIPS profile, on SQLite and PostgreSQL 17 at c22484f. All 4 mutations below fail their tests.
Not checked: the startup checks on a restored CA (key matches certificate, pinned broker hashes, leaf regeneration). They need the broker stack's tables and are left for the join.
You need to: review. Held unmerged by rule.

§13 Phase 0 checklist: KyGuard tables in migrationTables; seal gate on every entry point; restore contract (§9.4): the restore contract and the CA in the capsule. The seal gate is not done. Acceptance 13, except the broker-CA mismatch clause. Acceptance 14 is not done.

Detail

Mutation table (each mutation makes the named test fail)

# Property Mutation Failing test
R1 The broker CA travels in the capsule do not append the CA files TestSQLiteBackupRestoreRoundTrip
R2 Half a CA is never sealed drop the one-file check TestCollectCarriesTheBrokerCA
R3 Restore deletes CLI login codes drop that delete TestRestoreDeletesEveryBearerCredential
R4 Restore deletes unspent pairing tokens delete none TestRestoreDeletesEveryBearerCredential

Checks at c22484f

  • gofmt, go vet, go build, go test -race -count=1 -p 2 ./... and the same under GODEBUG=fips140=on: SQLite pass (k83), PostgreSQL 17 pass (Major, own postgres:17-alpine container). Rebased on the review fixes below it.

Stack

#1 → #3 → #7 → #17 → #18 → #19 → #25 → this.

Stack merge (hawthorn fix-auth-3): head 37c2cb4 merges kyguard/intents (plain merge commits, no rebase; f99f878 merged it first, and 37c2cb4 adds a content-free merge of the pushed commit below), so this PR carries #7's fail-closed SSO sign-in (9220dd7) and every fix below it. The only conflicts were in docs/DECISIONS.md, and both sides were kept. Go vet passes at this head; CI runs the suites.

Round 4 (hawthorn): main merged; restore test uses a real broker CA

Checks: race + FIPS on SQLite and PostgreSQL 17, at the bottom (#18 @ bd2fb58: SQLite k81 exit 0, PostgreSQL own container exit 0) and the top (#28 @ 0cb6d83: SQLite k82 exit 0, PostgreSQL own container exit 0). Affected packages were also run at this head on k82.

🤖 Generated with Claude Code

@Yoshiofthewire

Yoshiofthewire commented Nov 25, 2026 •

Copy link
Copy Markdown
Member Author

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪

🧪 PR contains tests

⚡ No major issues detected


Advisory only: this comment never gates the pull request.
gpt-6.1-sol using pr-agent on behalf of Yoshi

@Yoshiofthewire

Yoshiofthewire commented Nov 25, 2026 •

Copy link
Copy Markdown
Member Author

Security review - cleared

Detail 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-26, where it is readable by the operator and expires seven days after the last post.


claude-opus-5-5 using security-audit on behalf of Yoshi

@Yoshiofthewire

Yoshiofthewire commented Nov 25, 2026 •

Copy link
Copy Markdown
Member Author

Autonomous review - 1/1 personas cleared

  • security: cleared

Merging remains a human decision; this bot never approves.


claude-opus-5-5 using security-audit on behalf of Yoshi

Spec §9.4: the capsule carries the internal broker CA key and
certificate when present (half a pair refuses to seal), and a restore
deletes CLI login codes and unconsumed broker pairing tokens with the
sessions, for whichever of those tables the capsule has. A SQLite
round-trip test joins the PostgreSQL one for acceptance 13: state
matches, the chain verifies under the restored key, the CA comes back,
startup passes and the admin signs in.

The recovery-manifest seal gate waits for the trust stack (DECISIONS
19f).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Yoshiofthewire and others added 7 commits November 25, 2026 09:29
…to kyguard/restore

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Picks up the stack's merge commits as pushed. No content change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The test planted placeholder strings as broker-ca.key/.crt. With #8
merged, prepareStart loads the broker CA, so the restored server refused
them. The test now creates a real CA and checks that the restored files
are byte-identical and that the restored server starts with them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Yoshiofthewire
Yoshiofthewire changed the base branch from kyguard/intents to main November 25, 2026 23:41
@Yoshiofthewire

Copy link
Copy Markdown
Member Author

Merger (saltmarsh-merge): closing and reopening right away so CodeQL runs now that the base is main. The branch is unchanged.

@Yoshiofthewire
Yoshiofthewire merged commit 25ad5da into main Nov 25, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant