A UAF turned RCE
A use-after-free in curl's HTTP/2 upload handling left a dangling pointer to a freed easy handle, so when the multi handle was cleaned up, server-supplied data could be written into that freed memory. Under a narrow set of conditions an attacker could overwrite a function pointer and achieve remote code execution, though the text says the most likely outcome is a crash.
Published on daniel.haxx.se
In the curl 8.23.0 release we shipped a fix for one of the worst vulnerabilities in curl in a long time. We grade it severity HIGH.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely a dangling pointer to a freed easy handle was left behind after a stream reset, so multi-handle cleanup reused that freed memory for downloaded data and later called a function pointer stored there.
Impact
An attacker could potentially run remote code on the victim's machine, but many specific conditions must align, the payload area is tiny, and the most likely outcome is a crash, so the chance of success is described as slim.
What the attacker needed
Victim uploads to a malicious server; server certificate stays valid; upload size around 135KB; attacker knows curl's architecture
The fix
The fix was shipped in curl 8.23.0, and the project is reducing stored handle pointers in favour of transfer identifiers looked up on demand, plus adding tests and analyser coverage.
How it was found
- Have an application upload data over HTTP/2 to a server.
- The server zeroes the HTTP/2 window size to pause the send, returns part of the response, then resets the stream without closing the connection.
- curl finishes the transfer but leaves a pointer to the easy handle.
- The application frees the easy handle and then cleans up the multi handle.
- libcurl allocates a download buffer at the freed handle's memory and receives server data there, leaking internal client details.
- The received data overwrites a function pointer that libcurl then calls, running remote code.
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 write-up has not been written yet. The Original tab links to the source.
When a program frees memory it should stop using it, but here curl kept a pointer to memory it had already released. A malicious server could then place its own data in that reused space, and curl would later treat that data as instructions to follow. The result could be the attacker running their own code on the victim's machine, although the write-up says this is very hard to pull off and usually just crashes.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.