Bug 1552628 - (CVE-2018-1000120) CVE-2018-1000120 curl: FTP path trickery leads to NIL byte out of bounds write
CVE-2018-1000120 curl: FTP path trickery leads to NIL byte out of bounds write
Status: NEW
Product: Security Response
Classification: Other
Component: vulnerability (Show other bugs)
All Linux
medium Severity medium
: ---
: ---
Assigned To: Red Hat Product Security
: Security
Depends On: 1555207 1555208 1555210 1555221 1555222 1555209
Blocks: 1552634
  Show dependency treegraph
Reported: 2018-03-07 08:07 EST by Andrej Nemec
Modified: 2018-07-12 10:40 EDT (History)
25 users (show)

See Also:
Fixed In Version: curl 7.59.0
Doc Type: If docs needed, set a value
Doc Text:
It was found that libcurl did not safely parse FTP URLs when using the CURLOPT_FTP_FILEMETHOD 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.
Story Points: ---
Clone Of:
Last Closed:
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
upstream patch (4.18 KB, patch)
2018-03-07 08:17 EST, Andrej Nemec
no flags Details | Diff

  None (edit)
Description Andrej Nemec 2018-03-07 08:07:21 EST
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

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

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
`size_t index = directory_len - filepart_len` end up with a huge index
variable for where the zero byte gets stored: `heap_buffer[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.
Comment 1 Andrej Nemec 2018-03-07 08:07:29 EST

Name: the Curl project
Upstream: Duy Phan Thanh
Comment 2 Andrej Nemec 2018-03-07 08:17 EST
Created attachment 1405333 [details]
upstream patch
Comment 4 Cedric Buissart 2018-03-13 16:57:48 EDT

Preventing application from using non-default CURLOPT_FTP_FILEMETHOD will avoid triggering the vulnerable code.
Comment 5 Adam Mariš 2018-03-14 03:30:53 EDT
External References:

Comment 6 Adam Mariš 2018-03-14 03:33:39 EDT
Created mingw-curl tracking bugs for this issue:

Affects: fedora-all [bug 1555207]

Created curl tracking bugs for this issue:

Affects: fedora-all [bug 1555209]

Created mingw-curl tracking bugs for this issue:

Affects: epel-7 [bug 1555208]
Comment 9 Cedric Buissart 2018-03-14 04:35:48 EDT
Upstream commit: 
 FTP: reject path components with control codes 

Note You need to log in before you can comment on or make changes to this bug.