Skip to content

Terminate on unsupported challenge version instead of sending code 2 - #40

Open
markmnl wants to merge 1 commit into
mainfrom
fix/terminate-unsupported-challenge
Open

Terminate on unsupported challenge version instead of sending code 2#40
markmnl wants to merge 1 commit into
mainfrom
fix/terminate-unsupported-challenge

Conversation

@markmnl

@markmnl markmnl commented Aug 10, 2026

Copy link
Copy Markdown
Owner

Design correction from spec review (markmnl/fmsg#29, 49585f7): the listener's response to an unsupported first byte must depend on who is listening on the other end.

  • First byte ≤ 128 (unsupported message version): the peer is a sending host whose first read on Connection 1 is always a response code — REJECT 2 is unambiguous and informative. Unchanged.
  • First byte > 128 (unsupported challenge version): the peer is a challenger whose next read is exactly the 32-byte CHALLENGE-RESPONSE hash. A 1-byte code written into that stream is indistinguishable from the first byte of a hash (0x02 is a valid hash prefix); the challenger only discovers the truth via a short read at EOF — a protocol error either way. The spec therefore mandates TERMINATE without responding, and readVersionOrChallenge now closes without writing on this branch.

The earlier v0.5.0 spec draft had unified both branches to code 2 (matching fmsgd's then-behaviour); the spec has been corrected to keep the original TERMINATE for the challenge branch, and this PR brings fmsgd in line.

🤖 Generated with Claude Code

A challenger's next read after sending CHALLENGE is exactly the
32-byte CHALLENGE-RESPONSE hash, so a response code written into that
stream is indistinguishable from the start of a hash. Close without
responding (SPEC SS10.5); code 2 remains for unsupported MESSAGE
versions, where the peer's first read is always a response code.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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