Skip to content

fix(urllib3): bound bytes consumed for response body and content type - #15984

Open
alifakbxr wants to merge 1 commit into
google:masterfrom
alifakbxr:fix/15451-urllib3-fuzzeddataprovider-misuse
Open

fix(urllib3): bound bytes consumed for response body and content type#15984
alifakbxr wants to merge 1 commit into
google:masterfrom
alifakbxr:fix/15451-urllib3-fuzzeddataprovider-misuse

Conversation

@alifakbxr

Copy link
Copy Markdown

Fixes #15451

Issue:
The projects/urllib3/fuzz_requests.py oss-fuzz harness currently crashes with a ReadTimeoutError on large inputs. This occurs because the harness calls fdp.ConsumeBytes(sys.maxsize) for GLOBAL_RESPONSE_BODY, which immediately drains the entire fuzzer input buffer. Consequently, all subsequent fdp.* 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_BODY and GLOBAL_CONTENT_TYPE. By using fdp.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.

@github-actions

Copy link
Copy Markdown

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

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.

projects/urllib3/fuzz_requests.py fuzz_requests harness crashes due to FuzzedDataProvider misuse

1 participant