|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2016-12-27 07:04 UTC] stas@php.net
-Status: Open
+Status: Feedback
[2016-12-27 07:04 UTC] stas@php.net
[2016-12-27 09:05 UTC] eyal dot itkin at gmail dot com
-Status: Feedback
+Status: Open
[2016-12-27 09:05 UTC] eyal dot itkin at gmail dot com
[2016-12-30 23:41 UTC] stas@php.net
-Assigned To:
+Assigned To: stas
[2016-12-30 23:41 UTC] stas@php.net
[2016-12-30 23:59 UTC] stas@php.net
-PHP Version: 7.1.0
+PHP Version: 5.6.29
[2016-12-31 01:01 UTC] stas@php.net
-CVE-ID:
+CVE-ID: needed
[2016-12-31 08:30 UTC] eyal dot itkin at gmail dot com
[2017-01-01 02:50 UTC] stas@php.net
[2017-01-03 05:26 UTC] stas@php.net
-Status: Assigned
+Status: Closed
[2017-01-03 05:26 UTC] stas@php.net
[2017-01-25 11:10 UTC] kaplan@php.net
-CVE-ID: needed
+CVE-ID: 2016-10159
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 21:00:01 2025 UTC |
Description: ------------ Loading a hostile phar archive can cause an extensive memory allocation, that will trigger a fatal PHP error on 32 bit computers. 1) entry.filename_len is 4 bytes 2) value of 2 ** 32 - x can trigger an integer-overflow in the sanity check ( 0 < x <= 20): if(entry.filename_len - 20 > (size_t)(endbuffer - buffer)){ 3) later the call to "pestrndup" will crash: pestrndup(buffer, entry.filename_len, entry.is_persistent); The fix should be in 2 separate checks: 1) update the 1st check inside the loop from 4 to 24 (full entry size): if (buffer + 24 < endbuffer){ 2) avoid integer-overflow in the sanity check (20 because buffer was advanced by 4 already): if(entry.filename_len > (size_t)(endbuffer - buffer) - 20){ Test script: --------------- <?php $p = Phar::LoadPhar('example_hostile.phar', 'alias.phar'); echo "Loaded the phar archive\n"; ?> Expected result: ---------------- The script should print the message Actual result: -------------- " mmap() failed: [22] Invalid argument mmap() failed: [22] Invalid argument PHP Fatal error: Out of memory (allocated 2097152) (tried to allocate 4294967277 bytes) in XXX on line 2 "