Skip to content
Memory corruption Write-up Advanced

Heap Overflow in Floating Point Parsing (CVE-2013-4164)

Ruby's floating point parsing code contained a heap overflow that a specially crafted string could trigger whenever a string was converted to a float. This could cause a denial of service through segmentation faults and possibly allow arbitrary code execution.

ruby-lang.org

Published on ruby-lang.org

There is an overflow in floating point number parsing in Ruby. This vulnerability has been assigned the CVE identifier CVE-2013-4164.

The author, on ruby-lang.org

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a bounds error in the floating point string parser that writes beyond the allocated heap buffer when handling crafted input.

Impact

An attacker could cause a denial of service via segmentation faults and possibly achieve arbitrary code execution, though the text only says 'possibly'.

What the attacker needed

Application parses untrusted input as floats; attacker supplies a crafted string

The fix

It was fixed by upgrading to Ruby 1.9.3 patchlevel 484, Ruby 2.0.0 patchlevel 353 or Ruby 2.1.0 preview2.

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 write-up has not been written yet. The Original tab links to the source.

When a program turns text into a decimal number, it uses a parser. In some Ruby versions that parser could write past the end of a memory buffer, which crashes the program and might let an attacker run their own code. Any app that parses numbers from untrusted input, such as JSON, was at risk.

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.

Similar reports

View all

Same bug class and techniques, clearest first.

Memory corruption

The lesson behind this report.

Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.