exploit the possibilities
Home Files News &[SERVICES_TAB]About Contact Add New

Ruby On Rails JSON Processor YAML Deserialization Scanner

Ruby On Rails JSON Processor YAML Deserialization Scanner
Posted Sep 1, 2024
Authored by H D Moore, jjarmoc | Site metasploit.com

This Metasploit module attempts to identify Ruby on Rails instances vulnerable to an arbitrary object instantiation flaw in the JSON request processor.

tags | exploit, arbitrary, ruby
advisories | CVE-2013-0333
SHA-256 | 170aaef589710c91521601000cb3b478c0e13d9f21b9c95db63d18f83815c46d

Ruby On Rails JSON Processor YAML Deserialization Scanner

Change Mirror Download
##
# This module requires Metasploit: https://metasploit.com/download
# Current source: https://github.com/rapid7/metasploit-framework
##

class MetasploitModule < Msf::Auxiliary
include Msf::Exploit::Remote::HttpClient
include Msf::Auxiliary::Scanner

def initialize(info={})
super(update_info(info,
'Name' => 'Ruby on Rails JSON Processor YAML Deserialization Scanner',
'Description' => %q{
This module attempts to identify Ruby on Rails instances vulnerable to
an arbitrary object instantiation flaw in the JSON request processor.
},
'Author' =>
[
'jjarmoc', # scanner module
'hdm' # CVE-2013-0156 scanner, basis of this technique.
],
'License' => MSF_LICENSE,
'References' =>
[
['CVE', '2013-0333']
]
))

register_options([
OptString.new('TARGETURI', [true, "The URI to test", "/"]),
OptEnum.new('HTTP_METHOD', [true, 'HTTP Method', 'POST', ['GET', 'POST', 'PUT']]),
])
end

def send_probe(pdata)
res = send_request_cgi({
'uri' => normalize_uri(datastore['TARGETURI']),
'method' => datastore['HTTP_METHOD'],
'ctype' => 'application/json',
'data' => pdata
})
end

def run_host(ip)

# Straight JSON as a baseline
res1 = send_probe(
"{ \"#{Rex::Text.rand_text_alpha(rand(8)+1)}\" : \"#{Rex::Text.rand_text_alpha(rand(8)+1)}\" }"
)

unless res1
vprint_status("#{rhost}:#{rport} No reply to the initial JSON request")
return
end

if res1.code.to_s =~ /^[5]/
vprint_error("#{rhost}:#{rport} The server replied with #{res1.code} for our initial JSON request, double check TARGETURI and HTTP_METHOD")
return
end

# Deserialize a hash, this should work if YAML deserializes.
res2 = send_probe("--- {}\n".gsub(':', '\u003a'))

unless res2
vprint_status("#{rhost}:#{rport} No reply to the initial YAML probe")
return
end

# Deserialize a malformed object, inducing an error.
res3 = send_probe("--- !ruby/object:\x00".gsub(':', '\u003a'))

unless res3
vprint_status("#{rhost}:#{rport} No reply to the second YAML probe")
return
end

vprint_status("Probe response codes: #{res1.code} / #{res2.code} / #{res3.code}")

if (res2.code == res1.code) and (res3.code != res2.code) and (res3.code != 200)
# If first and second requests are the same, and the third is different but not a 200, we're vulnerable.
print_good("#{rhost}:#{rport} is likely vulnerable due to a #{res3.code} reply for invalid YAML")
report_vuln({
:host => rhost,
:port => rport,
:proto => 'tcp',
:name => self.name,
:info => "Module triggered a #{res3.code} reply",
:refs => self.references
})
else
# Otherwise we're not likely vulnerable.
vprint_status("#{rhost}:#{rport} is not likely to be vulnerable or TARGETURI & HTTP_METHOD must be set")
end
end
end
Login or Register to add favorites

File Archive:

October 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Oct 1st
    39 Files
  • 2
    Oct 2nd
    23 Files
  • 3
    Oct 3rd
    18 Files
  • 4
    Oct 4th
    0 Files
  • 5
    Oct 5th
    0 Files
  • 6
    Oct 6th
    0 Files
  • 7
    Oct 7th
    0 Files
  • 8
    Oct 8th
    0 Files
  • 9
    Oct 9th
    0 Files
  • 10
    Oct 10th
    0 Files
  • 11
    Oct 11th
    0 Files
  • 12
    Oct 12th
    0 Files
  • 13
    Oct 13th
    0 Files
  • 14
    Oct 14th
    0 Files
  • 15
    Oct 15th
    0 Files
  • 16
    Oct 16th
    0 Files
  • 17
    Oct 17th
    0 Files
  • 18
    Oct 18th
    0 Files
  • 19
    Oct 19th
    0 Files
  • 20
    Oct 20th
    0 Files
  • 21
    Oct 21st
    0 Files
  • 22
    Oct 22nd
    0 Files
  • 23
    Oct 23rd
    0 Files
  • 24
    Oct 24th
    0 Files
  • 25
    Oct 25th
    0 Files
  • 26
    Oct 26th
    0 Files
  • 27
    Oct 27th
    0 Files
  • 28
    Oct 28th
    0 Files
  • 29
    Oct 29th
    0 Files
  • 30
    Oct 30th
    0 Files
  • 31
    Oct 31st
    0 Files

Top Authors In Last 30 Days

File Tags

Systems

packet storm

© 2024 Packet Storm. All rights reserved.

Services
Security Services
Hosting By
Rokasec
close