Repository navigation
Make destructive-rollback approval tokens single-use and protect the key file - #149
Merged
Merged
Conversation
|
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. |
The approval key file could be readable by group or other, and an approval token could authorize more than one destructive rollback inside its time window. agenticd now refuses to start when the key file has group or other permission bits, and each token is accepted for at most one non-dry-run rollback per daemon process, tracked by its decoded HMAC tag. ADR-0014 gains an amendment describing both changes and the per-process limit.
The key-file mode check ran before the read and empty checks, so an empty 0644 key file or a path that opens but cannot be read now aborted startup instead of starting with destructive rollback disabled. The mode check now runs last, on the same handle. ADR-0014 no longer says a token can be replayed within its window, and notes that the mode check does not protect against a process sharing the daemon's uid.
Reading one byte past the key length is enough to reject a wrong-length file, so a misconfigured path to an endless source cannot exhaust memory. ADR-0014 Decision 6 now matches Decision 4 for empty files.
tonibergholm-codento
force-pushed
the
approval-token-hardening
branch
from
November 20, 2026 07:28
c68fa08 to
f1bf3cb
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The ADR-0014 approval gate had two gaps. The daemon loaded an approval key file that other local users could read, and any of them could then mint tokens. A valid token also authorized any number of destructive rollbacks until it expired.
The daemon now refuses to start when a non-empty key file has any group or other permission bit. A missing, unreadable or empty file still starts with destructive rollback disabled, as before. Each token now authorizes one destructive rollback per daemon process: a ledger keyed by the decoded HMAC tag rejects reuse as
rejected_replayed, and entries expire at the token's own timestamp plus the TTL. Dry runs check the token without using it up. ADR-0014 has a dated amendment, and its Decisions 3, 4 and 6 now match the code.Limits: the ledger lives in memory, so a restart or a second instance accepts a token again. The mode check only stops readers under other uids.
Proof: new tests cover the key-file mode, empty and directory key paths, single use, dry runs that keep the token, replay through different encodings of the same token, and ledger pruning. They fail without the fix.
cargo fmtandcargo test --workspacepass.Reviewed with sol-loop: 3 rounds with gpt-6.2-sol. Sol verdict: approved. Mythos 5.2 security review: approved.
Created with Claude Opus 5.5 and Claude Sonnet 5.5 in Claude Code.