curl escape and unescape integer overflows
Project curl Security Advisory, September 14, 2016 - Permalink
The four libcurl functions
curl_easy_unescape perform string URL percent escaping
and unescaping. They accept custom string length inputs in signed integer
arguments. (The functions having names without "easy" being the deprecated
versions of the others.)
The provided string length arguments were not properly checked and due to
arithmetic in the functions, passing in the length 0xffffffff (2^32-1 or
UINT_MAX or even just -1) would end up causing an allocation of zero bytes
of heap memory that curl would attempt to write gigabytes of data into.
The use of 'int' for this input type in the API is of course unwise but has remained so in order to maintain the API over the years.
We are not aware of any exploit of this flaw.
This flaw does not affect the curl command line tool.
The Common Vulnerabilities and Exposures (CVE) project has assigned the name CVE-2016-7167 to this issue.
This flaw exists in the following libcurl versions.
- Affected versions: libcurl 7.11.1 to and including 7.50.2
- Not affected versions: libcurl < 7.11.1 and libcurl >= 7.50.3
libcurl is used by many applications, but not always advertised as such!
In version 7.50.3, these functions will deny negative string lengths from being used.
A patch for CVE-2016-7167 is available.
We suggest you take one of the following actions immediately, in order of preference:
A - Upgrade curl and libcurl to version 7.50.3
B - Apply the patch to your version and rebuild
C - Make sure you don't pass in string lengths larger than
(typically 2^31) or negative values to the
It was first reported to the curl project on September 8 by the Mitre CVE Assignment Team based on the discussions in PHP bug report 72674.
libcurl 7.50.3 was released on September 14 2016, coordinated with the publication of this advisory.
Thanks to the Mitre CVE Assignment Team for reporting this to us.