Repository navigation
fix(repo): seal only to recipients this clone accepted, so a writer cannot add themselves - #368
Conversation
Protection rules, secret wrap lists and private-branch KEK wrap labels are repository data, so a writer with no key could grant their own key and wait for the victim's next commit, merge or replay reseal, rewrap, secret rotate or branch revoke to wrap a DEK to them. .sc/accepted-recipients is a local record of the recipient ids accepted per scope (path:<prefix>, secret:<NAME>, branch:<name>); local [escrow] keys count everywhere. encrypt_protected, the one function that turns a rule into wraps, refuses before sealing anything when a key is not accepted for the winning rule's prefix. sc protect validates the candidate rule before its first ref move, secret_rotate and branch_revoke check the final set, and rewrap skips an entry with an unaccepted key. Carries that copy existing wraps are not gated. Keys named by the caller are accepted on the spot (protect, grant, secret add/grant, branch --private, branch grant); the local revoke operations drop the pair. The record is written atomically under the repo lock and is never committed, packed or transferred. The test seams that hand-build rules accept the keys they name. Refs ADR-0059.
sc policy accept <scope> --key <scl-pk|id>[,...] records recipients in the local .sc/accepted-recipients; a key in neither [recipients] nor [escrow] needs --allow-unknown. sc policy forget removes one. Both touch only the local file, so they work while a merge, pick or rebase is stopped and a refused completion can be retried. sc secret rotate --to accepts the keys it names, since the library cannot tell a named set from one derived from the secret's own wrap labels. The rewrap hint now mentions the accept route for skipped entries. Refs ADR-0059.
Records the problem, the local accepted-recipients record, the gate sites, the auto-accept rule, the migration, the alternatives rejected (seal only to recipients.toml; signed policy) and the deferred items and residual risks. Adds the matching THREAT-MODEL entries (Protected paths, with one line each under Committed secrets and Private branches), a CLAUDE.md standing-boundary bullet, the ADR index row, and status pointers on ADR-0025 and ADR-0027.
Escrow keys are no longer recorded as approvals. protect and secret add persist only the keys the user named (the library drops the keys currently in [escrow] from what it records, the CLI records the named ones), and private branch creation records the creator and the named recipients only, so removing a key from [escrow] withdraws its acceptance. The three local revokes drop the approval after validation and before the new ref is published, so an interruption cannot leave an approval outliving a landed revoke. sc policy accept validates the whole batch and writes the record once; a path: scope with an id that has no key behind it is an error even with --allow-unknown. Refusal messages escape every repository-controlled field with sanitize_display_line and print no command for a scope with control characters. A Remove target that starts with "-" is written flags first and after "--". The shared seal path loads the record only when something is sealed, and rewrap loads it at the first entry that wraps anything, so a commit that wraps nothing no longer depends on the record being readable. The ADR notes that the record's integrity depends on the working-tree path guard.
…ment revoke gap The suggested Remove command is always "flags, --, target", so a target that starts with "-" cannot be read as a flag (the check ran after quoting before, so it never fired). The shell quoting is POSIX only, as its comment says. sc rewrap prints its skipped entries through sanitize_display_line: they carry paths and names from the repository. sc policy accept warns when a path: scope names no rule at the tip, and still records it. An ignored test (needs PR #367) pins that a cloned tree holding .sc/accepted-recipients or .sc/recipients.toml is refused, since the record's integrity does not rest on this change alone. ADR-0059, THREAT-MODEL and ROADMAP record the residual risk that a revoke made in another clone leaves this clone's acceptance in place, and the follow-on of recording the grant epoch with each path: pair.
…ecrets in rewrap rewrap skips a registry entry sealed under another name before opening it, as secret_rotate refuses it: it would otherwise be approved by the registry name and resealed under the sealed name, so a relabeled secret got wraps under another secret's approvals. protect_with_escrow and secret_add_with_escrow take the keys the user named apart from the escrow keys a command appends. protect stages the named keys in memory while it validates the rule and the sealing commit, records them after validation and before either ref moves, and a refusal leaves record, refs and oplog alone. secret add records the named keys before its ref moves. The CLI no longer records after the operation landed. The record is written with atomic_write_durable (fsynced temp file, rename, fsynced directory), as durable as the ref write. rewrap reads the record only for an entry that mints a wrap: a secret that opens, a path re-sealed or rotated, or a target with no wrap yet. A randomized path whose every wrap is reused copies them and needs no approval. The refusal text says what is true: no ref moved and no approval was recorded. sc protect --list, sc secret list, sc branch list and sc policy accept/forget print repository text through sanitize_display_line.
…nc unchanged records protect no longer stages approvals on the Repo handle. snapshot_files_with takes the approval source as a parameter and protect passes the keys it is about to record for that call only, so no other operation on the same handle can see them. snapshot_files keeps its signature and reads the record. secret grant refuses a registry entry sealed under another name before it records an approval or wraps anything, as rotate and rewrap do. rewrap checks a path re-seal against the record only after the ciphertext has opened, so a corrupt blob is skipped as that when the record is unreadable. An accept or forget that changes nothing still fsyncs .sc, so a retry after a failed directory sync cannot report success on an unsynced record.
…orization, lock the record secret grant opens the secret with the identity before it records or wraps anything. The registry key and the name in the secret's metadata are both repository data and can be made to agree, but the AEAD binds the name the secret was sealed under, so an edited name fails to open and the grant is refused. grant, secret grant and secret rotate --to record the named key only after the identity is authorized and the operation validated, still before the ref moves. secret_rotate_with takes the named keys as call-local approvals, and the CLI passes them instead of recording first, so a refused command leaves no approval. accept and forget read, change and write the record under .sc/index.lock, so callers on one handle cannot lose each other's change. ADR-0059 records the declined residual: an interruption after the approval write and before the ref move leaves an approval for a key the user named on that command.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
tonibergholm
left a comment
There was a problem hiding this comment.
Reviewed: design by Mythos and reviewed by Sol; implementation reviewed with sol-loop (5 rounds, approved) and a Mythos security review; all checks green; Codex review has no findings.
Protection rules, secret wrap lists and private-branch key labels are unsigned repository data, so any writer could make themselves a recipient. A writer without a key could commit a narrower
sc protectrule granting only their own key. After a merge or a fast-forward, the victim's next commit sealed changed files to the attacker, andsc rewrapre-wrapped existing keys to them. A teammate listed inrecipients.tomlcould also append a bogus wrap label and be included in the nextsecret rotateorbranch revoke. Nothing in merge, log or diff output showed any of this.This adds a local, never-transferred record,
.sc/accepted-recipients, and checks it wherever a key from committed data is actually wrapped (ADR-0059, amending ADR-0025 and ADR-0027).Where it is checked.
encrypt_protected: commit, amend, merge, pick and rebase completion,sc wsharvest and refresh,sc work, cherry-pick, rebase andbranch publish.sc protect, which checks before any ref moves.sc secret rotate,sc secret grant,sc rewrap(an unaccepted entry is skipped and the command exits 1) andsc branch revoke.What counts as accepted.
[escrow]list, read at check time and never recorded.sc policy accept <scope> --key <key>.sc policy forget <scope> <key>removes one. A local revoke also removes the pair.Refusals. A refusal names the scope, the key and its local name, and prints the exact accept and revoke commands, escaped. Repository text is escaped in the related listings too.
Hardening from review.
secret grant,rotateandrewraprefuse a registry entry whose name differs from the name the secret is authenticated under.sc protect --listexits quietly on a closed pipe.Migration. The record starts empty and is not seeded from the tip, since the tip may already be poisoned. In each existing clone, the first seal to a key this clone has not named or accepted refuses and lists what to accept. CI should provision the record from trusted configuration. All 14 demos pass unchanged, because they name their keys.
Not covered (documented in the ADR, THREAT-MODEL and ROADMAP).
.sc/path guard (fix(checkout): stop a cloned tree from writing into .sc/ or escaping the checkout #367).Proof: 20+ tests in
accepted.rsandcrates/cli/tests/policy_accept.rs. The core gate tests failed with the gate disabled. They cover:recipients.toml)protectaccepting its own keys but refusing a foreign one before a ref movescargo test -p scl-repo -p scl-clipasses, and so do the revoke, protect, rewrap, private-branch and lifecycle demos after the rebase.Reviewed with sol-loop: 5 rounds with gpt-6.2-sol. Sol verdict: approved. Mythos designed the mechanism, and Sol reviewed the design before implementation. A Mythos security review of the implementation found the message escaping and the dependency on the path guard; both are addressed.
Created with Claude Opus 5.5 and Claude Sonnet 5.5 in Claude Code.