Index: urllib3-1.26.20/changelog/GHSA-gh4c-6fx4-qh6g.bugfix.rst
===================================================================
--- /dev/null
+++ urllib3-1.26.20/changelog/GHSA-gh4c-6fx4-qh6g.bugfix.rst
@@ -0,0 +1 @@
+Fixed an infinite loop in ``HTTPResponse.stream()`` and ``HTTPResponse.read_chunked()`` when decoding chunked responses with ``Content-Encoding: deflate`` and trailing data after the compressed stream.
Index: urllib3-1.26.20/src/urllib3/response.py
===================================================================
--- urllib3-1.26.20.orig/src/urllib3/response.py
+++ urllib3-1.26.20/src/urllib3/response.py
@@ -53,6 +53,10 @@ class DeflateDecoder(object):
     def decompress(self, data, max_length = -1):
         data = self._unfed_data + data
         self._unfed_data = b""
+        # Data received after EOF cannot produce more output from this
+        # Deflate stream.
+        if self._obj.eof:
+            return b""
         if not data and not self._obj.unconsumed_tail:
             return data
         original_max_length = max_length
@@ -95,7 +99,9 @@ class DeflateDecoder(object):
     @property
     def has_unconsumed_tail(self):
         return bool(self._unfed_data) or (
-            bool(self._obj.unconsumed_tail) and not self._first_try
+            bool(self._obj.unconsumed_tail)
+            and not self._first_try
+            and not self._obj.eof
         )
 
 
Index: urllib3-1.26.20/test/test_response.py
===================================================================
--- urllib3-1.26.20.orig/test/test_response.py
+++ urllib3-1.26.20/test/test_response.py
@@ -8,7 +8,7 @@ import ssl
 import zlib
 from base64 import b64decode
 from io import BufferedReader, BytesIO, TextIOWrapper
-from test import onlyBrotlipy
+from test import LONG_TIMEOUT, onlyBrotlipy
 
 try:
     import unittest.mock as mock
@@ -1139,6 +1139,38 @@ class TestResponse(object):
         resp = HTTPResponse(fp, retries=retry)
         assert resp.geturl() == "https://www.example.com"
 
+    @pytest.mark.timeout(LONG_TIMEOUT)
+    @pytest.mark.parametrize(
+        "data",
+        [d[1] for d in _test_compressor_params],
+        ids=[d[0] for d in _test_compressor_params],
+    )
+    def test_read_chunked_with_trailing_data_does_not_hang(self, request, data):
+        if data is None:
+            pytest.skip(f"Proper {request.node.callspec.id} decoder is not available")
+        # The decoded body must fill multiple bounded reads so EOF is reached
+        # while trailing data remains in the decoder's input buffer.
+        original_data = b"A" * 100
+        content_encoding, compress_func = data
+        compressed_data = compress_func(original_data) + b"tail"
+        httplib_r = httplib.HTTPResponse(MockSock)  # type: ignore[arg-type]
+        httplib_r.fp = MockChunkedEncodingResponse([compressed_data])  # type: ignore[assignment]
+        r = HTTPResponse(
+            httplib_r,
+            preload_content=False,
+            headers={
+                "transfer-encoding": "chunked",
+                "content-encoding": content_encoding,
+            },
+        )
+
+        stream = r.stream(len(original_data) // 2, decode_content=True)
+        if content_encoding in ("br", "zstd"):
+            with pytest.raises(DecodeError):
+                list(stream)
+        else:
+            assert b"".join(stream) == original_data
+
     @pytest.mark.parametrize(
         ["payload", "expected_stream"],
         [
