CVE-2025-54365: CWE-20: Improper Input Validation in rennf93 fastapi-guard
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 Analysis
Technical Summary
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.
Affected Countries
Germany, France, United Kingdom, Netherlands, Sweden, Italy, Spain
CVE-2025-54365: CWE-20: Improper Input Validation in rennf93 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
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.
Affected Countries
For access to advanced analysis and higher rate limits, contact root@offseq.com
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
Related Threats
CVE-2025-51045: n/a
HighCVE-2025-51044: n/a
HighCVE-2025-36071: CWE-772 Missing Release of Resource after Effective Lifetime in IBM IBM Db2
MediumCVE-2025-33114: CWE-943 Improper Neutralization of Special Elements in Data Query Logic in IBM Db2
MediumCVE-2025-33092: CWE-121 Stack-based Buffer Overflow in IBM Db2
HighActions
Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.
Need enhanced features?
Contact root@offseq.com for Pro access with improved analysis and higher rate limits.