CVE-2023-46136

8.0 HIGH

📋 TL;DR

CVE-2023-46136 is a denial-of-service vulnerability in Werkzeug's multipart data parser. Attackers can send specially crafted file uploads that cause excessive CPU consumption, blocking worker processes from handling legitimate requests. This affects any application using vulnerable versions of Werkzeug to parse multipart/form-data.

💻 Affected Systems

Products:
  • Werkzeug
Versions: All versions before 3.0.1
Operating Systems: All operating systems running Python
Default Config Vulnerable: ⚠️ Yes
Notes: Only affects endpoints that parse multipart/form-data (typically file upload endpoints).

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Complete service unavailability as worker processes become saturated with CPU-bound parsing tasks, preventing legitimate user requests from being processed.

🟠

Likely Case

Degraded application performance and intermittent service disruptions under attack, potentially leading to timeouts and failed requests.

🟢

If Mitigated

Minimal impact with proper rate limiting, request size limits, and updated software.

🌐 Internet-Facing: HIGH - Web applications accepting file uploads are directly exposed to this attack vector.
🏢 Internal Only: MEDIUM - Internal applications accepting file uploads remain vulnerable but have reduced attack surface.

🎯 Exploit Status

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

Exploit requires sending crafted multipart data to vulnerable endpoints. Proof-of-concept details are publicly available in the advisory.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 3.0.1

Vendor Advisory: https://github.com/pallets/werkzeug/security/advisories/GHSA-hrfv-mqp8-q5rw

Restart Required: Yes

Instructions:

1. Update Werkzeug: pip install --upgrade werkzeug==3.0.1
2. Restart all Python processes using Werkzeug
3. Verify the update with: python -c "import werkzeug; print(werkzeug.__version__)"

🔧 Temporary Workarounds

Implement request size limits

all

Limit maximum request body size to prevent large malicious uploads

# In Flask/Werkzeug configuration
app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024  # 16MB limit

Rate limit file upload endpoints

all

Implement rate limiting on endpoints accepting multipart data

# Using Flask-Limiter or similar
from flask_limiter import Limiter
limiter = Limiter(app)
@app.route('/upload', methods=['POST'])
@limiter.limit("10 per minute")

🧯 If You Can't Patch

  • Implement WAF rules to block requests with suspicious multipart boundary patterns
  • Deploy reverse proxy with request inspection and size limiting before requests reach vulnerable application

🔍 How to Verify

Check if Vulnerable:

Check Werkzeug version: python -c "import werkzeug; print(werkzeug.__version__)" - if version is <3.0.1, system is vulnerable.

Check Version:

python -c "import werkzeug; print(werkzeug.__version__)"

Verify Fix Applied:

Verify version is 3.0.1 or higher: python -c "import werkzeug; print(werkzeug.__version__)"

📡 Detection & Monitoring

Log Indicators:

  • Unusually long request processing times for file uploads
  • High CPU usage spikes on application servers
  • Multiple failed requests due to timeouts

Network Indicators:

  • Large POST requests to upload endpoints with unusual boundary patterns
  • Sustained high-volume traffic to specific endpoints

SIEM Query:

source="web_server_logs" method="POST" uri_path="*upload*" duration_ms>10000 | stats count by src_ip

🔗 References

📤 Share & Export