Repository navigation
[0.11.x] proto: reject transport parameters with a mismatched length - #2866
Merged
djc merged 1 commit intoSep 10, 2026
Merged
Conversation
The decoding loop in TransportParameters::read reads each parameter's length field, but three of its arms never check that the value really occupies that many bytes. MaxDatagramFrameSize only rejects a length above 8, MinAckDelayDraft07 checks nothing, and PreferredAddress decodes a fixed number of bytes for a given connection ID length. Surplus bytes stay in the buffer and the next turn of the loop decodes them as if they were the next parameter. A peer can use that to smuggle in a parameter it never encoded. Sending max_datagram_frame_size with a length of 3 and the value bytes 00 0c 00 leaves 0c 00 behind, which is a complete disable_active_migration. Compare the declared length against the number of bytes consumed once, after the match, so the check covers every arm. Cover each of the three arms with its own test: read_length_mismatch, read_min_ack_delay_length_mismatch and read_preferred_address_length_mismatch each build a byte string for their case and expect Err(Error::Malformed).
MaxFreedomPollard
requested review from
Ralith,
djc and
gretchenfrage
as code owners
September 10, 2026 13:15
djc
approved these changes
Sep 10, 2026
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.
Backport of #2832 to 0.11.x, which djc asked for on that PR.
TransportParameters::readreads each parameter's length field, but three arms of its decoding loop never check that the value really occupies that many bytes:max_datagram_frame_sizeonly rejects a length above 8,min_ack_delaychecks nothing, andpreferred_addressdecodes a fixed number of bytes for a given connection ID length. Surplus bytes stay in the buffer and the next turn of the loop decodes them as if they were the next parameter, so a peer can smuggle in a parameter it never encoded. 0.11.x carries the same decoding loop as main, so it has the defect unchanged.The commit cherry-picked onto 0.11.x with no conflicts and needed no adaptation: the added and removed lines are identical to the approved change on #2832. I have not built this branch locally, so CI is the first compile here.