Bug 1637761 (CVE-2018-14665) - CVE-2018-14665 xorg-x11-server: Incorrect permission check in Xorg X server allows for privilege escalation
Summary: CVE-2018-14665 xorg-x11-server: Incorrect permission check in Xorg X server a...
Keywords:
Status: CLOSED ERRATA
Alias: CVE-2018-14665
Product: Security Response
Classification: Other
Component: vulnerability
Version: unspecified
Hardware: All
OS: Linux
high
high
Target Milestone: ---
Assignee: Red Hat Product Security
QA Contact:
URL:
Whiteboard:
Depends On: 1639248 1639249 1643131 1643132
Blocks: 1637763
TreeView+ depends on / blocked
 
Reported: 2018-10-10 02:20 UTC by Sam Fowler
Modified: 2022-03-13 15:43 UTC (History)
28 users (show)

Fixed In Version: xorg-x11-server 1.20.3
Doc Type: If docs needed, set a value
Doc Text:
An incorrect permission check for -modulepath and -logfile options when starting Xorg X server allows unprivileged users with the ability to log in to the system via physical console to escalate their privileges and run arbitrary code under root privileges.
Clone Of:
Environment:
Last Closed: 2018-10-30 17:28:29 UTC
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2018:3410 0 None None None 2018-10-30 17:00:05 UTC

Description Sam Fowler 2018-10-10 02:20:52 UTC
The X.org X11 server has a vulnerability that allows local users to escalate to
full root privileges. The /usr/bin/Xorg setuid binary shipped in the
xorg-x11-server-Xorg package allows for arbitrary file creation with certain
parameters, allowing attackers with low privilege access to overwrite system
files and subsequently execute arbitrary code.

Comment 1 Sam Fowler 2018-10-11 04:44:11 UTC
Acknowledgments:

Name: Narendra Shinde

Comment 9 Tomas Hoger 2018-10-14 15:40:08 UTC
This flaw was introduced in the upstream xserver version 1.19.0 via the following commit:

https://gitlab.freedesktop.org/xorg/xserver/commit/032b1d79b7

Prior to that commit, X server command line options -logfile and -modulepath could only be used when X server is started by the root user.  The above commit changed checking of these options to use the same code that was previously used for -config and -configdir options, which additionally allows arguments that are relative paths.  However, accepting relative paths for -logfile and -modulepath is not safe.

As 1.19.0 is the first affected version, Red Hat Enterprise Linux 7 is only affected as of the erratum RHBA-2017:1905, which was released as part of Red Hat Enterprise Linux 7.4, which rebased xorg-x11-server component from version 1.17.2 to version 1.19.3.  The versions of xorg-x11-server as shipped with Red Hat Enterprise Linux 7.3 and earlier are not affected.  Therefore, for Red Hat Enterprise Linux 7.4 and later, this issue can be mitigated by downgrading to version 1.17.2.

The versions of xorg-x11-server as shipped with Red Hat Enterprise Linux 6 and earlier were never updated to version 1.19.0 or later, and hence are not affected by this issue.

Note that the default PAM configuration for the xserver in Red Hat Enterprise Linux only allows users with physical access to the console to start Xorg server.  This restriction prevents exploitation of this flaw over remote connections, such as over SSH connection.

Comment 10 Narendra 2018-10-14 15:55:34 UTC
About, 

> Note that the default PAM configuration for the xserver in Red Hat
> Enterprise Linux only allows users with physical access to the console
> to start Xorg server.  This >restriction prevents exploitation of this
> flaw over remote connections, such as over SSH connection.

In my testing environment, if user is logged into console, s/he can exploit this issue remotely using SSH too. Could you please check ? 


[Dev@localhost ~]$ uname -a
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Wed Mar 21 18:14:51 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux
[Dev@localhost ~]$ 
[Dev@localhost ~]$ cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.5 (Maipo)
[Dev@localhost ~]$ 
[Dev@localhost ~]$ 
[Dev@localhost ~]$ cd /etc
[Dev@localhost etc]$ 
[Dev@localhost etc]$ Xorg -logfile crafted :1

X.Org X Server 1.19.5
Release Date: 2017-10-12
X Protocol Version 11, Revision 0
Build Operating System:  2.6.32-696.18.7.el6.x86_64 
Current Operating System: Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Wed Mar 21 18:14:51 EDT 2018 x86_64
Kernel command line: BOOT_IMAGE=/vmlinuz-3.10.0-862.el7.x86_64 root=/dev/mapper/rhel-root ro crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet LANG=en_US.UTF-8
Build Date: 13 February 2018  02:39:52PM
Build ID: xorg-x11-server 1.19.5-5.el7 
Current version of pixman: 0.34.0
	Before reporting problems, check http://wiki.x.org
	to make sure that you have the latest version.
Markers: (--) probed, (**) from config file, (==) default setting,
	(++) from command line, (!!) notice, (II) informational,
	(WW) warning, (EE) error, (NI) not implemented, (??) unknown.
(++) Log file: "crafted", Time: Sun Oct 14 21:22:11 2018
(==) Using config directory: "/etc/X11/xorg.conf.d"
(==) Using system config directory "/usr/share/X11/xorg.conf.d"
^Cerror setting MTRR (base = 0x00000000e0000000, size = 0x01700000, type = 1) Invalid argument (22)
(II) Server terminated successfully (0). Closing log file.
[Dev@localhost etc]$ ^C
[Dev@localhost etc]$ ^C
[Dev@localhost etc]$ ls -la crafted 
-rw-r--r--. 1 root Dev 53902 Oct 14 21:22 crafted
[Dev@localhost etc]$ 
[Dev@localhost etc]$

Comment 11 Tomas Hoger 2018-10-14 21:08:46 UTC
(In reply to Narendra from comment #10)
> In my testing environment, if user is logged into console, s/he can exploit
> this issue remotely using SSH too. Could you please check ? 

Right, that's how pam_console works.  The point is that attacker needs an open console session to run Xorg, even though it may be associated with a different terminal.  If attacker does not have console access to the target system, this PAM configuration prevents them from running Xorg there.  Only having remote SSH access is not enough.

Comment 12 Narendra 2018-10-14 21:49:43 UTC
True. Thanks.

Comment 24 Adam Mariš 2018-10-25 14:34:21 UTC
External References:

https://lists.x.org/archives/xorg-announce/2018-October/002927.html

Comment 25 Adam Mariš 2018-10-25 14:35:48 UTC
Created xorg-x11-server tracking bugs for this issue:

Affects: fedora-all [bug 1643131]

Comment 27 Tomas Hoger 2018-10-26 06:55:53 UTC
Blog post from the original reporter:

https://www.securepatterns.com/2018/10/cve-2018-14665-xorg-x-server.html

Comment 30 Adam Mariš 2018-10-26 08:27:28 UTC
Statement:

This issue did not affect the versions of xorg-x11-server as shipped with Red Hat Enterprise Linux 5 and 6, as well as Red Hat Enterprise Linux 7 prior to 7.4, as they did not allow the use of vulnerable command line options when running with elevated privileges.

The default X server configuration in Red Hat Enterprise Linux only allows users logged in on the system's physical console to run Xorg X server. Therefore, users which only have remote access to the the system (for example using SSH) can not exploit this flaw.

Comment 31 errata-xmlrpc 2018-10-30 16:59:55 UTC
This issue has been addressed in the following products:

  Red Hat Enterprise Linux 7

Via RHSA-2018:3410 https://access.redhat.com/errata/RHSA-2018:3410

Comment 33 Tomas Hoger 2018-11-13 21:05:57 UTC
Another write up form the original reporter describing exploitation using the -modulepath option:

https://www.securepatterns.com/2018/10/cve-2018-14665-another-way-of.html


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