reject 64-bit frame length with the high bit set#3095
Merged
Conversation
Member
|
impressive :) you found an actual bug in the spec implementation |
Contributor
Author
thank you |
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. |
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.
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 < 65536test); 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.