CVE-2023-38039: HTTP header allocation DOS
curl did not limit the number of HTTP headers it would accept from a server, so a malicious server could keep sending new headers on an open socket and make the client allocate memory without bound. An attacker running such a server could exhaust the resources of a victim's machine that connects to it with curl.
- Disclosed after 58 days
It was found that curl does not currently limit the amount of HTTP headers to be received leading to a potential DOS for the users. If an attacker sets up a malicious HTTP server that continuously sends new headers and keeps the socket open, curl will continuously listen on the socket and parse new received headers. This leads to the user's machine allocating more and more resources until the system is eventually exhausted. From research the vulnerable function seems to be located at https://github.com/curl/curl/blob/master/lib/transfer.c#L420. For comparison, modern browsers abort the connection once they reach a threshold. One potential fix to not affect functionality too much would be to set an arbitrary limit to the amount of headers to receive, which I believe is the solution adapted by most modern browsers to solve this issue.
Screenshot

My excuses for the French in screenshot (I'm sorting programs by RAM usage, and the top one is of course the windows terminal from which I executed curl). On there you can see my user terminal (windows) launching curl 127.0.0.1:80 to the left, on the right we see the attacker's server (attaching full source code to this report). Throughout testing memory usage kept increasing alarmingly high.
Malicious server code extract:
void send_payload(int fd)
{
memset(speedup, 'a', sizeof(speedup));
//first we send the start of a valid HTTP request with status line and a few headers
send(fd, validreq, sizeof(validreq), MSG_MORE);
while (1337)
{
//this is used to speed up the dos process sending extra bytes
send(fd, speedup, sizeof(speedup), MSG_MORE );
//now we're spamming the curl client with the header "a:b" then telling it there's more to come !
send(fd, "a:b\x0d\x0a", 5, MSG_MORE );
}
}
Steps To Reproduce:
- Compile exploit.c and execute the server binary.
Note: depending on your system, feel free to play with the ATTACK_SPEED define of the code, to speed up testing.
2. Open up another terminal and as the victim try curl 127.0.0.1:80
3. Observe system metrics.
Impact
DOS/overloading of user's system through malicious HTTP server interaction with curl's header parsing.
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-parsing loop in curl's transfer code had no cap on the number of headers accepted, so each new header was stored without limit.
Impact
A malicious HTTP server could cause a denial of service by exhausting the memory of a user's machine running curl.
What the attacker needed
Victim connects to attacker's server; attacker controls the HTTP server
The fix
curl should be changed to enforce a limit on the number of headers it will accept, as modern browsers do.
How it was found
- Compile and run the malicious server program.
- In another terminal, run curl against the local server as the victim.
- Watch system metrics such as memory usage while the transfer continues.
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 curl talks to a web server, it reads the reply line by line, including the small labels called headers. This report shows curl never set a maximum on how many headers it would read, so a hostile server could keep sending them forever and the program kept storing them, using more and more memory until the computer struggled. Browsers avoid this by cutting the connection once too many headers arrive.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.