Skip to content

[0.11.x] proto: reject transport parameters with a mismatched length - #2866

Merged
djc merged 1 commit into
quinn-rs:0.11.xfrom
MaxFreedomPollard:proto-tp-length-check-0.11.x
Sep 10, 2026
Merged

djc merged 1 commit into
quinn-rs:0.11.xfrom
MaxFreedomPollard:proto-tp-length-check-0.11.x

Conversation

@MaxFreedomPollard

Copy link
Copy Markdown
Contributor

Backport of #2832 to 0.11.x, which djc asked for on that PR.

TransportParameters::read reads 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_size only rejects a length above 8, min_ack_delay checks nothing, and preferred_address 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, 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.

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).
@djc
djc added this pull request to the merge queue Sep 10, 2026
Merged via the queue into quinn-rs:0.11.x with commit 811b548 Sep 10, 2026
19 checks passed
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.

2 participants