HTTP Request Smuggling and SSRF via CRLF Injection in Curl_add_custom_headers
The curl library did not reject carriage-return and line-feed characters in custom HTTP headers supplied by the caller, so an injected header string was sent as a separate header on the wire. An attacker who can influence a header value could split the request and add their own headers, which the report says could enable request smuggling and SSRF bypass.
- Disclosed after 9 hours
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.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the header-building function in lib/http.c appended caller-supplied header strings without checking for carriage-return or line-feed characters.
Impact
The report claims this could enable HTTP request smuggling and SSRF bypass, and that injected headers persist across redirects, potentially exposing internal services or poisoning caches; no end-to-end exploit against a real server is shown.
What the attacker needed
Attacker controls a custom header value; application passes untrusted data as a header
The fix
The report says a patch that rejects carriage-return and line-feed characters in lib/http.c mitigates the issue, but does not state that it was merged or released.
How it was found
- Start a listener that captures raw traffic to a file.
- Run a curl or libcurl client that sends a custom header containing carriage-return and line-feed characters.
- Inspect the captured bytes with a hex dump.
- See that the line-break bytes were sent unchanged and the receiver treats the injected text as a separate header.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
HTTP messages separate their headers with special line-break characters. If a program lets those characters slip into a header value, the receiving server thinks a new header has started. Here the curl library did not check for them, so a crafted header value could add extra headers to the request.
What is Smuggling / CRLF?
A front end and a back end split one connection's bytes into requests differently, letting an attacker hide a request inside another user's.