Use-After-Free in curl’s SMB connection reuse
curl's SMB connection reuse frees memory that a request path pointer still references, causing a use-after-free when the path is later read. An attacker could crash the application or potentially leak or corrupt memory.
If you tell curl to fetch two different SMB files from the same server, it might crash because it tries to read memory that was already freed — a Use-After-Free.
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, the request path pointer points into connection-owned memory that is freed during connection reuse, leading to a dangling pointer.
Impact
An attacker could crash the application (denial of service), potentially leak sensitive information from freed memory, or possibly achieve code execution if they control the freed memory contents.
What the attacker needed
Curl built with SMB support; ability to supply two SMB URLs
The fix
The fix should make the request path independent by copying the string instead of pointing into connection-owned memory, or by nulling related pointers when the connection is freed.
How it was found
- Build curl with AddressSanitizer and SMB support.
- Run a fake SMB server on a local port.
- Use curl to request two different SMB files from the same server.
- Observe the heap-use-after-free error from AddressSanitizer.
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 curl fetches two SMB files from the same server, it reuses the connection to save time. But during reuse, it frees some memory that a pointer still points to. Later, when curl tries to read that pointer, it accesses freed memory, which can crash the program or worse.
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.