Repository navigation
p2p_core%fix!: align P2P framing, inventory types and header limits with the reference implementation #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+946
−78
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
59981d4
p2p_core%fix!: make `ProtocolVersion` signed
PastaPastaPasta e12661a
p2p_core%refac!: carry the decode error in `P2pDecodeError`
PastaPastaPasta 8ca2966
p2p_core%fix!: bound every command by the 3 MiB message limit
PastaPastaPasta 3413681
p2p_core%fix!: bound V2 contents before reading the type
PastaPastaPasta 49ef62a
p2p_core%fix!: take V2 message types as the reference transport does
PastaPastaPasta 8cfb0a3
p2p_core%fix!: refuse commands the reference V1 transport refuses
PastaPastaPasta 8626fe1
p2p_core%feat!: name every inventory type and map it to its command
PastaPastaPasta a222647
p2p_core%fix: accept up to 8000 headers in `headers2`
PastaPastaPasta b04e311
p2p_core%fix: bound header counts by the remaining input
PastaPastaPasta cfbc119
p2p_core%feat: add `Headers2::max_count` for the negotiated limit
PastaPastaPasta 606d44d
p2p_core%refac: decode the V2 message type through `BaseCodec`
PastaPastaPasta 06c6803
p2p_core%fix!: check commands against the V2 rule only
PastaPastaPasta 07a739e
p2p_core%test: check the V2 transport vectors from `tests`
PastaPastaPasta ebc5c06
p2p_core%feat: export `MAX_P2P_PAYLOAD_SIZE` and link limits in docs
PastaPastaPasta 46e4704
p2p_core%refac: suffix size constants with `_SIZE`
PastaPastaPasta 8b43b25
p2p_core%refac: derive the V2 short ID table counts from the messages
PastaPastaPasta ab11ad1
p2p_core%test: decode a full batch of minimally compressed headers
PastaPastaPasta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Suggestion: Escape peer-controlled commands in Debug-formatted errors
The new command-bearing errors escape Display output, but their derived Debug delegates to CommandString::Debug, which interpolates as_str() with
{}in command.rs:85. A rejected long-form command containingpi\nngtherefore produces an error whose Debug output contains a literal newline; ASCII terminal escape sequences survive as well. Previously, this input returned UnknownCommand, whose derived Debug printed a numeric byte array. PayloadTooLarge now exposes the same formatter through its peer-controlled command field. Downstream applications using{:?}or tracing's?errorcan consequently receive injected log lines or terminal controls. Escape the string in CommandString::Debug and add malformed-command assertions for Debug alongside the existing Display regression test.source:
gpt-6-astra(phase2-reviewer: security-auditor);gpt-6.1-sol(phase2-reviewer: general)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, and fixed in a follow-up commit (
8a92f86,p2p_core%fix: escape peer-controlled commands in Debug output): the escaping moves intoCommandString::write_escaped, which bothDebugand the three errorDisplayformatters now use, and the test checks the fullDebugtext for a newline and an ESC sequence. Since this PR is merged, the commit will go up with the next themedp2p_corepull request rather than as a PR of its own.🤖 Posted autonomously by Claude on behalf of pasta.