Double-free of `trailers_buf' on `Curl_http_compile_trailers()` failure
A double-free occurs in curl's HTTP trailer handling when the function that compiles trailers fails, because the buffer pointer is not passed by reference and is freed twice. The reporter states this could cause memory corruption, though they did not actually reproduce it.
- Disclosed after 16 months
Summary:
When Curl_http_compile_trailers() fails, trailers_buf is freed twice, because we don't pass to this function the pointer value by reference.
Steps To Reproduce:
Did not actually reproduce, please double check patch attached and analysis.
Impact
Some memory corruption due to the double-free.
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 buffer pointer is passed by value rather than by reference, so the caller's pointer is not updated or cleared after the function frees it, leading to a second free on the error path.
Impact
The double-free could lead to memory corruption, though the reporter did not reproduce it and only provided analysis and a patch.
What the attacker needed
Trailer compilation must fail
The fix
The pointer should be passed by reference so the caller's pointer is updated or cleared, preventing the second free; the reporter attached a patch but the text does not say it was merged.
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.
A double-free is a memory bug where the same memory is released twice. Here a buffer is freed twice when trailer compilation fails, which can cause memory corruption.
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.