Clamp HTTP3 frame type buf size to reader bytes#13242
Open
JosiahWI wants to merge 4 commits into
Open
Conversation
The length of the source buffer for HTTP3 type parsing was always taken to be the maximum length of the type field. This seemed to work without UB when I tested it through `Http3FrameDispatcher`, but Kit Chan pointed out that it is risky (apache#11720). This patch refactors the type parsing to guarantee that the number of bytes passed to the parser will not be greater than the number of initialized bytes in the buffer.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a fuzzing-reported risk in HTTP/3 frame type parsing by ensuring the type parser never receives a buffer length larger than the number of bytes actually copied from the IOBufferReader, avoiding potential reads of uninitialized stack data.
Changes:
- Clamp the number of bytes used for HTTP/3 frame type parsing to
min(reader.read_avail(), FRAME_TYPE_MAX_BYTES). - Apply the clamping consistently in both
Http3FrameFactory::create()andHttp3FrameFactory::fast_create(). - Add
<algorithm>include to supportstd::min.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Contributor
|
[approve ci] |
maskit
approved these changes
Jun 5, 2026
Member
|
I'm not sure if it's worth back porting this fix for 10.x. I'd leave it on master for 11.0. |
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.
The length of the source buffer for HTTP3 type parsing was always taken
to be the maximum length of the type field. This seemed to work without
UB when I tested it through
Http3FrameDispatcher, but Kit Chan pointedout that it is risky (#11720).
This patch refactors the type parsing to guarantee that the number of
bytes passed to the parser will not be greater than the number of
initialized bytes in the buffer.
Fixes #11720