Unbounded iter_lines() and aiter_lines() buffering enables memory exhaustion via decompression amplification
Description
While httpx2 bounds per-chunk decompression memory in iter_bytes() and aiter_bytes() (addressed in GHSA-8xx6-hgc6-gc2m / CVE-2026-84382), Response.iter_lines() and Response.aiter_lines() fed decoded text into LineDecoder without any limit on buffered line length. A remote server can return a small compressed response body containing no line separators, forcing the client to buffer the entire decompressed payload in memory before yielding a line and exhausting process memory.
Details
LineDecoder in httpx2/_decoders.py accumulated decoded text segments in self.buffer whenever a chunk contained no line separator, and joined the full list in flush() on end-of-stream (allocating a second full copy). Because iter_lines() and aiter_lines() read from iter_bytes()/aiter_bytes() with automatic content decoding (gzip, deflate, br, zstd) enabled by default, the incremental decompression bound sat one layer below LineDecoder and did not prevent unbounded accumulation.
For example, a ~65 KiB gzip-compressed body that decompresses to 64 MiB of newline-free text causes iter_lines() to reach roughly 134 MiB peak memory (~2000x wire amplification), and scales linearly with the decompressed size.
Impact
Availability degradation or out-of-memory termination of the client process.
An application is affected when it streams a response from an untrusted or attacker-influenced origin using Response.iter_lines() or Response.aiter_lines() (such as NDJSON consumers, log tailers, or feed fetchers). Confidentiality and integrity are not affected.
Mitigation
Upgrade to httpx2 2.18.0 or later, which caps the length of any single line buffered by iter_lines() and aiter_lines() at 1,048,576 characters by default and raises DecodingError once the limit is exceeded (releasing the underlying response stream immediately). Pass max_line_length to adjust the limit or max_line_length=None to disable it.
If upgrading is not immediately possible, stream untrusted responses with iter_bytes() or aiter_bytes() and enforce an application-level size limit, or disable response decompression via Accept-Encoding: identity.