Skip to main content

CVE-2025-54365: CWE-20: Improper Input Validation in rennf93 fastapi-guard

High
VulnerabilityCVE-2025-54365cvecve-2025-54365cwe-20cwe-185
Published: Wed Jul 23 2025 (07/23/2025, 22:11:36 UTC)
Source: CVE Database V5
Vendor/Project: rennf93
Product: fastapi-guard

Description

fastapi-guard is a security library for FastAPI that provides middleware to control IPs, log requests, detect penetration attempts and more. In version 3.0.1, the regular expression patched to mitigate the ReDoS vulnerability by limiting the length of string fails to catch inputs that exceed this limit. This type of patch fails to detect cases in which the string representing the attributes of a <script> tag exceeds 100 characters. As a result, most of the regex patterns present in version 3.0.1 can be bypassed. This is fixed in version 3.0.2.

AI-Powered Analysis

AILast updated: 07/23/2025, 22:47:42 UTC

Technical Analysis

CVE-2025-54365 is a high-severity vulnerability affecting the fastapi-guard security library version 3.0.1, developed by rennf93. fastapi-guard is middleware designed for FastAPI applications to enhance security by controlling IP addresses, logging requests, and detecting penetration attempts. The vulnerability arises from improper input validation (CWE-20) and flawed regular expression handling (CWE-185) in the mitigation of a previous ReDoS (Regular Expression Denial of Service) vulnerability. Specifically, the patch introduced in version 3.0.1 limits the length of input strings to prevent ReDoS attacks but fails to detect inputs where the string representing the attributes of a <script> tag exceeds 100 characters. This failure allows attackers to bypass most regex-based security patterns implemented in the library, potentially enabling injection of malicious scripts or other payloads that the middleware is supposed to block. The vulnerability does not require authentication or user interaction and can be exploited remotely over the network, as indicated by the CVSS vector (AV:N/AC:L/PR:N/UI:N). Although no known exploits are currently in the wild, the high CVSS score of 7.8 reflects the significant risk posed by this flaw. The issue was addressed in version 3.0.2 of fastapi-guard, which corrects the regex validation logic to properly handle long attribute strings in <script> tags, restoring the intended security controls.

Potential Impact

For European organizations deploying FastAPI applications with fastapi-guard version 3.0.1, this vulnerability could lead to successful bypass of security middleware protections. This may allow attackers to inject malicious scripts or payloads, potentially leading to cross-site scripting (XSS), data exfiltration, or further exploitation of backend systems. The compromise of web applications could result in significant confidentiality breaches, integrity violations, and availability disruptions. Given the middleware’s role in detecting penetration attempts and controlling IPs, bypassing these controls could also facilitate stealthier attacks and prolonged unauthorized access. Organizations in sectors with stringent data protection requirements, such as finance, healthcare, and government, face heightened risks including regulatory penalties under GDPR if personal data is exposed. The vulnerability’s network-exploitable nature means that any externally accessible FastAPI service using the affected version is at risk, increasing the attack surface for European enterprises relying on this technology stack.

Mitigation Recommendations

European organizations should immediately audit their FastAPI deployments to identify usage of fastapi-guard version 3.0.1. The primary mitigation is to upgrade fastapi-guard to version 3.0.2 or later, where the regex validation flaw is fixed. Until the upgrade is applied, organizations should implement additional input validation and sanitization at the application level, specifically scrutinizing inputs that may contain <script> tags or unusually long attribute strings. Web Application Firewalls (WAFs) should be configured to detect and block suspicious payloads that attempt to exploit regex bypasses. Security teams should increase monitoring for anomalous request patterns indicative of attempted bypasses. Conducting penetration testing focused on input validation and regex bypass scenarios can help identify residual weaknesses. Finally, organizations should maintain an inventory of dependencies and integrate automated vulnerability scanning in their CI/CD pipelines to promptly detect and remediate such issues in the future.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2025-07-21T16:12:20.731Z
Cvss Version
4.0
State
PUBLISHED

Threat ID: 6881630dad5a09ad0028e316

Added to database: 7/23/2025, 10:32:45 PM

Last enriched: 7/23/2025, 10:47:42 PM

Last updated: 7/29/2025, 8:44:33 AM

Views: 29

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats