CVE-2025-53539

7.5 HIGH

📋 TL;DR

CVE-2025-53539 is a denial-of-service vulnerability in FastAPI Guard's penetration detection system where inefficient regex patterns can cause polynomial complexity backtracking when processing specially crafted inputs. This affects all FastAPI applications using vulnerable versions of fastapi-guard middleware. Attackers can cause resource exhaustion and service disruption.

💻 Affected Systems

Products:
  • fastapi-guard
Versions: All versions before 3.0.1
Operating Systems: All operating systems running Python
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects applications where fastapi-guard middleware is enabled and penetration detection is active.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete service unavailability due to CPU/memory exhaustion, potentially affecting all users of the application.

🟠

Likely Case

Degraded performance or temporary service disruption for affected endpoints, requiring restart of the FastAPI application.

🟢

If Mitigated

Minimal impact with proper rate limiting, request filtering, and updated regex patterns in place.

🌐 Internet-Facing: HIGH - Internet-facing FastAPI applications are directly exposed to crafted malicious requests.
🏢 Internal Only: MEDIUM - Internal applications are still vulnerable but attack surface is reduced.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

Exploitation requires sending specially crafted HTTP requests to trigger inefficient regex patterns.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 3.0.1

Vendor Advisory: https://github.com/rennf93/fastapi-guard/security/advisories/GHSA-j47q-rc62-w448

Restart Required: Yes

Instructions:

1. Update fastapi-guard: pip install fastapi-guard==3.0.1
2. Restart your FastAPI application
3. Verify the update with: pip show fastapi-guard

🔧 Temporary Workarounds

Disable penetration detection

all

Temporarily disable the vulnerable regex-based penetration detection feature

Modify FastAPI configuration to set penetration_detection=False in fastapi-guard middleware

Implement request filtering

linux

Add WAF or reverse proxy with request filtering before requests reach FastAPI

Configure nginx/apache to filter suspicious request patterns

🧯 If You Can't Patch

  • Implement strict rate limiting to prevent mass exploitation attempts
  • Deploy web application firewall (WAF) with regex attack protection rules

🔍 How to Verify

Check if Vulnerable:

Check fastapi-guard version: pip show fastapi-guard | grep Version

Check Version:

pip show fastapi-guard | grep Version

Verify Fix Applied:

Verify version is 3.0.1 or higher and test with sample malicious patterns

📡 Detection & Monitoring

Log Indicators:

  • High CPU usage spikes
  • Increased request processing times
  • Application crashes or restarts
  • Regex timeout errors in logs

Network Indicators:

  • Unusual request patterns with complex strings
  • Repeated requests to same endpoints with varying payloads

SIEM Query:

source="fastapi.logs" AND ("CPU spike" OR "timeout" OR "regex") AND status=500

🔗 References

📤 Share & Export