Vulnerabilities in pkg:pypi/fastapi-guard

PACKAGE
Advisory Identifier: GHSA-j47q-rc62-w448
Advisory Summary

CVE-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.

2 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:pypi/fastapi-guard

2 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:pypi/fastapi-guard. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-j47q-rc62-w448 CVE-2025-53539 MODERATE fastapi-guard is vulnerable to ReDoS through inefficient regex
GHSA-rrf6-pxg8-684g CVE-2025-54365 HIGH FastAPI Guard has a regex bypass

CVE-2025-53539 at a Glance

CVE Identifier CVE-2025-53539
GHSA Identifier GHSA-j47q-rc62-w448
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-1333: Inefficient Regular Expression Complexity
Affected Product Fastapi guard
Package Ecosystem PyPI
Published Date
Last Updated

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.

fastapi-guard fixed: 3.0.1
pip install fastapi-guard>=3.0.1
Verify Direct and Transitive Dependencies

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

### Summary fastapi-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. It 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. ### PoC e.g. https://github.com/rennf93/fastapi-guard/blob/1e6c2873bfc7866adcbe5fc4da72f2d79ea552e7/guard/handlers/suspatterns_handler.py#L31C79-L32C7 ```python payload = lambda n: '<'*n+ ' '*n+ 'style=' + '"'*n + ' '*n+ 'url('*n # complexity: O(n^5) print(requests.post("http://172.24.1.3:8000/", data=payload(50)).elapsed) # 0:00:03.771120 print(requests.post("http://172.24.1.3:8000/", data=payload(100)).elapsed) # 0:01:17.952637 print(requests.post("http://172.24.1.3:8000/", data=payload(200)).elapsed) # timeout (>15min) ``` Single-threaded uvicorn workers can not handle any other concurrent requests during the elapsed time. ### Impact Penetration detection is enabled by default. Services that use fastapi-guard middleware without explicitly setting `enable_penetration_detection=False` are vulnerable to DoS.

CVE-2025-53539 Affected Fastapi guard Versions

1 component(s)
Fixed Versions:
3.0.1
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?
CVE-2025-53539 is a security vulnerability in Fastapi guard involving fastapi-guard is vulnerable to ReDoS through inefficient regex under CWE-1333: Inefficient Regular Expression Complexity.
Which Fastapi guard versions are affected?
Affected versions include releases prior to 3.0.1 across affected packages: fastapi-guard.
What version fixes CVE-2025-53539?
Upgrading to 3.0.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is fastapi-guard affected?
Yes, fastapi-guard is affected in releases prior to 3.0.1. Upgrade your dependency to 3.0.1 or later.
What CWE is associated with CVE-2025-53539?
CVE-2025-53539 is classified under CWE-1333: Inefficient Regular Expression Complexity (The product uses a regular expression with a worst-case computational complexity that is inefficient and possibly exponential.).
How can I check PyPI dependencies for CVE-2025-53539?
Run the dependency tree command: 'pip show fastapi-guard'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "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"
  }
}