CVE-2018-1000120: Buffer Overflow
A buffer overflow exists in curl 7.12.3 to and including curl 7.58.0 in the FTP URL handling that allows an attacker to cause a denial of service or worse.
Other sources
It was found that curl can be fooled into writing a zero byte out of bounds.
This bug can trigger when curl is told to work on an FTP URL, with the setting to only issue a single CWD command (--ftp-method singlecwd or the libcurl alternative CURLOPTFTPFILEMETHOD).
curl then URL-decodes the given path, calls strlen() on the result and deducts the length of the file name part to find the end of the directory within the buffer. It then writes a zero byte on that index, in a buffer allocated on the heap.
If the directory part of the URL contains a "%00" sequence, the directory length might end up shorter than the file name path, making the calculation sizet index = directorylen - filepartlen end up with a huge index variable for where the zero byte gets stored: heapbuffer[index] = 0. On several architectures that huge index will wrap and work as a negative value, thus overwriting memory before the intended heap buffer.
By using different file part lengths and putting %00 in different places in the URL, an attacker that can control what paths a curl-using application uses can write that zero byte on different indexes.
— Red Hat
It was found that libcurl did not safely parse FTP URLs when using the CURLOPTFTPFILEMETHOD method. An attacker, able to provide a specially crafted FTP URL to an application using libcurl, could write a NULL byte at an arbitrary location, resulting in a crash or an unspecified behavior.
Affected Software
Remediation
Recommended actions to resolve this vulnerability, in priority order.
- Upgrade
Upgrade
redhat/curlto a version that resolves this vulnerability.Fixed in 0:7.29.0-51.el7 - Upgrade
Upgrade
redhat/nss-pemto a version that resolves this vulnerability.Fixed in 0:1.0.3-5.el7 - Upgrade
Upgrade
redhat/curlto a version that resolves this vulnerability.Fixed in 0:7.29.0-42.el7_4.2 - Upgrade
Upgrade
redhat/curlto a version that resolves this vulnerability.Fixed in 0:7.29.0-46.el7_5.1 - Upgrade
Upgrade
redhat/httpd24-curlto a version that resolves this vulnerability.Fixed in 0:7.61.1-1.el6 - Upgrade
Upgrade
redhat/httpd24-httpdto a version that resolves this vulnerability.Fixed in 0:2.4.34-7.el6 - Upgrade
Upgrade
redhat/httpd24-nghttp2to a version that resolves this vulnerability.Fixed in 0:1.7.1-7.el6 - Upgrade
Upgrade
redhat/httpd24-curlto a version that resolves this vulnerability.Fixed in 0:7.61.1-1.el7 - Upgrade
Upgrade
redhat/httpd24-httpdto a version that resolves this vulnerability.Fixed in 0:2.4.34-7.el7 - Upgrade
Upgrade
redhat/httpd24-nghttp2to a version that resolves this vulnerability.Fixed in 0:1.7.1-7.el7 - Upgrade
Upgrade
redhat/curlto a version that resolves this vulnerability.Fixed in 7.59.0 - Upgrade
Upgrade
debian/curlto a version that resolves this vulnerability.Fixed in 7.74.0-1.3+deb11u13Fixed in 7.74.0-1.3+deb11u16Fixed in 7.88.1-10+deb12u14Fixed in 7.88.1-10+deb12u5Fixed in 8.14.1-2+deb13u3Fixed in 8.20.0-5Fixed in 8.21.0~rc2-1 - Upgrade
Upgrade
debian/curlto a version that resolves this vulnerability.Fixed in 7.74.0-1.3+deb11u13 - Upgrade
Upgrade
debian/curlto a version that resolves this vulnerability.Fixed in 7.74.0-1.3+deb11u16 - Upgrade
Upgrade
debian/curlto a version that resolves this vulnerability.Fixed in 7.88.1-10+deb12u14 - Upgrade
Upgrade
debian/curlto a version that resolves this vulnerability.Fixed in 7.88.1-10+deb12u5 - Upgrade
Upgrade
debian/curlto a version that resolves this vulnerability.Fixed in 8.14.1-2+deb13u3 - Upgrade
Upgrade
debian/curlto a version that resolves this vulnerability.Fixed in 8.20.0-5 - Upgrade
Upgrade
debian/curlto a version that resolves this vulnerability.Fixed in 8.21.0~rc2-1 - Configuration
Ensure applications do not set CURLOPT_FTP_FILEMETHOD to a non-default value; keep the FTP file method at the library default to avoid invoking the vulnerable FTP URL parsing code.
libcurl CURLOPT_FTP_FILEMETHOD = do not use non-default - Configuration
Avoid using the --ftp-method singlecwd (or other non-default ftp-methods) on the curl command line; use the default FTP method so the vulnerable code path is not triggered.
curl (CLI) --ftp-method = do not use 'singlecwd' or other non-defaults
Event History
Parent advisories
This vulnerability appears in the following advisories.
Frequently Asked Questions
What is the vulnerability ID?
The vulnerability ID is CVE-2018-1000120.
What is the severity of CVE-2018-1000120?
The severity of CVE-2018-1000120 is critical.
What is the affected software for CVE-2018-1000120?
The affected software for CVE-2018-1000120 includes curl versions 7.12.3 to 7.58.0 and certain versions of debian, Ubuntu, Redhat, and Oracle products.
How can an attacker exploit CVE-2018-1000120?
An attacker can exploit CVE-2018-1000120 by providing a specially crafted FTP URL to an application using libcurl, which can result in a crash or unspecified behavior.
Are there any available fixes for CVE-2018-1000120?
Yes, the recommended fix for CVE-2018-1000120 is to upgrade to curl version 7.59.0 or higher.