Repository navigation
fix(terminal): recheck mirror secret authority before Enter - #1065
Merged
Merged
Conversation
Guard the committing key after its RPC connects. If authority lapsed after typing, erase the typed characters and report not_attached or read_only instead of submitting. Cover normal delivery, detach/rejoin, observe, observe-and-return, and loss while Enter connects with real masked shell reads. Raw-mode readers may consume Backspace bytes without erasing their own buffer. Plan: .omo/plans/issue-sweep-2026-10-14.md
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 57 seconds. View limit details
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. Comment |
Fix the blocking PR #1065 review finding: UTF-16-counted Backspaces left Unicode secret bytes in canonical input. Use Ctrl+U and verify byte-exact multibyte cancellation in the existing submit contract tests.
Fix the blocking PR #1065 Unicode cleanup finding without relying on Ctrl+U, which does not clear Windows cooked input. Reject mirrored non-ASCII secrets before typing and retain Backspace cleanup for ASCII; leave PTY-attached secrets unchanged.
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.
Fixes #900
Root cause
server/index.ts(theattachment.mirrorbranch of thesecrethandler, ~L3161-3171 on main): theallowedauthority guard was passed only topaneSendText. After the text RPC returned,paneSendKeys(pane, ["Enter"])ran with no guard and no recheck. A sender who detached and rejoined, switched to observe (and back), or lost the attachment/pty while the text was being typed still had its secret submitted and was answeredok: true.What changed
paneSendKeys(..., allowed)path that keystroke batches use (server: a queued chord or text can still write after its sender's authority lapses during the RPC connect #545), so authority is rechecked after typing and again once the Enter RPC has connected.Backspaceper character (an unguarded cleanup, so the secret is not left on the prompt line for someone else's Enter). The sender getsread_onlywhen its role changed, otherwisenot_attached.changelog.d/mirror-secret-authority.md.Residual
A raw-mode reader receives the Backspace bytes but may not erase its own input buffer. Cleanup counts the submitted string's length and is not an atomic compare-and-erase against another device typing in the same pane at the same moment.
Tests
New contract cases in
server/submit.contract.test.tsrun a real maskedread -sin a mirrored pane (terminalAttach: false), with a second client keeping the mirror alive:none: normal delivery answersok: true, and the reader gets all 12 characters. controlrejoin: detach + reattach while the text RPC is held. regression (fails on main)observe: switch to observe while the text RPC is held. regression (fails on main)observe-back: switch to observe and back. regression (fails on main)enter-connect: detach + reattach while the Enter RPC connects. regression (fails on main)Each regression case expects a refusal (
not_attached/read_only), then typesX+ Enter itself and requires the reader to report length 1, which proves the secret was erased rather than left in the buffer.Before / after
server/index.tsand the new test: control passes; the 4 stale-authority cases fail because the server answered{ ok: true }and submitted the secret.Checks run
bun run typecheck: passHERDR_TEST_MODE=unit bun test ./server/conventions.test.ts ./scripts/conventions.test.ts ./scripts/changelog-fold.test.ts: 31 pass, 0 failbun test ./server/submit.contract.test.tson an isolated herdr session: 66 pass, 0 failbun run test:unit(3515 pass, 0 fail) andbun run check fast(pass).