6.9medium
ReDoS in fastapi-guard's penetration attempts detector
- Severity
- 6.9medium CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.60% (higher than 50% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-j47q-rc62-w448PYSEC-2026-1359
Description
FastAPI Guard is a security library for FastAPI that provides middleware to control IPs, log requests, and detect penetration attempts. fastapi-guard's penetration attempts detection uses regex 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. This vulnerability is fixed in 3.0.1.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| rennf93 fastapi-guard | < 3.0.1 | CVE List |
| fastapi-guard (PyPI) | before 3.0.1 | GitHub Advisory Database, PyPA Advisory Database |
| fastapi-guard fastapi_guard | before 3.0.1 | NVD |
All scores
| GitHub_M | 6.9medium CVSS:4.0 | 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 |
| GitHub | medium CVSS:4.0 | 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 |
| NVD | 7.5high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H |
| PyPA Advisory Database | Not scored CVSS:4.0 | 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 |
Classification
SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.
What each source says
CVE List
FastAPI Guard is a security library for FastAPI that provides middleware to control IPs, log requests, and detect penetration attempts. fastapi-guard's penetration attempts detection uses regex 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. This vulnerability is fixed in 3.0.1.
GitHub Advisory Database
Summary
fastapi-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.
It 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.
PoC
payload = lambda n: '<'*n+ ' '*n+ 'style=' + '"'*n + ' '*n+ 'url('*n # complexity: O(n^5)
print(requests.post("http://172.24.1.3:8000/", data=payload(50)).elapsed) # 0:00:03.771120
print(requests.post("http://172.24.1.3:8000/", data=payload(100)).elapsed) # 0:01:17.952637
print(requests.post("http://172.24.1.3:8000/", data=payload(200)).elapsed) # timeout (>15min)
Single-threaded uvicorn workers can not handle any other concurrent requests during the elapsed time.
Impact
Penetration detection is enabled by default. Services that use fastapi-guard middleware without explicitly setting enable_penetration_detection=False are vulnerable to DoS.
NVD (es)
FastAPI Guard es una librería de seguridad para FastAPI que proporciona middleware para controlar IP, registrar solicitudes y detectar intentos de penetración. La detección de intentos de penetración de fastapi-guard utiliza expresiones regulares para analizar las solicitudes entrantes. Sin embargo, algunos patrones de expresiones regulares utilizados en la detección son extremadamente ineficientes y pueden causar retrocesos de complejidad polinómica al procesar entradas especialmente manipuladas. Esta vulnerabilidad se corrigió en la versión 3.0.1.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2025-53539 changed 2025-07-07 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-j47q-rc62-w448 changed 2026-07-07 | CC-BY-4.0 |
| NVD | CVE-2025-53539 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2026-1359 changed 2026-07-07 | CC-BY-4.0 |