GitHub Advisoryadvisory · PyPI

GHSA-j47q-rc62-w448 fastapi-guard is vulnerable to ReDoS through inefficient regex

MEDIUM Published 2025-07-07 Modified 2025-12-31 Official page ↗
Aliases
CVE-2025-53539
Ecosystem
PyPI
Packages
fastapi-guard
Severity
Moderate
CVSS 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
Weaknesses
CWE-1333
Reviewed
2025-07-07

Affected packages

• PyPI fastapi-guard: < 3.0.1 → fixed in 3.0.1

Description

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 ```python payload = lambda n: '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.

Related

Alias · CVE (1)

  • CVE-2025-53539 FastAPI Guard is a security library for FastAPI that provides middleware to control IPs, log requests, and detect penetration attempts. vulnerability

Weakness · CWE (1)

  • CWE-1333 Inefficient Regular Expression Complexity weakness

References