Heap buffer overflow vulnerability in conncache.c: incorrect use of pointer arrays resulting in out-of-bounds memory writes.
The cpool_bundle struct in conncache.c uses a pointer array instead of a flexible array, causing a heap buffer overflow when copying a long destination string. An attacker could trigger memory corruption by supplying a hostname of a specific length, potentially leading to a crash or remote code execution.
Originally disclosed on HackerOne
- Disclosed after 41 days
In the conncache.c file, the cpool_bundle structure incorrectly uses a pointer array (char *dest[1]) instead of a flexible array (char dest[]) to store string data, leading to a heap buffer overflow when calling memcpy in the cpool_bundle_create function.
Impact
# Summary:
The vulnerability is a heap buffer overflow caused by the cpool_bundle struct in the conncache.c file that incorrectly uses the pointer array char *dest[1] instead of the flexible array char dest[]. In the cpool_bundle_create function, when calling memcpy(bundle->dest, dest, bundle->dest_len), if the target string length exceeds the pointer size (8 bytes on a 64-bit system), it causes writes to go out of bounds and corrupt heap memory.
An attacker can trigger this vulnerability by providing a hostname/destination address of a specific length, resulting in memory corruption, which could trigger a program crash or remote code execution. This vulnerability affects all curl applications that use the connection caching feature, especially when dealing with long hostnames.
The fix should change the struct definition to use the correct flexible array: char dest[] or char dest[1], and ensure that memory allocation correctly takes string length into account.
Attachments
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
The struct uses a pointer array instead of a flexible array, so the allocated space is too small for the string being copied.
Impact
An attacker could cause a crash or potentially achieve remote code execution by providing a hostname of a specific length.
What the attacker needed
Application uses connection caching; attacker can supply a hostname
The fix
The struct definition should be changed to use a flexible array and memory allocation should account for the string length.
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 program stores a hostname in a fixed-size slot meant for a pointer, but then copies a longer string into it, writing past the allocated memory. This can crash the program or let an attacker run their own code. The bug is in how the memory structure is defined and used.
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.