CVE-2025-53539: Fastapi guard Denial of Service Vulnerability
MODERATECVE-2025-53539 is a MODERATE denial of service vulnerability (CWE-1333: Inefficient Regular Expression Complexity) affecting Fastapi guard libraries in the PyPI ecosystem. The issue involves fastapi-guard is vulnerable to redos through inefficient regex. Remediation is available by upgrading affected packages to version 3.0.1.
CVE-2025-53539 at a Glance
How to Fix CVE-2025-53539
To remediate this vulnerability, upgrade all affected Fastapi guard dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install fastapi-guard>=3.0.1
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show fastapi-guard
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2025-53539, inspect your installed packages using pip:
pip show fastapi-guard
Analyze the terminal output to locate any version of Fastapi guard in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.1), your application is affected.
Note: The pip show fastapi-guard command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-1333: Inefficient Regular Expression Complexity, where the product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential. In Fastapi guard, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-53539 Affected Fastapi guard Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
fastapi-guard
|
PyPI |
< 3.0.1
|
3.0.1
|
References
Frequently Asked Questions
What is CVE-2025-53539?
Which Fastapi guard versions are affected?
What version fixes CVE-2025-53539?
Is fastapi-guard affected?
What CWE is associated with CVE-2025-53539?
How can I check PyPI dependencies for CVE-2025-53539?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-j47q-rc62-w448",
"modified" : "2025-12-31T22:50:34Z",
"published" : "2025-07-07T23:36:39Z",
"aliases" : [ "CVE-2025-53539" ],
"summary" : "fastapi-guard is vulnerable to ReDoS through inefficient regex",
"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.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "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"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "fastapi-guard"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.0.1"
} ]
} ],
"database_specific" : {
"last_known_affected_version_range" : "<= 3.0.0"
}
} ],
"references" : [ {
"type" : "WEB",
"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" : "WEB",
"url" : "https://github.com/rennf93/fastapi-guard/commit/d9d50e8130b7b434cdc1b001b8cfd03a06729f7f"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/rennf93/fastapi-guard"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-1333" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-07-07T23:36:39Z",
"nvd_published_at" : "2025-07-07T20:15:28Z"
}
}