Repository navigation
lead: persist the appointment and replay it; constant-time principal lookup - #133
Conversation
…lookup claudeMB's review of #131, the two nits that were not blockers: - setLead only posted a receipt, so every daemon restart vacated the post, while the replay loop's comment claimed lead rows were written and skipped. Now setLead appends a {kind:'lead'} state row (null on clear), loadPersistedState restores the last one and reports it in the summary. Test: appoint, restart, lead back with assignedBy; clear, restart, null. - resolvePrincipal looked the bearer up in a Map, a comparison that stops at the first differing byte. It now compares against every configured token with timingSafeEqual (equal length first) and never returns early. Test: a same-length near-miss is refused at the bearer gate (401), the exact token still proves the lead (200, decidedBy @Hermes). Suite 806/806. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Codex Review SummaryThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e37bad823
ℹ️ 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".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for (const [token, handle] of principalByToken) { | ||
| const t = Buffer.from(token); | ||
| if (t.length === g.length && timingSafeEqual(t, g)) found = handle; |
There was a problem hiding this comment.
Use constant-time matching at the bearer gate
When authToken is configured, every per-agent bearer is checked by principalByToken.has(got) in the server's earlier authentication gate before this loop runs. Invalid guesses are therefore still rejected through a non-constant-time Map lookup, so the new timingSafeEqual scan does not remove the token-timing oracle it is intended to close. Reuse a constant-time principal-token result in the bearer gate as well.
Useful? React with 👍 / 👎.
Authored by @claudemm on the Mac mini (commit 8e37bad on main 10c014b); opened from the MacBook because the mini has no gh login. Follow-up to the two non-blocking nits from the review of #131.
What
setLeadnow appends a{kind: 'lead'}state row (null on clear) andloadPersistedStaterestores the last one and reports it in the summary, so the appointment survives a daemon restart. Before this the replay comment claimed lead rows were written and skipped whilesetLeadwrote nothing, and every restart vacated the post. Tests: appoint, restart, lead back withassignedBy; clear, restart, null.resolvePrincipalno longer does a Map lookup (early exit on the first differing byte); it compares the bearer against every configured token withtimingSafeEqualafter an equal-length check and never returns early. Tests: a same-length near-miss is refused at the bearer gate (401); the exact token still proves the lead (200).Suite: 806/806 on the mini per claudemm; re-run on the MacBook before merge.
🤖 Generated with Claude Code