CVE Vulnerabilities

CVE-2018-14036

Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal')

Published: Jul 13, 2018 | Modified: Nov 21, 2024
CVSS 3.x
6.5
MEDIUM
Source:
NVD
CVSS:3.0/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N
CVSS 2.x
4 MEDIUM
AV:N/AC:L/Au:S/C:P/I:N/A:N
RedHat/V2
RedHat/V3
5 MODERATE
CVSS:3.0/AV:L/AC:L/PR:L/UI:R/S:U/C:H/I:N/A:N
Ubuntu
LOW
root.io logo minimus.io logo echo.ai logo

Directory Traversal with ../ sequences occurs in AccountsService before 0.6.50 because of an insufficient path check in user_change_icon_file_authorized_cb() in user.c.

Weakness

The product uses external input to construct a pathname that is intended to identify a file or directory that is located underneath a restricted parent directory, but the product does not properly neutralize special elements within the pathname that can cause the pathname to resolve to a location that is outside of the restricted directory.

Affected Software

NameVendorStart VersionEnd Version
AccountsserviceFreedesktop*0.6.50 (excluding)
Red Hat Enterprise Linux 7RedHataccountsservice-0:0.6.50-2.el7*
Red Hat Enterprise Linux 7RedHatadwaita-icon-theme-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatappstream-data-0:7-20180614.el7*
Red Hat Enterprise Linux 7RedHatatk-0:2.28.1-1.el7*
Red Hat Enterprise Linux 7RedHatat-spi2-atk-0:2.26.2-1.el7*
Red Hat Enterprise Linux 7RedHatat-spi2-core-0:2.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatbaobab-0:3.28.0-2.el7*
Red Hat Enterprise Linux 7RedHatbolt-0:0.4-3.el7*
Red Hat Enterprise Linux 7RedHatbrasero-0:3.12.2-5.el7*
Red Hat Enterprise Linux 7RedHatcairo-0:1.15.12-3.el7*
Red Hat Enterprise Linux 7RedHatcheese-2:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatclutter-gst3-0:3.0.26-1.el7*
Red Hat Enterprise Linux 7RedHatcompat-exiv2-023-0:0.23-2.el7*
Red Hat Enterprise Linux 7RedHatcontrol-center-1:3.28.1-4.el7*
Red Hat Enterprise Linux 7RedHatdconf-0:0.28.0-4.el7*
Red Hat Enterprise Linux 7RedHatdconf-editor-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatdevhelp-1:3.28.1-1.el7*
Red Hat Enterprise Linux 7RedHatekiga-0:4.0.1-8.el7*
Red Hat Enterprise Linux 7RedHatempathy-0:3.12.13-1.el7*
Red Hat Enterprise Linux 7RedHateog-0:3.28.3-1.el7*
Red Hat Enterprise Linux 7RedHatevince-0:3.28.2-5.el7*
Red Hat Enterprise Linux 7RedHatevolution-0:3.28.5-2.el7*
Red Hat Enterprise Linux 7RedHatevolution-data-server-0:3.28.5-1.el7*
Red Hat Enterprise Linux 7RedHatevolution-ews-0:3.28.5-1.el7*
Red Hat Enterprise Linux 7RedHatevolution-mapi-0:3.28.3-2.el7*
Red Hat Enterprise Linux 7RedHatfile-roller-0:3.28.1-2.el7*
Red Hat Enterprise Linux 7RedHatflatpak-0:1.0.2-2.el7*
Red Hat Enterprise Linux 7RedHatfolks-1:0.11.4-1.el7*
Red Hat Enterprise Linux 7RedHatfontconfig-0:2.13.0-4.3.el7*
Red Hat Enterprise Linux 7RedHatfreetype-0:2.8-12.el7*
Red Hat Enterprise Linux 7RedHatfribidi-0:1.0.2-1.el7*
Red Hat Enterprise Linux 7RedHatfwupd-0:1.0.8-4.el7*
Red Hat Enterprise Linux 7RedHatfwupdate-0:12-5.el7*
Red Hat Enterprise Linux 7RedHatgcr-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatgdk-pixbuf2-0:2.36.12-3.el7*
Red Hat Enterprise Linux 7RedHatgdm-1:3.28.2-9.el7*
Red Hat Enterprise Linux 7RedHatgedit-2:3.28.1-1.el7*
Red Hat Enterprise Linux 7RedHatgedit-plugins-0:3.28.1-1.el7*
Red Hat Enterprise Linux 7RedHatgeoclue2-0:2.4.8-1.el7*
Red Hat Enterprise Linux 7RedHatgeocode-glib-0:3.26.0-2.el7*
Red Hat Enterprise Linux 7RedHatgjs-0:1.52.3-1.el7*
Red Hat Enterprise Linux 7RedHatglade-0:3.22.1-1.el7*
Red Hat Enterprise Linux 7RedHatglib2-0:2.56.1-2.el7*
Red Hat Enterprise Linux 7RedHatglibmm24-0:2.56.0-1.el7*
Red Hat Enterprise Linux 7RedHatglib-networking-0:2.56.1-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-backgrounds-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-bluetooth-1:3.28.2-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-boxes-0:3.28.5-2.el7*
Red Hat Enterprise Linux 7RedHatgnome-calculator-0:3.28.2-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-clocks-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-color-manager-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-contacts-0:3.28.2-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-desktop3-0:3.28.2-2.el7*
Red Hat Enterprise Linux 7RedHatgnome-devel-docs-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-dictionary-0:3.26.1-2.el7*
Red Hat Enterprise Linux 7RedHatgnome-disk-utility-0:3.28.3-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-documents-0:3.28.2-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-font-viewer-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-getting-started-docs-0:3.28.2-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-initial-setup-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-keyring-0:3.28.2-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-online-accounts-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-online-miners-0:3.26.0-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-packagekit-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-screenshot-0:3.26.0-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-session-0:3.28.1-5.el7*
Red Hat Enterprise Linux 7RedHatgnome-settings-daemon-0:3.28.1-2.el7*
Red Hat Enterprise Linux 7RedHatgnome-shell-0:3.28.3-6.el7*
Red Hat Enterprise Linux 7RedHatgnome-shell-extensions-0:3.28.1-5.el7*
Red Hat Enterprise Linux 7RedHatgnome-software-0:3.28.2-3.el7*
Red Hat Enterprise Linux 7RedHatgnome-system-monitor-0:3.28.2-1.el7*
Red Hat Enterprise Linux 7RedHatgnome-terminal-0:3.28.2-2.el7*
Red Hat Enterprise Linux 7RedHatgnome-themes-standard-0:3.28-2.el7*
Red Hat Enterprise Linux 7RedHatgnome-tweak-tool-0:3.28.1-2.el7*
Red Hat Enterprise Linux 7RedHatgnome-user-docs-0:3.28.2-1.el7*
Red Hat Enterprise Linux 7RedHatgnote-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatgobject-introspection-0:1.56.1-1.el7*
Red Hat Enterprise Linux 7RedHatgom-0:0.3.3-1.el7*
Red Hat Enterprise Linux 7RedHatgoogle-noto-emoji-fonts-0:20180508-4.el7*
Red Hat Enterprise Linux 7RedHatgrilo-0:0.3.6-1.el7*
Red Hat Enterprise Linux 7RedHatgrilo-plugins-0:0.3.7-1.el7*
Red Hat Enterprise Linux 7RedHatgsettings-desktop-schemas-0:3.28.0-2.el7*
Red Hat Enterprise Linux 7RedHatgspell-0:1.6.1-1.el7*
Red Hat Enterprise Linux 7RedHatgssdp-0:1.0.2-1.el7*
Red Hat Enterprise Linux 7RedHatgstreamer1-plugins-base-0:1.10.4-2.el7*
Red Hat Enterprise Linux 7RedHatgtk3-0:3.22.30-3.el7*
Red Hat Enterprise Linux 7RedHatgtk-doc-0:1.28-2.el7*
Red Hat Enterprise Linux 7RedHatgtksourceview3-0:3.24.8-1.el7*
Red Hat Enterprise Linux 7RedHatgucharmap-0:10.0.4-1.el7*
Red Hat Enterprise Linux 7RedHatgupnp-0:1.0.2-5.el7*
Red Hat Enterprise Linux 7RedHatgupnp-igd-0:0.2.5-2.el7*
Red Hat Enterprise Linux 7RedHatgvfs-0:1.36.2-1.el7*
Red Hat Enterprise Linux 7RedHatharfbuzz-0:1.7.5-2.el7*
Red Hat Enterprise Linux 7RedHatjson-glib-0:1.4.2-2.el7*
Red Hat Enterprise Linux 7RedHatlibappstream-glib-0:0.7.8-2.el7*
Red Hat Enterprise Linux 7RedHatlibchamplain-0:0.12.16-2.el7*
Red Hat Enterprise Linux 7RedHatlibcroco-0:0.6.12-4.el7*
Red Hat Enterprise Linux 7RedHatlibgdata-0:0.17.9-1.el7*
Red Hat Enterprise Linux 7RedHatlibgee-0:0.20.1-1.el7*
Red Hat Enterprise Linux 7RedHatlibgepub-0:0.6.0-1.el7*
Red Hat Enterprise Linux 7RedHatlibgexiv2-0:0.10.8-1.el7*
Red Hat Enterprise Linux 7RedHatlibgnomekbd-0:3.26.0-1.el7*
Red Hat Enterprise Linux 7RedHatlibgovirt-0:0.3.4-1.el7*
Red Hat Enterprise Linux 7RedHatlibgtop2-0:2.38.0-3.el7*
Red Hat Enterprise Linux 7RedHatlibgweather-0:3.28.2-2.el7*
Red Hat Enterprise Linux 7RedHatlibgxps-0:0.3.0-4.el7*
Red Hat Enterprise Linux 7RedHatlibical-0:3.0.3-2.el7*
Red Hat Enterprise Linux 7RedHatlibjpeg-turbo-0:1.2.90-6.el7*
Red Hat Enterprise Linux 7RedHatlibmediaart-0:1.9.4-1.el7*
Red Hat Enterprise Linux 7RedHatlibosinfo-0:1.1.0-2.el7*
Red Hat Enterprise Linux 7RedHatlibpeas-0:1.22.0-1.el7*
Red Hat Enterprise Linux 7RedHatlibrsvg2-0:2.40.20-1.el7*
Red Hat Enterprise Linux 7RedHatlibsecret-0:0.18.6-1.el7*
Red Hat Enterprise Linux 7RedHatlibsoup-0:2.62.2-2.el7*
Red Hat Enterprise Linux 7RedHatlibwnck3-0:3.24.1-2.el7*
Red Hat Enterprise Linux 7RedHatmozjs52-0:52.9.0-1.el7*
Red Hat Enterprise Linux 7RedHatmutter-0:3.28.3-4.el7*
Red Hat Enterprise Linux 7RedHatnautilus-0:3.26.3.1-2.el7*
Red Hat Enterprise Linux 7RedHatnautilus-sendto-1:3.8.6-1.el7*
Red Hat Enterprise Linux 7RedHatopenchange-0:2.3-3.el7*
Red Hat Enterprise Linux 7RedHatosinfo-db-0:20180531-1.el7*
Red Hat Enterprise Linux 7RedHatPackageKit-0:1.1.10-1.el7*
Red Hat Enterprise Linux 7RedHatpango-0:1.42.4-1.el7*
Red Hat Enterprise Linux 7RedHatpoppler-0:0.26.5-20.el7*
Red Hat Enterprise Linux 7RedHatpyatspi-0:2.26.0-3.el7*
Red Hat Enterprise Linux 7RedHatredhat-logos-0:70.0.3-7.el7*
Red Hat Enterprise Linux 7RedHatrest-0:0.8.1-2.el7*
Red Hat Enterprise Linux 7RedHatrhythmbox-0:3.4.2-2.el7*
Red Hat Enterprise Linux 7RedHatseahorse-nautilus-0:3.11.92-11.el7*
Red Hat Enterprise Linux 7RedHatshotwell-0:0.28.4-1.el7*
Red Hat Enterprise Linux 7RedHatsushi-0:3.28.3-1.el7*
Red Hat Enterprise Linux 7RedHattotem-1:3.26.2-1.el7*
Red Hat Enterprise Linux 7RedHattotem-pl-parser-0:3.26.1-1.el7*
Red Hat Enterprise Linux 7RedHatupower-0:0.99.7-1.el7*
Red Hat Enterprise Linux 7RedHatvala-0:0.40.8-1.el7*
Red Hat Enterprise Linux 7RedHatvino-0:3.22.0-7.el7*
Red Hat Enterprise Linux 7RedHatvte291-0:0.52.2-2.el7*
Red Hat Enterprise Linux 7RedHatwayland-0:1.15.0-1.el7*
Red Hat Enterprise Linux 7RedHatwayland-protocols-0:1.14-1.el7*
Red Hat Enterprise Linux 7RedHatwebkitgtk4-0:2.20.5-1.el7*
Red Hat Enterprise Linux 7RedHatxdg-desktop-portal-0:1.0.2-1.el7*
Red Hat Enterprise Linux 7RedHatxdg-desktop-portal-gtk-0:1.0.2-1.el7*
Red Hat Enterprise Linux 7RedHatyelp-2:3.28.1-1.el7*
Red Hat Enterprise Linux 7RedHatyelp-tools-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatyelp-xsl-0:3.28.0-1.el7*
Red Hat Enterprise Linux 7RedHatzenity-0:3.28.1-1.el7*
AccountsserviceUbuntuartful*
AccountsserviceUbuntubionic*
AccountsserviceUbuntucosmic*
AccountsserviceUbuntudisco*
AccountsserviceUbuntuesm-infra-legacy/trusty*
AccountsserviceUbuntuesm-infra/bionic*
AccountsserviceUbuntuesm-infra/xenial*
AccountsserviceUbuntutrusty*
AccountsserviceUbuntutrusty/esm*
AccountsserviceUbuntuupstream*
AccountsserviceUbuntuxenial*

Extended Description

Many file operations are intended to take place within a restricted directory. By using special elements such as “..” and “/” separators, attackers can escape outside of the restricted location to access files or directories that are elsewhere on the system. One of the most common special elements is the “../” sequence, which in most modern operating systems is interpreted as the parent directory of the current location. This is referred to as relative path traversal. Path traversal also covers the use of absolute pathnames such as “/usr/local/bin” to access unexpected files. This is referred to as absolute path traversal.

Potential Mitigations

  • Assume all input is malicious. Use an “accept known good” input validation strategy, i.e., use a list of acceptable inputs that strictly conform to specifications. Reject any input that does not strictly conform to specifications, or transform it into something that does.

  • When performing input validation, consider all potentially relevant properties, including length, type of input, the full range of acceptable values, missing or extra inputs, syntax, consistency across related fields, and conformance to business rules. As an example of business rule logic, “boat” may be syntactically valid because it only contains alphanumeric characters, but it is not valid if the input is only expected to contain colors such as “red” or “blue.”

  • Do not rely exclusively on looking for malicious or malformed inputs. This is likely to miss at least one undesirable input, especially if the code’s environment changes. This can give attackers enough room to bypass the intended validation. However, denylists can be useful for detecting potential attacks or determining which inputs are so malformed that they should be rejected outright.

  • When validating filenames, use stringent allowlists that limit the character set to be used. If feasible, only allow a single “.” character in the filename to avoid weaknesses such as CWE-23, and exclude directory separators such as “/” to avoid CWE-36. Use a list of allowable file extensions, which will help to avoid CWE-434.

  • Do not rely exclusively on a filtering mechanism that removes potentially dangerous characters. This is equivalent to a denylist, which may be incomplete (CWE-184). For example, filtering “/” is insufficient protection if the filesystem also supports the use of “" as a directory separator. Another possible error could occur when the filtering is applied in a way that still produces dangerous data (CWE-182). For example, if “../” sequences are removed from the “…/…//” string in a sequential fashion, two instances of “../” would be removed from the original string, but the remaining characters would still form the “../” string.

  • Inputs should be decoded and canonicalized to the application’s current internal representation before being validated (CWE-180). Make sure that the application does not decode the same input twice (CWE-174). Such errors could be used to bypass allowlist validation schemes by introducing dangerous inputs after they have been checked.

  • Use a built-in path canonicalization function (such as realpath() in C) that produces the canonical version of the pathname, which effectively removes “..” sequences and symbolic links (CWE-23, CWE-59). This includes:

  • When the set of acceptable objects, such as filenames or URLs, is limited or known, create a mapping from a set of fixed input values (such as numeric IDs) to the actual filenames or URLs, and reject all other inputs.

  • For example, ID 1 could map to “inbox.txt” and ID 2 could map to “profile.txt”. Features such as the ESAPI AccessReferenceMap [REF-185] provide this capability.

  • Run the code in a “jail” or similar sandbox environment that enforces strict boundaries between the process and the operating system. This may effectively restrict which files can be accessed in a particular directory or which commands can be executed by the software.

  • OS-level examples include the Unix chroot jail, AppArmor, and SELinux. In general, managed code may provide some protection. For example, java.io.FilePermission in the Java SecurityManager allows the software to specify restrictions on file operations.

  • This may not be a feasible solution, and it only limits the impact to the operating system; the rest of the application may still be subject to compromise.

  • Be careful to avoid CWE-243 and other weaknesses related to jails.

  • Store library, include, and utility files outside of the web document root, if possible. Otherwise, store them in a separate directory and use the web server’s access control capabilities to prevent attackers from directly requesting them. One common practice is to define a fixed constant in each calling program, then check for the existence of the constant in the library/include file; if the constant does not exist, then the file was directly requested, and it can exit immediately.

  • This significantly reduces the chance of an attacker being able to bypass any protection mechanisms that are in the base program but not in the include files. It will also reduce the attack surface.

  • Ensure that error messages only contain minimal details that are useful to the intended audience and no one else. The messages need to strike the balance between being too cryptic (which can confuse users) or being too detailed (which may reveal more than intended). The messages should not reveal the methods that were used to determine the error. Attackers can use detailed information to refine or optimize their original attack, thereby increasing their chances of success.

  • If errors must be captured in some detail, record them in log messages, but consider what could occur if the log messages can be viewed by attackers. Highly sensitive information such as passwords should never be saved to log files.

  • Avoid inconsistent messaging that might accidentally tip off an attacker about internal state, such as whether a user account exists or not.

  • In the context of path traversal, error messages which disclose path information can help attackers craft the appropriate attack strings to move through the file system hierarchy.

References