32780 : PHP substr_compare() Function Arbitrary Memory Disclosure
Printer | http://osvdb.org/32780 | Email This | Edit Vulnerability

Views This Week

5

Views All Time

314

Info

Last Modified

about 1 year ago

Percent Complete

100%

Disclosure

Mar 07, 2007

Discovery

Unknown

Dates

Exploit

Mar 07, 2007

Solution

Unknown

Description

An information leak vulnerability exists in PHP. An integer overflow which occurs while performing sanity checks on the input parameters to the substr_compare() function makes it possible to compare offsets outside of the allocated buffer. This allows memory access outside the buffer and the retrieval of sensitive information, leading to a loss of confidentiality.

Classification

Location: Remote / Network Access
Attack Type: Information Disclosure
Impact: Loss of Confidentiality
Exploit: Exploit Public
Disclosure: OSVDB Verified
OSVDB: Concern

Technical

substr_compare() performs two sanity checks on the input parameters:

Sanity Check #1 - ensures that a negative offset is considered relative to the end of the first input string
if (offset < 0) {
offset = s1_len + offset;
offset = (offset < 0) ? 0 : offset;
}

Sanity Check #2 - ensures that offset and requested length do not exceed the buffer length, but does not take into account that the addition of two positive signed variables can result in a negative value when an integer overflow occurs
if ((offset + len) > s1_len) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "The start position cannot exceed ...");
RETURN_FALSE;
}

Comparing an ASCIIZ char and a ASCII 01 char with an offset outside the buffer and comparing the return values of substr_compare() it is possible to determine ASCII value of the byte outside the buffer.

Solution

Upgrade to version 5.2.2 or higher, as it has been reported to fix this vulnerability. An upgrade is required as there are no known workarounds.

Products

The PHP Group
Watch-list
PHP
Watch-list
5.2.1
5.2.0
5.1.x
5.0.x
5.0 Release Candidate 3
5.0 Release Candidate 2
5.0 Beta 4
5.0 Beta 3
5.0 Beta 2
5.0 Beta 1
5.0 Release Candidate 1

References

Tools & Filters

24887 25100 26107 28053
3982

Credit

  • Stefan Esser - sesserhardened-php.net - www.hardened-php.net

CVSSv2 Score

CVSSv2 Base Score = 5.0
Source: nvd.nist.gov | Generated: 2007-03-12 | Disagree?

Access_vector_2 Access_complexity_2 Authentication_2 Confidentiality_impact_1 Integrity_impact_0 Availability_impact_0

Blogs

This section lists the latest news and blogs found via the daylife API (and for older items, the technorati API), which mention or otherwise discuss this vulnerability.

None found at this time

Comments

No Comments.

The database information may change without any notice. Use of the information constitutes acceptance for use in an AS IS condition, and there are NO warranties, implied or otherwise, with regard to this information or its use. Any use of this information is at the user's risk. In no event shall the copyright holder or distributor (OSVDB or OSF) be held liable for any damages whatsoever arising out of or in connection with the use or spread of this information.

© Copyright 2010 Open Source Vulnerability Database (OSVDB), All Rights Reserved.
Privacy Statement - Terms of Use