
Cloud Vulnerability DB
A community-led vulnerabilities database
CVE-2025-54365 is a regex bypass vulnerability in fastapi-guard, a security middleware library for FastAPI applications. The flaw exists specifically in version 3.0.1, where a prior patch intended to mitigate ReDoS (Regular Expression Denial of Service) by introducing bounded quantifiers (e.g., {0,100}) inadvertently created a bypass condition: inputs with <script> tag attributes exceeding 100 characters evade detection, allowing most regex-based security patterns to be circumvented. The vulnerability was published on July 23, 2025, and affects only fastapi-guard == 3.0.1 (pip package). It carries a CVSS v4 base score of 7.8 (High) and a CVSS v3.1 base score of 7.5 (High) (Github Advisory, Feedly).
The root cause is classified under CWE-20 (Improper Input Validation), CWE-185 (Incorrect Regular Expression), and CWE-1333 (Inefficient Regular Expression Complexity). In version 3.0.1, the ReDoS mitigation replaced unbounded quantifiers (e.g., [^<]*) with bounded ones (e.g., [^<]{0,100}), but this approach fails when the input string — particularly the attributes portion of a <script> tag — exceeds the imposed character limit, causing the pattern to not match and thus silently pass the security check. This affects patterns across multiple attack categories in guard/handlers/suspatterns_handler.py, including XSS, SQL injection, command injection, LDAP injection, SSRF, and template injection detection. The attack vector is network-based, requires no authentication or user interaction, and can be triggered by crafting HTTP request bodies, query parameters, headers, or paths with payloads exceeding the bounded quantifier thresholds (Github Advisory, Patch Commit).
Successful exploitation allows an attacker to bypass the penetration detection middleware entirely, enabling injection attacks — including XSS, SQL injection, command injection, SSRF, and template injection — against the underlying FastAPI application that relies on fastapi-guard for protection. The primary impact is high availability risk (potential for ReDoS via catastrophic backtracking if unbounded patterns are re-introduced) and low-to-moderate integrity risk through injection payloads that bypass security filters. Confidentiality is not directly impacted by the bypass itself, but downstream injection attacks enabled by the bypass could expose sensitive data or allow unauthorized actions (Github Advisory).
A proof-of-concept (PoC) exploit is publicly available in the GitHub security advisory, demonstrating the bypass using a crafted HTTP POST request with a <script> tag whose attributes exceed 100 characters. There is no evidence of in-the-wild exploitation at this time, and no threat actor attribution has been reported. The EPSS score is approximately 0.094% (0.000940), indicating a low but non-zero probability of exploitation in the near term. The vulnerability is not listed in the CISA Known Exploited Vulnerabilities (KEV) catalog (Github Advisory, Feedly).
fastapi-guard version 3.0.1 as middleware with penetration detection enabled (e.g., enable_penetration_detection=True in SecurityConfig).git clone https://github.com/rennf93/fastapi-guard and navigate to the examples/ directory to understand the middleware configuration.<script> tag payload where the attributes portion exceeds 100 characters, causing the bounded quantifier {0,100} in the regex to fail to match. For example: <script aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa>alert(1);</script>.import requests
URL = "http://target-app:8000/"
bypassed_payload = {"suspicious": "<script " + "a"*101 + ">alert(1);"}
response = requests.post(url=URL, json=bypassed_payload)
print(f"[+] Response: {response.text}")<script> tags with attribute strings exceeding 100 characters; requests with SQL keywords (SELECT, UNION, FROM) or command injection patterns in body/query params that are not blocked by the middleware.<script> attribute strings that were not flagged by detect_penetration_attempt(); absence of expected WARNING - Regex timeout exceeded or penetration detection log entries for suspicious inputs.Upgrade fastapi-guard to version 3.0.2 immediately, which resolves the bypass by reverting to unbounded quantifiers and instead implementing a configurable regex execution timeout (regex_timeout) via ThreadPoolExecutor to prevent ReDoS without introducing bypassable length limits. The new regex_timeout parameter (default: 2.0 seconds, range: 0.1–30.0 seconds) can be set in SecurityConfig. No configuration-based workaround exists for version 3.0.1 — upgrading is the only effective remediation (Github Advisory, Patch Commit).
from guard.models import SecurityConfig
config = SecurityConfig(
enable_penetration_detection=True,
regex_timeout=2.0 # New in v3.0.2
)The vulnerability was reported by researcher dhki and remediated by the library maintainer rennf93, who published the advisory and patch on July 23, 2025. The fix was noted in the changelog as an "IMPORTANT" security enhancement. No significant broader media coverage or notable community commentary beyond the GitHub advisory has been identified (Github Advisory).
Source: This report was generated using AI
Free Vulnerability Assessment
Evaluate your cloud security practices across 9 security domains to benchmark your risk level and identify gaps in your defenses.
Get a personalized demo
"Best User Experience I have ever seen, provides full visibility to cloud workloads."
"Wiz provides a single pane of glass to see what is going on in our cloud environments."
"We know that if Wiz identifies something as critical, it actually is."