MediumGHSA-gh4c-6fx4-qh6gCVE-2026-97688PYSEC-2026-4176

urllib3: Chunked Deflate streaming can enter an infinite loop

Published 30 Sept 2026 · Updated 1 Oct 2026

Is your project on an affected urllib3?

Private repo? Upload its lockfile instead, or connect GitHub to check every repo.

Look after several Python apps? Indie watches up to 15 repos, private ones too, for $5 a month. See Indie

Affected package

Affected
>=2.6.2 <2.8.0
Fixed in
2.8.0
Update to the fixed version for your release line, for example:pip install 'urllib3>=2.8.0'

Details

Impact

urllib3's streaming API is designed for the efficient handling of large HTTP responses by reading content in chunks instead of loading the entire response body into memory at once.

urllib3 can decompress response bodies according to the HTTP Content-Encoding header. When streaming a compressed, chunked response, urllib3 first consumes data already buffered by the decoder before reading the next HTTP chunk.

However, urllib3 versions from 2.6.2 through 2.7.0 could enter an infinite loop when a chunked response contained bytes after the end of the Deflate stream. If the decompressed body exceeded the requested streaming chunk size, Python's zlib implementation could retain the trailing bytes as unconsumed input after reaching the end of the compressed stream. urllib3 would repeatedly attempt to decode those same bytes without making progress or reading more data from the network.

A malicious server could exploit this behavior to cause excessive CPU usage and prevent the affected request from completing on the client. Network read timeouts would not interrupt the loop because no further socket operation was required.

Affected usages

Applications and libraries using urllib3 versions 2.6.2 through 2.7.0 may be affected when all of the following conditions are met:

1. Compressed responses from an untrusted source are streamed using HTTPResponse.stream(amt=N) or HTTPResponse.read_chunked(amt=N) with a positive, finite chunk size. 2. Content decoding is enabled. 3. The response uses both Transfer-Encoding: chunked and Content-Encoding: deflate. 4. The decoded body exceeds the requested chunk size and the encoded body contains bytes after the end of the Deflate stream.

HTTPResponse.stream() uses a finite chunk size by default and is therefore affected when the other conditions are met.

Remediation

Upgrade to urllib3 2.8.0, in which the Deflate decoder stops accepting input after reaching the end of the compressed stream and no longer reports trailing bytes as data that can produce more decoded output.

If upgrading is not immediately possible, disable automatic content decoding for responses from untrusted sources by setting decode_content=False, or reject streamed responses using the Deflate content encoding. Applications that disable automatic decoding must handle the compressed response safely at another layer.

Is GHSA-gh4c-6fx4-qh6g in any of your client repos?

Checking one package by hand is fine. Checking it across forty client projects is not. NPMscan reads the lockfiles in every GitHub repo you pick, finds each project with an affected urllib3, and gives you the command that fixes it.

More advisories for urllib3

  • HighCVE-2026-97689urllib3: HTTPResponse.stream()/read_chunked() buffers an unbounded chunk-size line into memory · 30 Sept 2026
  • HighCVE-2026-97687urllib3: HTTPS proxy TLS configuration may be ignored or overridden · 30 Sept 2026
  • HighCVE-2026-44432urllib3: Decompression-bomb safeguards bypassed in parts of the streaming API · 11 May 2026
  • HighCVE-2026-44431urllib3: Sensitive headers forwarded across origins in proxied low-level redirects · 11 May 2026
  • HighCVE-2026-21441Decompression-bomb safeguards bypassed when following HTTP redirects (streaming API) · 7 Jan 2026
  • HighCVE-2025-66471urllib3 streaming API improperly handles highly compressed data · 5 Dec 2025
All 22 advisories for urllib3

References

Advisory data from OSV.dev (opens OSV.dev in a new tab), refreshed daily.