CVE-2026-97689: urllib3: HTTPResponse.stream()/read_chunked() buffers an unbounded chunk-size line into memory
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.
Other sources
urllib3 is an HTTP client library for Python. From 1.10.3 until 2.8.0, the HTTPResponse.readchunked and HTTPResponse.stream methods can allocate unbounded memory because the streaming chunk parser buffers the chunk-size field until newline or EOF without a length bound. The trigger is that a malicious server returns Transfer-Encoding: chunked followed by a very long run of bytes without a newline. The attack mechanism is that a malicious HTTP server sends a very long unterminated chunk-size line. The impact is that unbounded memory allocation can exhaust the client process. This issue is fixed in version 2.8.0.
— MITRE
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 response at once using the read() method instead of the streaming read_chunked() or stream() methods.
Event History
Frequently Asked Questions
Which applications are exposed to this issue?
Applications using urllib3 versions from 1.10.3 up to, but not including, 2.8.0 are exposed when they use HTTPResponse.read_chunked() or HTTPResponse.stream() against a malicious HTTP server.
What must an attacker control to trigger the memory exhaustion?
An attacker needs to operate or control an HTTP server that the affected client connects to. The server must send Transfer-Encoding: chunked and then provide an extremely long chunk-size line without a newline or EOF.
How can I determine whether an application is affected?
Check whether the application depends on an urllib3 version in the affected range and whether it processes responses from untrusted or potentially malicious HTTP servers through HTTPResponse.read_chunked() or HTTPResponse.stream().
What is the remediation?
Upgrade urllib3 to version 2.8.0, which fixes the unbounded buffering of the chunk-size field.