fix(urllib3): bound bytes consumed for response body and content type - #15984
Open
alifakbxr wants to merge 1 commit into
Open
fix(urllib3): bound bytes consumed for response body and content type#15984alifakbxr wants to merge 1 commit into
alifakbxr wants to merge 1 commit into
Conversation
|
alifakbxr is a new contributor to projects/urllib3. The PR must be approved by known contributors before it can be merged. The past contributors are: illia-v, hunsche, sg3-141-592, sethmlarson, pquentin, TheShiftedBit, fmeum |
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.
Fixes #15451
Issue:
The
projects/urllib3/fuzz_requests.pyoss-fuzz harness currently crashes with aReadTimeoutErroron large inputs. This occurs because the harness callsfdp.ConsumeBytes(sys.maxsize)forGLOBAL_RESPONSE_BODY, which immediately drains the entire fuzzer input buffer. Consequently, all subsequentfdp.*calls (response code, content type, request method, headers, and form data) have no bytes left to consume and remain unvaried. This effectively restricts the fuzzer to only fuzzing the response body size and masks a significant coverage gap.Fix:
This PR bounds the bytes consumed for
GLOBAL_RESPONSE_BODYandGLOBAL_CONTENT_TYPE. By usingfdp.ConsumeIntInRange()to determine a sensible limit for the body (up to 65536 bytes) and content type (up to 256 bytes) before consuming the bytes, we ensure enough data remains to populate and mutate other request parameters. This eliminates the OOM/timeout crashes on large files and allows the fuzzer to explore the library's request encoding, header handling, retry logic, and content-type processing.