Skip to content

reject 64-bit frame length with the high bit set#3095

Merged
ashtum merged 2 commits into
boostorg:developfrom
sahvx655-wq:frame-len-high-bit
Jun 9, 2026
Merged

reject 64-bit frame length with the high bit set#3095
ashtum merged 2 commits into
boostorg:developfrom
sahvx655-wq:frame-len-high-bit

Conversation

@sahvx655-wq

Copy link
Copy Markdown
Contributor

While analysing how parse_fh decodes frame headers I noticed the 64-bit extended payload length is checked only for its minimum canonical encoding (the fh.len < 65536 test); the most significant bit is never examined. RFC 6455 section 5.2 requires that bit to be 0 in the 64-bit form, so a frame advertising a length of 2^63 or more is malformed framing that a conformant endpoint must reject. Replaying such a header into a client read confirms it is accepted as an ordinary data frame and the stream then starts reading the advertised payload.

The behaviour depends on configuration: with a read message limit the oversize length only surfaces later as message_too_big, but with read_message_max(0) nothing catches it and the read blocks on a payload that can never arrive. I put the check beside the existing canonical-length test because parse_fh is the only place the 64-bit length is decoded, so failing it there with bad_size keeps callers from re-validating the framing themselves.

@vinniefalco

Copy link
Copy Markdown
Member

impressive :) you found an actual bug in the spec implementation

@sahvx655-wq

Copy link
Copy Markdown
Contributor Author

impressive :) you found an actual bug in the spec implementation

thank you

@ashtum

ashtum commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

@sahvx655-wq, thanks for the PR.

Two existing tests used frame lengths with the high bit set and were failing, so I've added a commit to fix them and get CI passing.

@ashtum ashtum merged commit ef5aec2 into boostorg:develop Jun 9, 2026
75 of 76 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.

3 participants