Index: urllib3-2.5.0/changelog/GHSA-gh4c-6fx4-qh6g.bugfix.rst
===================================================================
--- /dev/null
+++ urllib3-2.5.0/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-2.5.0/src/urllib3/response.py
===================================================================
--- urllib3-2.5.0.orig/src/urllib3/response.py
+++ urllib3-2.5.0/src/urllib3/response.py
@@ -74,6 +74,10 @@ class DeflateDecoder(ContentDecoder):
     def decompress(self, data: bytes, max_length: int = -1) -> bytes:
         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
@@ -116,7 +120,9 @@ class DeflateDecoder(ContentDecoder):
     @property
     def has_unconsumed_tail(self) -> bool:
         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
         )
 
     def flush(self) -> bytes:
Index: urllib3-2.5.0/test/test_response.py
===================================================================
--- urllib3-2.5.0.orig/test/test_response.py
+++ urllib3-2.5.0/test/test_response.py
@@ -10,7 +10,7 @@ import zlib
 from base64 import b64decode
 from http.client import IncompleteRead as httplib_IncompleteRead
 from io import BufferedReader, BytesIO, TextIOWrapper
-from test import onlyBrotli, onlyZstd
+from test import LONG_TIMEOUT, onlyBrotli, onlyZstd
 from unittest import mock
 
 import pytest
@@ -738,6 +738,42 @@ class TestResponse:
         for params in _test_compressor_params
     ]
 
+    @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: pytest.FixtureRequest,
+        data: tuple[str, typing.Callable[[bytes], bytes]] | None,
+    ) -> None:
+        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(
         "data",
         [d[1] for d in _test_memory_usage_decode_with_max_length_params],
