CVE-2024-52804·Python vulnerability
Tornado is a Python web framework and asynchronous networking library. The algorithm used for parsing HTTP cookies in Tornado versions prior to 6.4.2 sometimes has quadratic complexity, leading to excessive CPU consumption when parsing maliciously-crafted cookie headers. This parsing occurs in the event loop thread and may block the processing of other requests. Version 6.4.2 fixes the issue.
- Severity
- high
- Software
- Python
- Fixed in
- 6.4.2
- Published
- 2024-11-22
Affected versions
Until: 6.4.2
Fixed in: 6.4.2
How to fix this CVE
Update Python's Tornado web framework to version 6.4.2 or later to remediate a cookie parsing vulnerability that causes excessive CPU consumption. This vulnerability allows unauthenticated attackers to trigger denial-of-service conditions by sending specially crafted HTTP cookie headers that trigger quadratic-time parsing logic. Ensure all systems running Tornado are patched immediately, particularly those exposed to untrusted network traffic.
sudo dnf update python3-tornadoDefensia detects this vulnerability
What an exploitation attempt looks like
Sample log line indicative of exploitation attempts:
POST|GET .* HTTP/1\.[01].*Cookie:.{1000,}|Cookie:.*(?:[a-zA-Z0-9_-]{50,}=){5,}WAF mitigation (if patching is not yet possible)
Add this rule to your WAF to block exploitation attempts while you schedule the patch.
Implement request-level cookie header size validation: reject HTTP requests with Cookie headers exceeding 4096 bytes. Add rate limiting on the Tornado application level to detect clients sending repeated requests with unusually large or complex cookie structures within short time windows.How to check if you are affected
- Check installed Tornado version: python3 -c "import tornado; print(tornado.version)" and verify it is 6.4.2 or higher
- Identify Tornado applications in your environment: grep -r "import tornado" /opt /srv /home --include="*.py" 2>/dev/null | grep -v __pycache__
- Review web server access logs for abnormal cookie header sizes or repeated malformed cookie patterns: grep -i 'cookie' /var/log/nginx/access.log | awk -F'Cookie:' '{print $2}' | awk '{print length}' | sort -rn | head -20
- Verify the patch was applied by checking Tornado version again and confirming pip list shows tornado>=6.4.2 for Python package managers
FAQ
What is CVE-2024-52804?
CVE-2024-52804 is a denial-of-service vulnerability in Tornado's HTTP cookie parsing mechanism where specially crafted cookies trigger inefficient algorithmic behavior, causing the event loop thread to consume excessive CPU resources and blocking legitimate request processing.
Is CVE-2024-52804 being actively exploited?
No, this vulnerability is not currently listed in the CISA KEV catalog and no public exploits are available, though the attack is trivial to execute and organizations should still patch promptly.
What versions of Python are affected by CVE-2024-52804?
Tornado versions prior to 6.4.2 are affected. The vulnerability exists across all Tornado releases up to and including 6.4.1, regardless of the underlying Python 3 version.
How do I check if my server is vulnerable to CVE-2024-52804?
Run 'python3 -c "import tornado; print(tornado.version)"' and compare the output to 6.4.2. If the version is 6.4.1 or lower, the server is vulnerable.
Does Defensia detect CVE-2024-52804?
Yes — Defensia's CVE advisory scanner compares installed package versions against the NVD database. If Tornado is installed on a monitored server, CVE-2024-52804 will appear in your dashboard with remediation steps.
Related Python CVEs
References
Track CVEs across your fleet automatically
Defensia scans your Linux servers and tells you exactly which ones are running vulnerable versions — including CVE-2024-52804. Free for 1 server.
Get started free