Skip to content

Make destructive-rollback approval tokens single-use and protect the key file - #149

Merged
tonibergholm-codento merged 3 commits into
mainfrom
approval-token-hardening
Nov 20, 2026
Merged

tonibergholm-codento merged 3 commits into
mainfrom
approval-token-hardening

Conversation

@tonibergholm-codento

Copy link
Copy Markdown
Collaborator

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 fmt and cargo test --workspace pass.

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.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fe2d1ee4-991a-4b70-8493-8e912065c42c
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T07:28:59.424774Z f1bf3cb New commits
🔒 Security Review ✅ Completed 2026-11-20T07:31:29.483258Z f1bf3cb New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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
tonibergholm-codento merged commit ededf2b into main Nov 20, 2026
14 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