CVE-2026-61652
Denial‑of‑service via memory exhaustion in Zapros < 0.14.0 when decoding streamed compressed responses.
- CVSS 8.7
- CWE-770
- Resource Management
- Remote
Zapros, a Python HTTP client, prior to version 0.14.0 is vulnerable to denial of service via memory exhaustion. The issue affects all callers who streamed compressed responses relying on the chunk size — explicit (`iter_bytes(chunk_size=…)`) or the default — to bound memory. The decoder ignored that bound, so a chunk could be far larger than requested and a single compressed response could overflow memory. Version 0.14.0 contains a patch. Some workarounds are available. Read the still-compressed body with `Response.iter_raw()` / `Response.async_iter_raw()`, which bypass the built-in decoders, and decompress it yourself with an explicit output-size bound (e.g. `zlib`'s `max_length`), aborting once a configured limit is exceeded. Where feasible, send `Accept-Encoding: identity` to disable response compression so bodies are not decompressed client-side. Avoid decoding response bodies from untrusted servers.
- CWE
- CWE-770
- CVSS base score
- 8.7
- Published
- 2026-09-21
- OWASP
- A06 Vulnerable and Outdated Components
- Orthogonal defect classification
- Checking
- Code defect classification
- Incorrect Check
- Category
- Resource Management
- Subcategory
- Resource Exhaustion
- Accessibility scope
- Remote
- Impact
- Denial of Service (DoS)
- Affected component
- Zapros
- Fixed by upgrading
- Yes
Solution
Upgrade Zapros to version 0.14.0 (or later).
Vulnerable code sample
import zapros
import zlib
def fetch_and_decompress(url: str) -> bytes:
client = zapros.Client()
# VULNERABLE: decoder ignores chunk size, may allocate huge memory
resp = client.get(url, headers={"Accept-Encoding": "gzip"})
# iter_bytes decompresses on the fly but does not respect chunk_size bound
data = b"".join(resp.iter_bytes(chunk_size=8192))
return dataPatched code sample
import zapros
import zlib
def fetch_and_decompress(url: str) -> bytes:
client = zapros.Client()
# FIX: read raw compressed bytes and limit decompression output size
resp = client.get(url, headers={"Accept-Encoding": "gzip"})
compressed = b"".join(resp.iter_raw(chunk_size=8192))
# Use zlib with max_length to prevent memory exhaustion
decompressor = zlib.decompressobj()
# Decompress in small steps, abort if output exceeds limit
limit = 10 * 1024 * 1024 # 10 MiB
result = []
total = 0
for chunk in [compressed[i:i+8192] for i in range(0, len(compressed), 8192)]:
out = decompressor.decompress(chunk, max_length=limit - total)
result.append(out)
total += len(out)
if total >= limit:
raise MemoryError("Decompressed data exceeds safe limit")
result.append(decompressor.flush())
return b"".join(result)Published fix
Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.
- fix(security): protect streaming responses from zip bombs (kap-sh/zapros)
src/zapros/_decoders.py,src/zapros/_decoders.py · BrotliDecoder.decode,src/zapros/_decoders.py · BrotliDecoder.flush,src/zapros/_decoders.py · BrotliDecoder.__init__,src/zapros/_decoders.py · ContentDecoder.decode,src/zapros/_decoders.py · ContentDecoder.flush,src/zapros/_decoders.py · DeflateDecoder.decode,src/zapros/_decoders.py · DeflateDecoder.flush,src/zapros/_decoders.py · DeflateDecoder.__init__,src/zapros/_decoders.py · GZipDecoder.decode,src/zapros/_decoders.py · GZipDecoder.flush,src/zapros/_decoders.py · GZipDecoder.__init__and 10 more
Cite this entry
@misc{vaitp:cve202661652,
title = {{Denial‑of‑service via memory exhaustion in Zapros < 0.14.0 when decoding streamed compressed responses.}},
author = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
year = {2026},
note = {VAITP Python Vulnerability Dataset, entry CVE-2026-61652},
howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-61652/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.
The supreme art of war is to subdue the enemy without fighting.
Sun Tzu – “The Art of War”
:: Shaping the future through research and ingenuity ::
