GHSA-vxq7-64xx-v4gw: Pip/urllib3 vulnerability
Impact
urllib3's streaming API is designed for efficiently handling large HTTP responses by reading the content in chunks, rather than loading the entire response body into memory at once. When decoding a chunked-transfer-encoded response, this API reads each chunk's size field by buffering until it sees \n or EOF.
A malicious HTTP server can return Transfer-Encoding: chunked and then send a very long run of bytes without any newline, causing the streaming client to buffer that entire run before urllib3 can reject the chunk size as invalid and allocate more memory than intended.
To fix the issue, we'll reject chunk-size fields larger than 65536 bytes, as already done in the non-streaming case, which is currently handled by the Python standard library. Note that this only applies to reading the chunk-size field, not the chunk data, which is already handled correctly. Thus, there shouldn't be any impact for non-malicious servers.
Affected usages
Applications and libraries using urllib3 versions earlier than 2.8.0 may be affected when streaming a chunked response from untrusted sources. Specifically, this affects the readchunked() and stream() methods of the HTTPResponse object.
This also affects requests streaming API, which uses urllib3 under the hood.
Remediation
Upgrade to urllib3 version 2.8.0 or later, where chunk-size fields larger than 65536 will be rejected. If upgrading is not immediately possible, consider reading the response at once using the read() method.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
pip/urllib3to a version that resolves this vulnerability.Fixed in 2.8.0 - Upgrade
Upgrade
urllib3to a version that resolves this vulnerability.Fixed in 2.8.0 - Compensating control
If upgrading is not immediately possible, read the chunked response at once using the read() method instead of streaming it.
Event History
Frequently Asked Questions
Which applications are exposed?
Applications and libraries using urllib3 versions earlier than 2.8.0 may be affected if they use urllib3's streaming API to read responses from an HTTP server that may be malicious.
What does an attacker need to do to trigger the issue?
The attacker needs to control or impersonate an HTTP server contacted by the streaming client. The server sends a chunked response with an excessively long chunk-size field that contains no newline, causing urllib3 to buffer the field before rejecting it.
How can the issue be remediated?
Upgrade urllib3 to version 2.8.0 or later. The fix rejects chunk-size fields larger than 65,536 bytes.