Repository navigation
Add origin.peek() so a listener can route a datagram to the right secret - #21
Merged
Merged
Conversation
A listener that follows one board can verify every datagram with the one secret it holds. A listener that follows twenty cannot: it has to know which board is claiming to have sent a datagram before it can pick the secret to check it against. Identifying the sender by its source address is the obvious shortcut and the wrong one -- NAT between a board and the listener rewrites it, and the signature, not the address, is what establishes who sent the datagram. peek() decodes the body without verifying it, for routing only. Its docstring is blunt about what that means: nothing it returns is trustworthy until unpack() has been called with the secret it led you to. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VmtVSp58rDkDBRPzL9hJkt
Coverage report✅ Total coverage: 100.00% (0.00% vs base |
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.
What
A listener following one board can verify every datagram with the one secret it holds. A listener following twenty cannot — it has to know which board is claiming to have sent a datagram before it can pick the secret to check it against.
origin.peek(packet)decodes the body without verifying it, for routing only:Why not just use the source address
That's the obvious shortcut and it's the wrong one. NAT between a board and the listener rewrites the source address — which is exactly what Origin hits running Ray on the Docker bridge, and what any port-forwarding setup hits. More fundamentally, the signature is what establishes who sent a datagram; the address was never doing that job, it was just standing near it.
On handing out an unverified decode
peek()returns attacker-controlled data on an open network, so the docstring says so plainly and points atunpack()as the step that establishes trust. Parsing before verifying is safe as long as nothing is believed before verifying — the JSON decode itself is not a trust decision, and the alternative (duplicating the frame layout in every consumer) is worse for exactly the reason this module exists._split()and_decode()are factored out sopeek()andunpack()cannot drift apart on framing or malformed-input handling.Testing
python -m pytest— 299 passedruff check .— cleanpeek()explicitly does not authenticate (a forged datagram peeks fine and then failsunpack()), and malformed/non-object frames.Notes
Version 0.3.1 → 0.4.0. Consumed by the Origin change that switches Ray from source-IP identification to
machine_idfrom the signed body.🤖 Generated with Claude Code
https://claude.ai/code/session_01VmtVSp58rDkDBRPzL9hJkt
Generated by Claude Code