CVE-2008-2663 - Integer Overflow or Wraparound

Severity

99%

Complexity

99%

Confidentiality

165%

Multiple integer overflows in the rb_ary_store function in Ruby 1.8.4 and earlier, 1.8.5 before 1.8.5-p231, 1.8.6 before 1.8.6-p230, and 1.8.7 before 1.8.7-p22 allow context-dependent attackers to execute arbitrary code or cause a denial of service via unknown vectors, a different issue than CVE-2008-2662, CVE-2008-2664, and CVE-2008-2725. NOTE: as of 20080624, there has been inconsistent usage of multiple CVE identifiers related to Ruby. The CVE description should be regarded as authoritative, although it is likely to change.

Multiple integer overflows in the rb_ary_store function in Ruby 1.8.4 and earlier, 1.8.5 before 1.8.5-p231, 1.8.6 before 1.8.6-p230, and 1.8.7 before 1.8.7-p22 allow context-dependent attackers to execute arbitrary code or cause a denial of service via unknown vectors, a different issue than CVE-2008-2662, CVE-2008-2664, and CVE-2008-2725. NOTE: as of 20080624, there has been inconsistent usage of multiple CVE identifiers related to Ruby. The CVE description should be regarded as authoritative, although it is likely to change.

CVSS 2.0 Base Score 9.9. CVSS Attack Vector: network. CVSS Attack Complexity: low. CVSS Vector: (AV:N/AC:L/Au:N/C:C/I:C/A:C).

Demo Examples

Integer Overflow or Wraparound

CWE-190

The following image processing code allocates a table for images.


               
...

This code intends to allocate a table of size num_imgs, however as num_imgs grows large, the calculation determining the size of the list will eventually overflow (CWE-190). This will result in a very small list to be allocated instead. If the subsequent code operates on the list as if it were num_imgs long, it may result in many types of out-of-bounds problems (CWE-119).

Integer Overflow or Wraparound

CWE-190

The following code excerpt from OpenSSH 3.3 demonstrates a classic case of integer overflow:


               
}
for (i = 0; i < nresp; i++) response[i] = packet_get_string(NULL);

If nresp has the value 1073741824 and sizeof(char*) has its typical value of 4, then the result of the operation nresp*sizeof(char*) overflows, and the argument to xmalloc() will be 0. Most malloc() implementations will happily allocate a 0-byte buffer, causing the subsequent loop iterations to overflow the heap buffer response.

Integer Overflow or Wraparound

CWE-190

Integer overflows can be complicated and difficult to detect. The following example is an attempt to show how an integer overflow may lead to undefined looping behavior:


               
}
bytesRec += getFromInput(buf+bytesRec);

In the above case, it is entirely possible that bytesRec may overflow, continuously creating a lower number than MAXGET and also overwriting the first MAXGET-1 bytes of buf.

Integer Overflow or Wraparound

CWE-190

In this example the method determineFirstQuarterRevenue is used to determine the first quarter revenue for an accounting/business application. The method retrieves the monthly sales totals for the first three months of the year, calculates the first quarter sales totals from the monthly sales totals, calculates the first quarter revenue based on the first quarter sales, and finally saves the first quarter revenue results to the database.


               
}
return 0;// Variable for sales revenue for the quarter// Calculate quarterly total// Calculate the total revenue for the quarter

However, in this example the primitive type short int is used for both the monthly and the quarterly sales variables. In C the short int primitive type has a maximum value of 32768. This creates a potential integer overflow if the value for the three monthly sales adds up to more than the maximum value for the short int primitive type. An integer overflow can lead to data corruption, unexpected behavior, infinite loops and system crashes. To correct the situation the appropriate primitive type should be used, as in the example below, and/or provide some validation mechanism to ensure that the maximum value for the primitive type is not exceeded.


               
}
...// Calculate quarterly total// Calculate the total revenue for the quarter

Note that an integer overflow could also occur if the quarterSold variable has a primitive type long but the method calculateRevenueForQuarter has a parameter of type short.

Overview

First reported 16 years ago

2008-06-24 19:41:00

Last updated 6 years ago

2018-11-01 15:06:00

Affected Software

Ruby-lang Ruby

Debian GNU/Linux 4.0

4.0

Canonical Ubuntu Linux 6.06 LTS (Long-Term Support)

6.06

Canonical Ubuntu Linux 7.04

7.04

Canonical Ubuntu Linux 7.10

7.10

Canonical Ubuntu Linux 8.04 LTS (Long-Term Support)

8.04

References

http://blog.phusion.nl/2008/06/23/ruby-186-p230187-broke-your-app-ruby-enterprise-edition-to-the-rescue/

Third Party Advisory

APPLE-SA-2008-06-30

Mailing List, Third Party Advisory

SUSE-SR:2008:017

Third Party Advisory

30802

Third Party Advisory

30831

Third Party Advisory

30867

Third Party Advisory

30875

Third Party Advisory

30894

Third Party Advisory

31062

Third Party Advisory

31090

Third Party Advisory

31181

Third Party Advisory

31256

Third Party Advisory

31687

Third Party Advisory

33178

Third Party Advisory

GLSA-200812-17

Third Party Advisory

SSA:2008-179-01

Mailing List, Third Party Advisory

http://support.apple.com/kb/HT2163

Third Party Advisory

http://weblog.rubyonrails.org/2008/6/21/multiple-ruby-security-vulnerabilities

Third Party Advisory

http://wiki.rpath.com/wiki/Advisories:rPSA-2008-0206

Broken Link

DSA-1612

Third Party Advisory

DSA-1618

Third Party Advisory

MDVSA-2008:140

Third Party Advisory

MDVSA-2008:141

Third Party Advisory

MDVSA-2008:142

Third Party Advisory

http://www.matasano.com/log/1070/updates-on-drew-yaos-terrible-ruby-vulnerabilities/

Third Party Advisory

RHSA-2008:0561

Third Party Advisory

http://www.ruby-forum.com/topic/157034

Third Party Advisory

http://www.rubyinside.com/june-2008-ruby-security-vulnerabilities-927.html

Third Party Advisory

http://www.ruby-lang.org/en/news/2008/06/20/arbitrary-code-execution-vulnerabilities/

Patch, Vendor Advisory

20080626 rPSA-2008-0206-1 ruby

Third Party Advisory, VDB Entry

29903

Third Party Advisory, VDB Entry

1020347

Third Party Advisory, VDB Entry

USN-621-1

Third Party Advisory

ADV-2008-1907

Third Party Advisory

ADV-2008-1981

Third Party Advisory

http://www.zedshaw.com/rants/the_big_ruby_vulnerabilities.html

Broken Link

ruby-rbarystore-code-execution(43346)

Third Party Advisory, VDB Entry

https://issues.rpath.com/browse/RPL-2626

Broken Link

oval:org.mitre.oval:def:10524

Third Party Advisory

FEDORA-2008-5649

Third Party Advisory

Stay updated

ExploitPedia is constantly evolving. Sign up to receive a notification when we release additional functionality.

Get in touch

If you'd like to report a bug or have any suggestions for improvements then please do get in touch with us using this form. We will get back to you as soon as we can.