Skip to content
Smuggling / CRLF Disclosed report Intermediate

CRLF Injection via Custom HTTP Headers

libcurl writes user-supplied custom headers directly into the HTTP request buffer without stripping carriage return and line feed characters. An attacker who can influence a header value passed via CURLOPT_HTTPHEADER could inject arbitrary HTTP headers.

bugthiru Follow

Originally disclosed on HackerOne

Informational View original
  • Disclosed after 25 days

Summary:

libcurl writes user-supplied custom headers directly into the HTTP request buffer without stripping \r\n characters. The raw input pointer origp in Curl_add_custom_headers() (lib/http.c) is serialized verbatim into the outgoing request using curlx_dyn_addf(req, "%s\r\n", origp) instead of using the already-parsed, newline-safe name and val components. This allows an attacker who can influence a header value passed via CURLOPT_HTTPHEADER to inject arbitrary HTTP headers.

Steps To Reproduce

  1. Build a simple C program or use any language binding (PHP, Python, etc.)

  2. Pass a header string containing an embedded \r\n via CURLOPT_HTTPHEADER:

โ€˜ #include <curl/curl.h>

int main(void) { CURL *curl = curl_easy_init(); struct curl_slist *headers = NULL;

// Simulates attacker-controlled input in a header value
headers = curl_slist_append(headers,
    "X-Custom: legitimate\r\nInjected-Header: evil-value");

curl_easy_setopt(curl, CURLOPT_URL, "http://httpbin.org/get");
curl_easy_setopt(curl, CURLOPT_HTTPHEADER, headers);
curl_easy_perform(curl);

curl_slist_free_all(headers);
curl_easy_cleanup(curl);
return 0;

}โ€™

  1. Capture the outgoing request with Wireshark or a netcat listener (nc -l 8080)

  2. Observe that Injected-Header: evil-value appears as a separate header in the raw Http request

Expected Result: libcurl should reject or strip \r\n from header strings, or return an error when such characters are detected

Actual Result: The injected content appears as a fully formed separate HTTP header on the wire.

Impact

Impacts:

An application that passes any user-influenced data into CURLOPT_HTTPHEADER without pre-sanitizing \r\n is vulnerable to header injection, request splitting, authentication bypass, and cache poisoning.

The original report as published on HackerOne, by bugthiru. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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 function Curl_add_custom_headers() serialises the raw user-supplied header string directly into the request instead of using the already-parsed, newline-safe name and value components.

Impact

An application that passes user-influenced data into CURLOPT_HTTPHEADER without pre-sanitising carriage return and line feed characters is vulnerable to header injection, request splitting, authentication bypass, and cache poisoning.

What the attacker needed

Attacker controls a header value; application uses libcurl; no pre-sanitisation of CRLF

The fix

libcurl should reject or strip carriage return and line feed characters from header strings, or return an error when such characters are detected.

How it was found

  1. Build a simple C program or use any language binding.
  2. Pass a header string containing an embedded carriage return and line feed via CURLOPT_HTTPHEADER.
  3. Capture the outgoing request with Wireshark or a netcat listener.
  4. Observe that the injected header appears as a separate header in the raw HTTP request.

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.

When a program sends a web request, it includes extra pieces of information called headers. This report shows that a library called libcurl does not clean up special newline characters in those headers, so an attacker could sneak in extra headers that the server might trust.

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.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Request smuggling and header injection

The lesson behind this report.

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.