reject zero-length padded DATA frame in H2Context::OnData#3325
Open
sahvx655-wq wants to merge 1 commit into
Open
reject zero-length padded DATA frame in H2Context::OnData#3325sahvx655-wq wants to merge 1 commit into
sahvx655-wq wants to merge 1 commit into
Conversation
wwbmmm
reviewed
Jun 5, 2026
| H2ParseResult H2Context::OnData( | ||
| butil::IOBufBytesIterator& it, const H2FrameHead& frame_head) { | ||
| const bool has_padding = (frame_head.flags & H2_FLAGS_PADDED); | ||
| if (frame_head.payload_size < (size_t)has_padding) { |
Contributor
There was a problem hiding this comment.
The logic is not clear to converter a bool to a size_t here
| uint32_t frag_size = frame_head.payload_size; | ||
| uint8_t pad_length = 0; | ||
| if (frame_head.flags & H2_FLAGS_PADDED) { | ||
| if (has_padding) { |
Contributor
There was a problem hiding this comment.
I think a better way is to add the check code here:
if (frag_size <= 0) {
LOG(ERROR) << ...
return ...;
}
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.
A DATA frame with the PADDED flag but Length 0 underflows frag_size here.
--frag_sizewraps the uint32_t to 0xFFFFFFFF, thefrag_size < pad_lengthcheck then passes, and the bogus size reaches append_and_forward, which swallows the rest of the connection buffer as one DATA payload and feeds ~4GiB into the flow-control counter. OnHeaders already rejects this case; OnData was missing the same guard. Fix returns FRAME_SIZE_ERROR per RFC 7540 6.1 when a padded frame has no room for the pad-length byte.