{"id":"CVE-2026-61541","aliases":["CVE-2026-61541","GHSA-5vjj-2r48-q622","PYSEC-2026-4181"],"related":[],"kind":"vulnerability","state":"published","title":"Zapros has an Unbounded Content-Encoding decompression chain that allows denial of service","summary":"Zapros, a Python HTTP client, prior to version 0.14.0 is vulnerable to denial of service when an application requests content from an untrusted server, or follows a redirect to one, because a malicious response containing an excessive number of chained `Content-Encoding` values causes Zapros to construct a deeply nested decompression chain that consumes excessive resources. Version 0.14.0 patches the vulnerability by limiting responses to five content-encoding layers and raising `DecodingError` when that limit is exceeded. As a workaround, applications can add response middleware that inspects the `Content-Encoding` header and rejects responses containing more than a safe number of encoding layers.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Zapros, a Python HTTP client, prior to version 0.14.0 is vulnerable to denial of service when an application requests content from an untrusted server, or follows a redirect to one, because a malicious response containing an excessive number of chained `Content-Encoding` values causes Zapros to construct a deeply nested decompression chain that consumes excessive resources. Version 0.14.0 patches the vulnerability by limiting responses to five content-encoding layers and raising `DecodingError` when that limit is exceeded. As a workaround, applications can add response middleware that inspects the `Content-Encoding` header and rejects responses containing more than a safe number of encoding layers.","source":"cvelist"},{"lang":"en","text":"### Impact\n\n**Who is impacted**:\n  - Any application using Zapros to make HTTP requests to untrusted servers\n  - Applications that follow redirects to attacker-controlled hosts\n\n**Attack vector**:\n  - A malicious HTTP server returns a response with many chained content encodings. When the client attempts to decode, it creates a deeply nested decompression chain consuming excessive resources.\n\n### Patches\n\nFixed in version 0.14.0.\n\n  The fix adds a hardcoded limit of **5** `Content-Encoding` layers. Responses exceeding this limit raise `DecodingError`.\n\n### Workarounds\n\nAdd middleware that checks for a malicious Content-Encoding header.\n\n```python\nfrom typing import cast\n\nfrom zapros import (\n    AsyncBaseHandler,\n    AsyncBaseMiddleware,\n    BaseHandler,\n    BaseMiddleware,\n    Client,\n    DecodingError,\n    Request,\n    Response,\n)\n\nMAX_DECODE_LAYERS = 5\n\n\nclass ContentEncodingCheckMiddleware(BaseMiddleware, AsyncBaseMiddleware):\n    def __init__(\n        self,\n        next_handler: BaseHandler | AsyncBaseHandler,\n        *,\n        max_layers: int = MAX_DECODE_LAYERS,\n    ) -> None:\n        self.next = cast(BaseHandler, next_handler)\n        self.async_next = cast(AsyncBaseHandler, next_handler)\n        self._max_layers = max_layers\n\n    def _check(self, response: Response) -> None:\n        encoding_header = response.headers.get(\"Content-Encoding\")\n        if not encoding_header:\n            return\n\n        layers = [enc.strip().lower() for enc in encoding_header.split(\",\") if enc.strip()]\n        if len(layers) > self._max_layers:\n            raise DecodingError(f\"Too many Content-Encoding layers ({len(layers)}), maximum is {self._max_layers}\")\n\n    def handle(self, request: Request) -> Response:\n        response = self.next.handle(request)\n        self._check(response)\n        return response\n\n    async def ahandle(self, request: Request) -> Response:\n        response = await self.async_next.ahandle(request)\n        self._check(response)\n        return response\n\n\nwith Client().wrap_with_middleware(lambda next: ContentEncodingCheckMiddleware(next)) as client:\n    ...\n```","format":"markdown","source":"ghsa"}],"published":"2026-09-21T21:21:21.321Z","modified":"2026-10-01T17:56:21.759Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","score":6.9,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","score":6.9,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N","rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N"}],"cwes":["CWE-770"],"affected":[{"ranges":[{"version":"< 0.14.0","status":"affected"}],"vendor":"kap-sh","product":"zapros","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.14.0"}],"ecosystem":"PyPI","package":"zapros","purl":"pkg:pypi/zapros","source":"ghsa"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.14.0"}],"ecosystem":"PyPI","package":"zapros","purl":"pkg:pypi/zapros","source":"pysec"}],"references":[{"url":"https://github.com/kap-sh/zapros/security/advisories/GHSA-5vjj-2r48-q622","tags":["web","x-refsource-confirm"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2026-61541","tags":["advisory"],"sources":["ghsa","pysec"]},{"url":"https://github.com/kap-sh/zapros/commit/7971fbca9707eb01455ca2d73416ac091f96908b","tags":["web"],"sources":["ghsa","pysec"]},{"url":"https://github.com/kap-sh/zapros","tags":["package"],"sources":["ghsa","pysec"]},{"url":"https://github.com/kap-sh/zapros/releases/tag/v0.14.0","tags":["web"],"sources":["ghsa","pysec"]},{"url":"https://pypi.org/project/zapros","tags":["package"],"sources":["pysec"]},{"url":"https://github.com/advisories/GHSA-5vjj-2r48-q622","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2026-09-23T19:07:48.022Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2026-61541","url":"https://www.cve.org/CVERecord?id=CVE-2026-61541","licence":"CVE Terms of Use","modified":"2026-09-23T19:07:58.617Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-5vjj-2r48-q622","url":"https://github.com/advisories/GHSA-5vjj-2r48-q622","licence":"CC-BY-4.0","modified":"2026-10-01T17:56:21.759Z"},{"source":"nvd","name":"NVD","id":"CVE-2026-61541","url":"https://nvd.nist.gov/vuln/detail/CVE-2026-61541","licence":"Public domain","modified":"2026-09-30T17:32:07.107Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2026-4181","url":"https://osv.dev/vulnerability/PYSEC-2026-4181","licence":"CC-BY-4.0","modified":"2026-10-01T17:45:18.544Z"}],"updatedAt":"2026-11-25T22:59:40.398Z","epss":{"score":0.00253,"percentile":0.17902,"date":"2026-12-01T12:00:22.000Z"}}