curl · Report #3484431
HTTP Request Smuggling and SSRF via CRLF Injection in Curl_add_custom_headers
How it was found
Summary:
A lack of CRLF validation in Curl_add_custom_headers at lib/http.c:1761 allows users to inject arbitrary HTTP headers. This violation of RFC 7230 §3.2.4 leads to HTTP Request Smuggling and potential SSRF bypass. AI Disclosure: I utilized an AI assistant to aid in the initial code analysis and patch generation, but I have manually verified all claims using hex dumps and proxy simulations to ensure technical accuracy.
Affected version
- curl/libcurl version: 8.18.0-DEV and 8.15.0
- Platform: Linux (Kali Linux)
- curl -V output:
curl 8.18.0-DEV (x86_64-pc-linux-gnu) libcurl/8.18.0-DEV OpenSSL/3.5.4
Steps To Reproduce:
- Start a listener to capture raw traffic:
nc -l -p 8080 > raw_http.txt. - Execute a
libcurlapplication (or curl CLI) that appends a custom header containing CRLF:curl -H "X-Injected: Value\r\nInjected-Header: Malicious" http://localhost:8080. - Inspect the captured output:
hexdump -C raw_http.txt. - Observe that the CRLF bytes (
0d 0a) are transmitted unsanitized, causing the receiver to interpret the injected string as a separate, valid HTTP header.
Supporting Material/References:
- Hexdump Proof: The hex dump shows
0d 0aat offset0x49, confirming request splitting at the protocol level. - Suggested Patch: A verification patch using
strchrto reject\rand\ninlib/http.csuccessfully mitigates the issue.
Impact
The lack of CRLF validation in
libcurl's header handling allows for HTTP Request Smuggling, enabling an attacker to bypass security boundaries and perform Server-Side Request Forgery (SSRF). Aslibcurlis a foundational library used by countless applications and backends, this vulnerability poses a systemic risk. Specifically, injected headers persist across redirects (-L), which significantly increases the attack surface and allows for the potential exposure of isolated internal services or cache poisoning.