Hi PHP guys, already another vuln. No time to take some rest, sorry! 5.2 is not affected. Application: PHP 5 <= 5.1.6, PHP 4 <= 4.4.4 -----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 '\0'. When exploiting heap overflows it can be enough to just overwrite the appending memory structure with a single '\0' char and control the content of the following memory block to execute arbitrary code. While the above Greek character exploit is only possible in the htmlentities() function it is also possible to overwrite with up to 7 chars by embedding broken UTF-8 characters into the string. The characters may come from the limited charset 0x00, 0xc0-0xfd. On Linux glibc systems this is for example enough to trick realloc into believing that the next memory block is empty and long enough to store the additional 128 bytes. The position of the buffer is therefore not changed and following writes to the output buffer will overwrite the Zend Memory Manager structure of the following block. This allows the typical linked list unlink exploit against the Zend Memory Manager. Proof of Concept: The Hardened-PHP Project is not going to release a proof of concept exploit for this vulnerability. Disclosure Timeline: 31. October 2006 - Notified security@php.net, patch in CVS 01. November 2006 - Notified vendor-sec 03. November 2006 - PHP developers released PHP 5.2.0 03. November 2006 - Public Disclosure Recommendation: For PHP 4 users it is strongly recommended to patch their version of PHP with the following patch until php.net is providing PHP4 updates. http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.63.2.23.2.2&r2=1.63.2.23.2.3&view=patch As usual we very strongly recommend that you install Suhosin-Patch and the Suhosin Extension, because once again this advisory proved that remotely triggerable overflows in PHP still exist. It is therefore highly recommended by us to use Suhosin-Patch. It's canary protection will detect overflows and stop execution to make exploitation very hard or impossible. FreeBSD and OpenBSD's PHP ports already come with Suhosin-Patch activated by default. Grab your copy and more information at: http://www.hardened-php.net/suhosin/index.html CVE Information: The Common Vulnerabilities and Exposures project (cve.mitre.org) has assigned the name CVE-2006-5465 to this vulnerability. GPG-Key: http://www.hardened-php.net/hardened-php-signature-key.asc pub 1024D/0A864AA1 2004-04-17 Hardened-PHP Signature Key Key fingerprint = 066F A6D0 E57E 9936 9082 7E52 4439 14CC 0A86 4AA1 Copyright 2006 Stefan Esser. All rights reserved. -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (GNU/Linux) iD8DBQFFSnmgRDkUzAqGSqERAksrAJsHlMJD90XU9KtiFI6PpyLddaZ2wQCgpR++ VRAQBzFoGx5SJemSTgxKTaI= =6OY5 -----END PGP SIGNATURE-----
UTF8 character sed needs to be selected --> B1
*** Bug 153853 has been marked as a duplicate of this bug. ***
*** Bug 154083 has been marked as a duplicate of this bug. ***
php-bugs any news on this one?
will we ever get PHP 5.2 ebuild in portage???
I'm working on the security issue for 4.4 and 5.1. There won't be a 5.2.0 ebuild in Portage, I'll only consider adding PHP 5.2 to Portage when 5.2.1 is out, for now just get it from the PHP Overlay [1] if you really need it. Best regards, CHTEKK. [1] http://overlays.gentoo.org/proj/php/
Just wondering - does php 5.2 have some kind of a problem? Why wait until 5.2.1? (In reply to comment #6) > I'm working on the security issue for 4.4 and 5.1. > There won't be a 5.2.0 ebuild in Portage, I'll only consider adding PHP 5.2 to > Portage when 5.2.1 is out, for now just get it from the PHP Overlay [1] if you > really need it. > Best regards, CHTEKK. > > [1] http://overlays.gentoo.org/proj/php/ >
(In reply to comment #7) > Just wondering - does php 5.2 have some kind of a problem? Why wait until > 5.2.1? Lots of issues. Please, this is a security bug, not a discussion forum. Feel free to ask in #gentoo-php, not here.
PHP 5.2.1 fixes several vulnerabilities in the 5.x branch. It could be good if it was feasible to bump php-5.2.1. Could you have a look please?
http://www.php.net/releases/5_2_1.php and http://secunia.com/advisories/24089/
*** Bug 166683 has been marked as a duplicate of this bug. ***
Bug 166779 is somewhat related to this one as it effects 5.2.1
Can seem to find 5.2.x in the overlay.
*** Bug 166779 has been marked as a duplicate of this bug. ***
*** Bug 167028 has been marked as a duplicate of this bug. ***
Ok people it's finally all done! Lots of work and fixes went into this, finally we have the new releases, that bring us again up-to-date PHP and a whole lot of security fixes (all fixed in 4.4.6 and 5.2.1-r3, not all fixed in 5.1.6-r11, but that's needed stable too for backwards compatibility). Usual testing rules apply, ie. FEATURES="test" will work, remember to have all your dbs turned on if you want to test the db extensions too, and don't let failures stop you (unless they're reeeaallly many, like >20), a couple of failures are expected, and the results vary from system to system. If in doubt, just ping me via mail or IRC and tell me the test results. This time also a few extensions need stabling, pecl-zip fixes a few security-related issues in the newest version, suhosin is the successor to hardenedphp (which was dropped as it's unmaintained and known to be broken), and we need a stable pecl-filter for backwards compatibility of 5.1 with 5.2. Usual testing rules apply here too... Just emerge and see if it loads. ;) Here all the packages I'd like you to stabilize ASAP: PHP: dev-lang/php-4.4.6 dev-lang/php-5.1.6-r11 dev-lang/php-5.2.1-r3 Extensions: (security-related) dev-php4/suhosin-0.9.17 dev-php4/pecl-zip-1.8.6 dev-php5/suhosin-0.9.17 dev-php5/pecl-zip-1.8.6 Extensions: (needed for correct backwards compatibility of 5.1 to 5.2) dev-php5/pecl-filter-0.11.0 As usual, thanks a lot, love ya all! Best regards, CHTEKK.
AMD64 all done! Btw, please *REMEMBER* to update your eclass/ directory before doing any testing&keywording, thanks! Best regards, CHTEKK.
thank you very much, bro!
ppc64 stable
x86 stable
ppc stable
Stable for HPPA.
dev-lang/php-4.4.6 dev-lang/php-5.1.6-r11 dev-lang/php-5.2.1-r3 dev-php4/suhosin-0.9.17 dev-php4/pecl-zip-1.8.6 dev-php5/suhosin-0.9.17 dev-php5/pecl-zip-1.8.6 dev-php5/pecl-filter-0.11.0 sparc stable. also sent dev-php5/pecl-fileinfo-1.0.4 stable directly for php-5.2 (build issues). will do others as we find them out.
I've been working during the last two days in this bug for alpha. Unluckily, I found several failing tests in the three php versions. I'm currently reviewing the archives (aka #143126) to check which are save to ignore. I'll post the list in some hours. Thanks guys.
Here we go: these are the test I found on alpha and which don't appear in previous versions (check #143126 for details). PHP-4.6.6 -------------------------- - Bug #35239 (Objects can lose references) [tests/lang/bug35239.phpt] - Bug #24155 (gdImageRotate270 rotation problem). [ext/gd/tests/bug24155.phpt] - Bug #27582 (ImageFillToBorder() on alphablending image looses alpha on fill color) [ext/gd/tests/bug27582_1.phpt] - Bug #16069 [ext/iconv/tests/bug16069.phpt] COMMON PHP-5 -------------------------- - Test for buffering in core functions with implicit flush off [tests/func/008.phpt] - Bug #16069 [ext/iconv/tests/bug16069.phpt] - iconv stream filter [ext/iconv/tests/iconv_stream_filter.phpt] - HTML input/output [ext/mbstring/tests/htmlent.phpt] - mb_output_handler() (Shift_JIS) [ext/mbstring/tests/mb_output_handler_shift_jis.phpt] PHP 5.1 -------------------------- - Test for abstract static classes [Zend/tests/abstract-static.phpt] PHP - 5.2.1 -------------------------- - Bug #30549 (incorrect character translations for some ISO8859 charsets) [ext/mbstring/tests/bug30549.phpt] - stream_socket_client() and invalid arguments [ext/standard/tests/file/stream_002.phpt] - touch() tests [ext/standard/tests/file/touch.phpt] - inet_ntop() & inet_pton() tests [ext/standard/tests/network/inet.phpt] BTW, php seems to compile and work fine in basics test of php+mysql apps. Luca, what do you think? :)
(In reply to comment #25) > Luca, what do you think? :) Fine to go, all those are known failures and shouldn't worry anybody. Best regards, CHTEKK.
dev-lang/php-4.4.6 dev-lang/php-5.1.6-r11 dev-lang/php-5.2.1-r3 dev-php4/suhosin-0.9.17 dev-php4/pecl-zip-1.8.6 dev-php5/suhosin-0.9.17 dev-php5/pecl-zip-1.8.6 dev-php5/pecl-filter-0.11.0 Stable on alpha. Thanks guys. I'll do more keywording on monday.
GLSA 200703-21
ia64 stable