CVE-2009-0689 - Improper Restriction of Operations within the Bounds of a Memory Buffer

Severity

68%

Complexity

86%

Confidentiality

106%

Array index error in the (1) dtoa implementation in dtoa.c (aka pdtoa.c) and the (2) gdtoa (aka new dtoa) implementation in gdtoa/misc.c in libc, as used in multiple operating systems and products including in FreeBSD 6.4 and 7.2, NetBSD 5.0, OpenBSD 4.5, Mozilla Firefox 3.0.x before 3.0.15 and 3.5.x before 3.5.4, K-Meleon 1.5.3, SeaMonkey 1.1.8, and other products, allows context-dependent attackers to cause a denial of service (application crash) and possibly execute arbitrary code via a large precision value in the format argument to a printf function, which triggers incorrect memory allocation and a heap-based buffer overflow during conversion to a floating-point number.

Array index error in the (1) dtoa implementation in dtoa.c (aka pdtoa.c) and the (2) gdtoa (aka new dtoa) implementation in gdtoa/misc.c in libc, as used in multiple operating systems and products including in FreeBSD 6.4 and 7.2, NetBSD 5.0, OpenBSD 4.5, Mozilla Firefox 3.0.x before 3.0.15 and 3.5.x before 3.5.4, K-Meleon 1.5.3, SeaMonkey 1.1.8, and other products, allows context-dependent attackers to cause a denial of service (application crash) and possibly execute arbitrary code via a large precision value in the format argument to a printf function, which triggers incorrect memory allocation and a heap-based buffer overflow during conversion to a floating-point number.

CVSS 2.0 Base Score 6.8. CVSS Attack Vector: network. CVSS Attack Complexity: medium. CVSS Vector: (AV:N/AC:M/Au:N/C:P/I:P/A:P).

Demo Examples

Improper Restriction of Operations within the Bounds of a Memory Buffer

CWE-119

This example takes an IP address from a user, verifies that it is well formed and then looks up the hostname and copies it into a buffer.


               
}
strcpy(hostname, hp->h_name);/*routine that ensures user_supplied_addr is in the right format for conversion */

This function allocates a buffer of 64 bytes to store the hostname, however there is no guarantee that the hostname will not be larger than 64 bytes. If an attacker specifies an address which resolves to a very large hostname, then we may overwrite sensitive data or even relinquish control flow to the attacker.

Note that this example also contains an unchecked return value (CWE-252) that can lead to a NULL pointer dereference (CWE-476).

Improper Restriction of Operations within the Bounds of a Memory Buffer

CWE-119

This example applies an encoding procedure to an input string and stores it into a buffer.


               
}
return dst_buf;
die("user string too long, die evil hacker!");
else dst_buf[dst_index++] = user_supplied_string[i];
dst_buf[dst_index++] = ';';
/* encode to < */

The programmer attempts to encode the ampersand character in the user-controlled string, however the length of the string is validated before the encoding procedure is applied. Furthermore, the programmer assumes encoding expansion will only expand a given character by a factor of 4, while the encoding of the ampersand expands by 5. As a result, when the encoding procedure expands the string it is possible to overflow the destination buffer if the attacker provides a string of many ampersands.

Improper Restriction of Operations within the Bounds of a Memory Buffer

CWE-119

The following example asks a user for an offset into an array to select an item.


               
}
printf("You selected %s\n", items[index-1]);

The programmer allows the user to specify which element in the list to select, however an attacker can provide an out-of-bounds offset, resulting in a buffer over-read (CWE-126).

Improper Restriction of Operations within the Bounds of a Memory Buffer

CWE-119

In the following code, the method retrieves a value from an array at a specific array index location that is given as an input parameter to the method


               
}
return value;// check that the array index is less than the maximum// length of the array
value = array[index];// get the value at the specified index of the array
// if array index is invalid then output error message// and return value indicating error
value = -1;

However, this method only verifies that the given array index is less than the maximum length of the array but does not check for the minimum value (CWE-839). This will allow a negative value to be accepted as the input array index, which will result in a out of bounds read (CWE-125) and may allow access to sensitive memory. The input array index should be checked to verify that is within the maximum and minimum range required for the array (CWE-129). In this example the if statement should be modified to include a minimum range check, as shown below.


               
...// check that the array index is within the correct// range of values for the array

Improper Restriction of Operations within the Bounds of a Memory Buffer

CWE-119

Windows provides the _mbs family of functions to perform various operations on multibyte strings. When these functions are passed a malformed multibyte string, such as a string containing a valid leading byte followed by a single null byte, they can read or write past the end of the string buffer causing a buffer overflow. The following functions all pose a risk of buffer overflow: _mbsinc _mbsdec _mbsncat _mbsncpy _mbsnextc _mbsnset _mbsrev _mbsset _mbsstr _mbstok _mbccpy _mbslen

Overview

First reported 15 years ago

2009-07-01 13:00:00

Last updated 6 years ago

2018-11-02 10:29:00

Affected Software

Mozilla Firefox 3.0.1

3.0.1

Mozilla Firefox 3.0.2

3.0.2

Mozilla Firefox 3.0.3

3.0.3

Mozilla Firefox 3.0.4

3.0.4

Mozilla Firefox 3.0.5

3.0.5

Mozilla Firefox 3.0.6

3.0.6

Mozilla Firefox 3.0.7

3.0.7

Mozilla Firefox 3.0.8

3.0.8

Mozilla Firefox 3.0.9

3.0.9

Mozilla Firefox 3.0.10

3.0.10

Mozilla Firefox 3.0.11

3.0.11

Mozilla Firefox 3.0.12

3.0.12

Mozilla Firefox 3.0.13

3.0.13

Mozilla Firefox 3.0.14

3.0.14

Mozilla Firefox 3.5

3.5

Mozilla Firefox 3.5.1

3.5.1

Mozilla Firefox 3.5.2

3.5.2

Mozilla Firefox 3.5.3

3.5.3

Mozilla SeaMonkey 1.1.8

1.1.8

FreeBSD 6.4

6.4

FreeBSD 7.2

7.2

OpenBSD 4.5

4.5

References

http://cvsweb.netbsd.org/bsdweb.cgi/src/lib/libc/gdtoa/gdtoaimp.h

Patch

APPLE-SA-2010-03-29-1

Vendor Advisory

APPLE-SA-2010-06-21-1

SUSE-SR:2009:018

SUSE-SR:2010:013

RHSA-2014:0311

RHSA-2014:0312

37431

Vendor Advisory

37682

Vendor Advisory

37683

Vendor Advisory

38066

Vendor Advisory

38977

Vendor Advisory

39001

Vendor Advisory

http://secunia.com/secunia_research/2009-35/

Vendor Advisory

20090625 Multiple Vendors libc/gdtoa printf(3) Array Overrun

Exploit

20091030 Multiple BSD printf(1) and multiple dtoa/*printf(3) vulnerabilities

20091120 SeaMonkey 1.1.8 Remote Array Overrun (Arbitrary code execution)

20091120 K-Meleon 1.5.3 Remote Array Overrun (Arbitrary code execution)

20091120 Opera 10.01 Remote Array Overrun (Arbitrary code execution)

20091211 Flock 2.5.2 Remote Array Overrun (Arbitrary code execution)

20091211 Camino 1.6.10 Remote Array Overrun (Arbitrary code execution)

20091211 Sunbird 0.9 Array Overrun (code execution)

20091211 Thunderbird 2.0.0.23 (lib) Remote Array Overrun (Arbitrary code execution)

20100108 MacOS X 10.5/10.6 libc/strtod(3) buffer overflow

1022478

Patch

272909

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

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

MDVSA-2009:294

MDVSA-2009:330

http://www.mozilla.org/security/announce/2009/mfsa2009-59.html

Vendor Advisory

http://www.openbsd.org/cgi-bin/cvsweb/src/lib/libc/gdtoa/misc.c

Patch, Vendor Advisory

http://www.opera.com/support/kb/view/942/

RHSA-2009:1601

RHSA-2010:0153

RHSA-2010:0154

20091120 K-Meleon 1.5.3 Remote Array Overrun (Arbitrary code execution)

20091120 SeaMonkey 1.1.8 Remote Array Overrun (Arbitrary code execution)

20091210 Flock 2.5.2 Remote Array Overrun (Arbitrary code execution)

20091210 Camino 1.6.10 Remote Array Overrun (Arbitrary code execution)

35510

Exploit, Patch

USN-915-1

ADV-2009-3297

Vendor Advisory

ADV-2009-3299

Vendor Advisory

ADV-2009-3334

Vendor Advisory

ADV-2010-0094

Vendor Advisory

ADV-2010-0648

Vendor Advisory

ADV-2010-0650

Vendor Advisory

https://bugzilla.mozilla.org/show_bug.cgi?id=516396

https://bugzilla.mozilla.org/show_bug.cgi?id=516862

[debian-lts-announce] 20181101 [SECURITY] [DLA 1564-1] mono security update

oval:org.mitre.oval:def:6528

oval:org.mitre.oval:def:9541

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.