Ruby: Heap Overflow in Floating Point Parsing
A specially crafted string converted to a floating point value can cause a heap overflow in Ruby. This can lead to denial of service via segmentation faults and possibly arbitrary code execution.
- Fixed in under an hour
- Paid in 12 days
- Disclosed after under an hour
Any time a string is converted to a floating point value, a specially crafted string can cause a heap overflow. This can lead to a denial of service attack via segmentation faults and possibly arbitrary code execution. Any program that converts input of unknown origin to floating point values (especially common when accepting JSON) are vulnerable.
Vulnerable code looks something like this:
untrusted_data.to_f
But any code that produces floating point values from external data is vulnerable, such as this:
JSON.parse untrusted_data
Note that this bug is similar to CVE-2009-0689.
All users running an affected release should upgrade to the FIXED versions of Ruby.
#Affected versions
- All Ruby 1.8 versions
- All Ruby 1.9 versions prior to Ruby 1.9.3 patchlevel 484
- All Ruby 2.0 versions prior to Ruby 2.0.0 patchlevel 353
- All Ruby 2.1 versions prior to Ruby 2.1.0 preview2
- prior to trunk revision 43780
#Solutions All users are recommended to upgrade to Ruby 1.9.3 patchlevel 484, Ruby 2.0.0 patchlevel 353 or Ruby 2.1.0 preview2.
Please note that Ruby 1.8 series or any earlier releases are already obsoleted. There is no plan to release new FIXED versions for them. Users of such versions are advised to upgrade as soon as possible as we cannot guarantee the continued availability of security fixes for unsupported releases.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Impact
This could cause a denial of service through segmentation faults and possibly allow arbitrary code execution.
What the attacker needed
Program converts untrusted input to float
The fix
Users should upgrade to the fixed Ruby versions listed in the advisory.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a program turns text into a decimal number, it uses memory to store that number. A bug in this conversion lets a malicious piece of text write past the intended memory area, which can crash the program or let an attacker run their own code.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.