Bug #76929 [NEW]: zip-based phar does not respect phar.require_hash
| From: | david at bamsoftware dot com | Date: | Mon, 24 Sep 2018 19:56:52 +0000 |
| Subject: | Bug #76929 [NEW]: zip-based phar does not respect phar.require_hash | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-217221@lists.php.net to get a copy of this message | ||
From: david at bamsoftware dot com
Operating system: Linux 4.18.0-1-amd64
PHP version: master-Git-2018-09-24 (Git)
Package: PHAR related
Bug Type: Bug
Bug description:zip-based phar does not respect phar.require_hash
Description:
------------
Phar files in the zip format do not raise an error when
phar.require_hash is true and the file lacks a signature
(.phar/signature.bin), unlike the phar and tar formats.
The attached patch adds a test, copied with adjustments from
ext/phar/tests/tar/require_hash.phpt; and a check for require_hash,
copied with adjustments from ext/phar/tar.c.
This bug could allow you to bypass the signature check on openssl-signed
phars by rewriting them as zip files without a signature. I didn't mark
the bug "Security" though, because you can accomplish the same thing
more easily by rewriting the phar with e.g. an md5 signature.
commit 152dc924c565330619a90f99dc1f223bb22ac420
./configure --with-openssl --with-zlib --with-bz2 --enable-zip
Test script:
---------------
<?
$zip = new ZipArchive;
$zip->open('zip.phar', ZIPARCHIVE::CREATE);
$zip->addFromString('zip.php', '<?php var_dump(__FILE__);');
$zip->addFromString('.phar/stub.php', '__HALT_COMPILER();');
$zip->close();
$phar = new Phar('zip.phar');
echo $phar->getStub();
Expected result:
----------------
Fatal error: Uncaught UnexpectedValueException: zip-based phar
"zip.phar" does not have a signature in zip.php:8
Actual result:
--------------
__HALT_COMPILER();
--
Edit bug report at https://bugs.php.net/bug.php?id=76929&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76929&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76929&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76929&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76929&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76929&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76929&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76929&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76929&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76929&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76929&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76929&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76929&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76929&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76929&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76929&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76929&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76929&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76929&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76929&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76929&r=mysqlcfg