CVE Vulnerabilities

CVE-2017-1000254

Improper Restriction of Operations within the Bounds of a Memory Buffer

Published: Oct 06, 2017 | Modified: Nov 07, 2023
CVSS 3.x
7.5
HIGH
Source:
NVD
CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H
CVSS 2.x
5 MEDIUM
AV:N/AC:L/Au:N/C:N/I:N/A:P
RedHat/V2
RedHat/V3
3.7 MODERATE
CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:N/A:L
Ubuntu
MEDIUM

libcurl may read outside of a heap allocated buffer when doing FTP. When libcurl connects to an FTP server and successfully logs in (anonymous or not), it asks the server for the current directory with the PWD command. The server then responds with a 257 response containing the path, inside double quotes. The returned path name is then kept by libcurl for subsequent uses. Due to a flaw in the string parser for this directory name, a directory name passed like this but without a closing double quote would lead to libcurl not adding a trailing NUL byte to the buffer holding the name. When libcurl would then later access the string, it could read beyond the allocated heap buffer and crash or wrongly access data beyond the buffer, thinking it was part of the path. A malicious server could abuse this fact and effectively prevent libcurl-based clients to work with it - the PWD command is always issued on new FTP connections and the mistake has a high chance of causing a segfault. The simple fact that this has issue remained undiscovered for this long could suggest that malformed PWD responses are rare in benign servers. We are not aware of any exploit of this flaw. This bug was introduced in commit 415d2e7cb7, March 2005. In libcurl version 7.56.0, the parser always zero terminates the string but also rejects it if not terminated properly with a final double quote.

Weakness

The product performs operations on a memory buffer, but it can read from or write to a memory location that is outside of the intended boundary of the buffer.

Affected Software

Name Vendor Start Version End Version
Libcurl Haxx 7.7 (including) 7.7 (including)
Libcurl Haxx 7.7.1 (including) 7.7.1 (including)
Libcurl Haxx 7.7.2 (including) 7.7.2 (including)
Libcurl Haxx 7.7.3 (including) 7.7.3 (including)
Libcurl Haxx 7.8 (including) 7.8 (including)
Libcurl Haxx 7.8.1 (including) 7.8.1 (including)
Libcurl Haxx 7.9 (including) 7.9 (including)
Libcurl Haxx 7.9.1 (including) 7.9.1 (including)
Libcurl Haxx 7.9.2 (including) 7.9.2 (including)
Libcurl Haxx 7.9.3 (including) 7.9.3 (including)
Libcurl Haxx 7.9.4 (including) 7.9.4 (including)
Libcurl Haxx 7.9.5 (including) 7.9.5 (including)
Libcurl Haxx 7.9.6 (including) 7.9.6 (including)
Libcurl Haxx 7.9.7 (including) 7.9.7 (including)
Libcurl Haxx 7.9.8 (including) 7.9.8 (including)
Libcurl Haxx 7.10 (including) 7.10 (including)
Libcurl Haxx 7.10.1 (including) 7.10.1 (including)
Libcurl Haxx 7.10.2 (including) 7.10.2 (including)
Libcurl Haxx 7.10.3 (including) 7.10.3 (including)
Libcurl Haxx 7.10.4 (including) 7.10.4 (including)
Libcurl Haxx 7.10.5 (including) 7.10.5 (including)
Libcurl Haxx 7.10.6 (including) 7.10.6 (including)
Libcurl Haxx 7.10.7 (including) 7.10.7 (including)
Libcurl Haxx 7.10.8 (including) 7.10.8 (including)
Libcurl Haxx 7.11.0 (including) 7.11.0 (including)
Libcurl Haxx 7.11.1 (including) 7.11.1 (including)
Libcurl Haxx 7.11.2 (including) 7.11.2 (including)
Libcurl Haxx 7.12.0 (including) 7.12.0 (including)
Libcurl Haxx 7.12.1 (including) 7.12.1 (including)
Libcurl Haxx 7.12.2 (including) 7.12.2 (including)
Libcurl Haxx 7.12.3 (including) 7.12.3 (including)
Libcurl Haxx 7.13.0 (including) 7.13.0 (including)
Libcurl Haxx 7.13.1 (including) 7.13.1 (including)
Libcurl Haxx 7.13.2 (including) 7.13.2 (including)
Libcurl Haxx 7.14.0 (including) 7.14.0 (including)
Libcurl Haxx 7.14.1 (including) 7.14.1 (including)
Libcurl Haxx 7.15.0 (including) 7.15.0 (including)
Libcurl Haxx 7.15.1 (including) 7.15.1 (including)
Libcurl Haxx 7.15.2 (including) 7.15.2 (including)
Libcurl Haxx 7.15.3 (including) 7.15.3 (including)
Libcurl Haxx 7.15.4 (including) 7.15.4 (including)
Libcurl Haxx 7.15.5 (including) 7.15.5 (including)
Libcurl Haxx 7.16.0 (including) 7.16.0 (including)
Libcurl Haxx 7.16.1 (including) 7.16.1 (including)
Libcurl Haxx 7.16.2 (including) 7.16.2 (including)
Libcurl Haxx 7.16.3 (including) 7.16.3 (including)
Libcurl Haxx 7.16.4 (including) 7.16.4 (including)
Libcurl Haxx 7.17.0 (including) 7.17.0 (including)
Libcurl Haxx 7.17.1 (including) 7.17.1 (including)
Libcurl Haxx 7.18.0 (including) 7.18.0 (including)
Libcurl Haxx 7.18.1 (including) 7.18.1 (including)
Libcurl Haxx 7.18.2 (including) 7.18.2 (including)
Libcurl Haxx 7.19.0 (including) 7.19.0 (including)
Libcurl Haxx 7.19.1 (including) 7.19.1 (including)
Libcurl Haxx 7.19.2 (including) 7.19.2 (including)
Libcurl Haxx 7.19.3 (including) 7.19.3 (including)
Libcurl Haxx 7.19.4 (including) 7.19.4 (including)
Libcurl Haxx 7.19.5 (including) 7.19.5 (including)
Libcurl Haxx 7.19.6 (including) 7.19.6 (including)
Libcurl Haxx 7.19.7 (including) 7.19.7 (including)
Libcurl Haxx 7.20.0 (including) 7.20.0 (including)
Libcurl Haxx 7.20.1 (including) 7.20.1 (including)
Libcurl Haxx 7.21.0 (including) 7.21.0 (including)
Libcurl Haxx 7.21.1 (including) 7.21.1 (including)
Libcurl Haxx 7.21.2 (including) 7.21.2 (including)
Libcurl Haxx 7.21.3 (including) 7.21.3 (including)
Libcurl Haxx 7.21.4 (including) 7.21.4 (including)
Libcurl Haxx 7.21.5 (including) 7.21.5 (including)
Libcurl Haxx 7.21.6 (including) 7.21.6 (including)
Libcurl Haxx 7.21.7 (including) 7.21.7 (including)
Libcurl Haxx 7.22.0 (including) 7.22.0 (including)
Libcurl Haxx 7.23.0 (including) 7.23.0 (including)
Libcurl Haxx 7.23.1 (including) 7.23.1 (including)
Libcurl Haxx 7.24.0 (including) 7.24.0 (including)
Libcurl Haxx 7.25.0 (including) 7.25.0 (including)
Libcurl Haxx 7.26.0 (including) 7.26.0 (including)
Libcurl Haxx 7.27.0 (including) 7.27.0 (including)
Libcurl Haxx 7.28.0 (including) 7.28.0 (including)
Libcurl Haxx 7.28.1 (including) 7.28.1 (including)
Libcurl Haxx 7.29.0 (including) 7.29.0 (including)
Libcurl Haxx 7.30.0 (including) 7.30.0 (including)
Libcurl Haxx 7.31.0 (including) 7.31.0 (including)
Libcurl Haxx 7.32.0 (including) 7.32.0 (including)
Libcurl Haxx 7.33.0 (including) 7.33.0 (including)
Libcurl Haxx 7.34.0 (including) 7.34.0 (including)
Libcurl Haxx 7.35.0 (including) 7.35.0 (including)
Libcurl Haxx 7.36.0 (including) 7.36.0 (including)
Libcurl Haxx 7.37.0 (including) 7.37.0 (including)
Libcurl Haxx 7.37.1 (including) 7.37.1 (including)
Libcurl Haxx 7.38.0 (including) 7.38.0 (including)
Libcurl Haxx 7.39 (including) 7.39 (including)
Libcurl Haxx 7.40.0 (including) 7.40.0 (including)
Libcurl Haxx 7.41.0 (including) 7.41.0 (including)
Libcurl Haxx 7.42.0 (including) 7.42.0 (including)
Libcurl Haxx 7.42.1 (including) 7.42.1 (including)
Libcurl Haxx 7.43.0 (including) 7.43.0 (including)
Libcurl Haxx 7.44.0 (including) 7.44.0 (including)
Libcurl Haxx 7.45.0 (including) 7.45.0 (including)
Libcurl Haxx 7.46.0 (including) 7.46.0 (including)
Libcurl Haxx 7.47.0 (including) 7.47.0 (including)
Libcurl Haxx 7.47.1 (including) 7.47.1 (including)
Libcurl Haxx 7.48.0 (including) 7.48.0 (including)
Libcurl Haxx 7.49.0 (including) 7.49.0 (including)
Libcurl Haxx 7.49.1 (including) 7.49.1 (including)
Libcurl Haxx 7.50.0 (including) 7.50.0 (including)
Libcurl Haxx 7.50.1 (including) 7.50.1 (including)
Libcurl Haxx 7.50.2 (including) 7.50.2 (including)
Libcurl Haxx 7.50.3 (including) 7.50.3 (including)
Libcurl Haxx 7.51.0 (including) 7.51.0 (including)
Libcurl Haxx 7.52.0 (including) 7.52.0 (including)
Libcurl Haxx 7.52.1 (including) 7.52.1 (including)
Libcurl Haxx 7.53.0 (including) 7.53.0 (including)
Libcurl Haxx 7.53.1 (including) 7.53.1 (including)
Libcurl Haxx 7.54.0 (including) 7.54.0 (including)
Libcurl Haxx 7.54.1 (including) 7.54.1 (including)
Libcurl Haxx 7.55.0 (including) 7.55.0 (including)
Libcurl Haxx 7.55.1 (including) 7.55.1 (including)
Curl Ubuntu artful *
Curl Ubuntu devel *
Curl Ubuntu trusty *
Curl Ubuntu upstream *
Curl Ubuntu vivid/ubuntu-core *
Curl Ubuntu xenial *
Curl Ubuntu zesty *
Red Hat JBoss Core Services 1 RedHat curl *
Red Hat Software Collections for Red Hat Enterprise Linux 6 RedHat httpd24-curl-0:7.61.1-1.el6 *
Red Hat Software Collections for Red Hat Enterprise Linux 6 RedHat httpd24-httpd-0:2.4.34-7.el6 *
Red Hat Software Collections for Red Hat Enterprise Linux 6 RedHat httpd24-nghttp2-0:1.7.1-7.el6 *
Red Hat Software Collections for Red Hat Enterprise Linux 7 RedHat httpd24-curl-0:7.61.1-1.el7 *
Red Hat Software Collections for Red Hat Enterprise Linux 7 RedHat httpd24-httpd-0:2.4.34-7.el7 *
Red Hat Software Collections for Red Hat Enterprise Linux 7 RedHat httpd24-nghttp2-0:1.7.1-7.el7 *
Red Hat Software Collections for Red Hat Enterprise Linux 7.4 EUS RedHat httpd24-curl-0:7.61.1-1.el7 *
Red Hat Software Collections for Red Hat Enterprise Linux 7.4 EUS RedHat httpd24-httpd-0:2.4.34-7.el7 *
Red Hat Software Collections for Red Hat Enterprise Linux 7.4 EUS RedHat httpd24-nghttp2-0:1.7.1-7.el7 *
Red Hat Software Collections for Red Hat Enterprise Linux 7.5 EUS RedHat httpd24-curl-0:7.61.1-1.el7 *
Red Hat Software Collections for Red Hat Enterprise Linux 7.5 EUS RedHat httpd24-httpd-0:2.4.34-7.el7 *
Red Hat Software Collections for Red Hat Enterprise Linux 7.5 EUS RedHat httpd24-nghttp2-0:1.7.1-7.el7 *
Red Hat Software Collections for Red Hat Enterprise Linux 7.6 EUS RedHat httpd24-curl-0:7.61.1-1.el7 *
Red Hat Software Collections for Red Hat Enterprise Linux 7.6 EUS RedHat httpd24-httpd-0:2.4.34-7.el7 *
Red Hat Software Collections for Red Hat Enterprise Linux 7.6 EUS RedHat httpd24-nghttp2-0:1.7.1-7.el7 *

Extended Description

Certain languages allow direct addressing of memory locations and do not automatically ensure that these locations are valid for the memory buffer that is being referenced. This can cause read or write operations to be performed on memory locations that may be associated with other variables, data structures, or internal program data. As a result, an attacker may be able to execute arbitrary code, alter the intended control flow, read sensitive information, or cause the system to crash.

Potential Mitigations

  • Use a language that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.

  • For example, many languages that perform their own memory management, such as Java and Perl, are not subject to buffer overflows. Other languages, such as Ada and C#, typically provide overflow protection, but the protection can be disabled by the programmer.

  • Be wary that a language’s interface to native code may still be subject to overflows, even if the language itself is theoretically safe.

  • Use a vetted library or framework that does not allow this weakness to occur or provides constructs that make this weakness easier to avoid.

  • Examples include the Safe C String Library (SafeStr) by Messier and Viega [REF-57], and the Strsafe.h library from Microsoft [REF-56]. These libraries provide safer versions of overflow-prone string-handling functions.

  • Use automatic buffer overflow detection mechanisms that are offered by certain compilers or compiler extensions. Examples include: the Microsoft Visual Studio /GS flag, Fedora/Red Hat FORTIFY_SOURCE GCC flag, StackGuard, and ProPolice, which provide various mechanisms including canary-based detection and range/index checking.

  • D3-SFCV (Stack Frame Canary Validation) from D3FEND [REF-1334] discusses canary-based detection in detail.

  • Consider adhering to the following rules when allocating and managing an application’s memory:

  • Run or compile the software using features or extensions that randomly arrange the positions of a program’s executable and libraries in memory. Because this makes the addresses unpredictable, it can prevent an attacker from reliably jumping to exploitable code.

  • Examples include Address Space Layout Randomization (ASLR) [REF-58] [REF-60] and Position-Independent Executables (PIE) [REF-64]. Imported modules may be similarly realigned if their default memory addresses conflict with other modules, in a process known as “rebasing” (for Windows) and “prelinking” (for Linux) [REF-1332] using randomly generated addresses. ASLR for libraries cannot be used in conjunction with prelink since it would require relocating the libraries at run-time, defeating the whole purpose of prelinking.

  • For more information on these techniques see D3-SAOR (Segment Address Offset Randomization) from D3FEND [REF-1335].

  • Use a CPU and operating system that offers Data Execution Protection (using hardware NX or XD bits) or the equivalent techniques that simulate this feature in software, such as PaX [REF-60] [REF-61]. These techniques ensure that any instruction executed is exclusively at a memory address that is part of the code segment.

  • For more information on these techniques see D3-PSEP (Process Segment Execution Prevention) from D3FEND [REF-1336].

References