Skip to content

server: a secret's authority is not rechecked for a replaced pty or a role switch during the screen read #589

Closed

Description

@devswha

From the Codex adversarial pass on #588 (finding 2 there), confirmed by the reviewer by reading the code; not reproduced with a test yet. Older than #588, and outside what that PR fixes (a sender that detached and rejoined a shared attachment).

The secret handler in server/index.ts awaits a live-screen read (pane.read) before it types the secret. After the read it re-checks the connection, the attachment identity and membership, readiness, and (from #588) the sender's attach claim. Two things can still change during the read without failing those checks:

  1. The pane's pty is replaced under the same attachment (a live handoff after a herdr update), so attachment.pty.write goes to a pty other than the one the sender saw.
  2. The sender switches interact -> observe -> interact while the read is pending; the mode check passes again on the way back.

In both cases it is still the same pane and the sender's own submitted secret, and the prompt is validated on the live screen, so the exposure is small; the point is that the authority to type is not the one captured when the secret was accepted.

Suggested fix: capture the pty identity and a role generation with the claim when the secret is accepted, and compare all of them after the read (answer input_not_ready / read_only). Add contract cases next to the detach/rejoin one #588 adds in server/submit.contract.test.ts.

Related: #566, #576, #588. Review: #588 (review)

Activity

  1. devswha commented on Oct 8, 2026

    @devswha
    OwnerAuthor

    One more window, from the pre-release Codex (gpt-6-astra) review of v0.4.0..6993563, confirmed by reading the code (not reproduced with a test here):

    On a mirrored pane the secret handler re-checks the sender's claim after the screen read (#588), but not between paneSendText(secret) and paneSendKeys(["Enter"]) (server/index.ts, the attachment.mirror branch). A sender that detaches and rejoins a still-alive attachment while the text RPC is pending gets its Enter sent anyway, and the answer is ok: true.

    In the #588 review this was judged not worth blocking on: once the text is in the prompt, withholding Enter leaves the secret typed there for whoever presses Enter next. The fix belongs with the rest of this issue: carry one captured authority (claim, pty identity, role generation) through the whole send, and if it changes after the text, clear the line rather than leave the secret in it.

  2. devswha commented on Oct 12, 2026

    @devswha
    OwnerAuthor

    The parts of this issue that main already covers are done. The remaining work moves to #900, so this issue can close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions