Heap Overflow in Floating Point Parsing (CVE-2013-4164)
Posted by tenderlove on 22 Nov 2013
There is an overflow in floating point number parsing in Ruby. This vulnerability has been assigned the CVE identifier CVE-2013-4164.
Details
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 after Ruby 1.8.6 patchlevel 230
- 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.
Credits
Thanks to Charlie Somerville for reporting this issue!
History
- Originally published at 2013-11-22 04:00:00 UTC
- Secondary published at 2013-11-22 06:46:00 UTC
- Thirdly published at 2013-11-22 22:46:00 UTC
- Fourthly published at 2013-12-10 12:09:38 UTC
Recent News
Ruby 4.0.0 Released
We are pleased to announce the release of Ruby 4.0.0. Ruby 4.0 introduces “Ruby Box” and “ZJIT”, and adds many improvements.
Posted by naruse on 25 Dec 2025
A New Look for Ruby's Documentation
Following the ruby-lang.org redesign, we have more news to celebrate Ruby’s 30th anniversary: docs.ruby-lang.org has a completely new look with Aliki—RDoc’s new default theme.
Posted by Stan Lo on 23 Dec 2025
Redesign our Site Identity
We are excited to announce a comprehensive redesign of our site. The design for this update was created by Taeko Akatsuka.
Posted by Hiroshi SHIBATA on 22 Dec 2025
Ruby 4.0.0 preview3 Released
We are pleased to announce the release of Ruby 4.0.0-preview3. Ruby 4.0 introduces Ruby::Box and “ZJIT”, and adds many improvements.
Posted by naruse on 18 Dec 2025