Vigil@ance : libcurl, buffer overflow via uncompression
February 2010 by Vigil@nce
SYNTHESIS OF THE VULNERABILITY
An attacker, who owns a web server, can return data compressed with Deflate (zlib), in order to generate an overflow in applications linked to libcurl.
Consequences: user access/rights, denial of service of client
Provenance: internet server
Means of attack: no proof of concept, no attack
Ability of attacker: expert (4/4)
Confidence: confirmed by the editor (5/5)
Diffusion of the vulnerable configuration: high (3/3)
Creation date: 09/02/2010
DESCRIPTION OF THE VULNERABILITY
The libcurl library offers a callback system for applications. In
this case, the application defines a function such as:
size_t write_data(void *buffer, size_t size, size_t nmemb, void *userp);
This function is referenced with:
curl_easy_setopt(easyhandle, CURLOPT_WRITEFUNCTION, write_data);
Then each time libcurl wants to write data, it calls the write_data() function.
Data coming from the web site can be automatically uncompressed by
Deflate (zlib) if the application uses (this option is not set by
curl_easy_setopt(d->m_handle, CURLOPT_HTTP_CONTENT_DECODING, true);
The libcurl documentation indicates that the maximal size of data given to the write_data() function is CURL_MAX_WRITE_SIZE (16k) bytes.
However, if data coming form the web site is automatically uncompressed by Deflate, the maximal size of data given to the write_data() function is 64k bytes. If the write_data() function is not conceived to manage this amount of data, this generates an overflow.
An attacker, who owns a web server, can therefore return data compressed with Deflate (zlib), in order to generate an overflow in applications linked to libcurl.
No public application linked to libcurl is known to be impacted by this vulnerability.
Identifiers: BID-38162, VIGILANCE-VUL-9420