Home / vulnerabilities advisory_132006.138.txt
Posted on 06 November 2006
Source : packetstormsecurity.org Link
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hardened-PHP Project
www.hardened-php.net
-= Security Advisory =-
Advisory: PHP HTML Entity Encoder Heap Overflow Vulnerability
Release Date: 2006/11/03
Last Modified: 2006/11/03
Author: Stefan Esser [sesser@hardened-php.net]
Application: PHP 5 <= 5.1.6, PHP 4 <= 4.4.4
Severity: Bufferoverflows in htmlentities() and
htmlspecialchars() may result in arbitrary
remote code execution
Risk: Critical
Vendor Status: Vendor has released PHP 5.2.0 which fixes this issue
References: http://www.hardened-php.net/advisory_132006.138.html
Overview:
Quote from http://www.php.net
"PHP is a widely-used general-purpose scripting language that
is especially suited for Web development and can be embedded
into HTML."
While we were searching for a hole in htmlspecialchars() and
htmlentities() to bypass the encoding of certain chars to exploit
a possible eval() injection hole in another application we
discovered that the implementation contains a possible
bufferoverflow that can be triggered when the UTF-8 charset
is selected.
Unfortunately the whole purpose of both functions is to prepare
userinput for HTML output. Therefore they are used in most PHP
applications as protection against XSS and are always exposed
to userinput.
By triggering the overflow it is possible to overwrite heap
management structures with a limited charset. This can result in
remote code execution. Exploitability has been proven against
for example Linux with glibc 2.3 in a test environment. It
depends on the heap layout, the OS heap implementation and the
used Zend Memory Manager.
Details:
The HTML entity encoder of PHP will increase the size of it's
output buffer every time it reaches the end of the current buffer.
Unfortunately the check assumes that the maximum length of an
HTML entity is 8 chars, which is true for most entities. However
especially the Greek character set contains entities that are
longer than 8 chars. Because of this it is for example possible
to trigger the overflow by embedding Greek theta UTF-8 characters
into the input string.
Because the longest HTML entity currently supported is 10 bytes
long this allows overflowing the buffer with the 2 bytes ';' and
'