Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,8 @@ PHP NEWS
(kocsismate)

- Zip:
. Fixed bug GH-21682 (ZipArchive must not be serializable).
(Nickolay Harin)
. Fixed ZipArchive callback being called after executor has shut down.
(ilutov)
. Support minimum version for libzip dependency updated to 1.0.0.
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/tests/strings/bug72434.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Bug #72434: ZipArchive class Use After Free Vulnerability in PHP's GC algorithm
// The following array will be serialized and this representation will be freed later on.
$free_me = array(new StdClass());
// Create our payload and unserialize it.
$serialized_payload = 'a:3:{i:1;N;i:2;O:10:"ZipArchive":1:{s:8:"filename";'.serialize($free_me).'}i:1;R:4;}';
$serialized_payload = 'a:3:{i:1;N;i:2;O:8:"stdClass":1:{s:8:"filename";'.serialize($free_me).'}i:1;R:4;}';
$unserialized_payload = unserialize($serialized_payload);
gc_collect_cycles();
// The reference counter for $free_me is at -1 for PHP 7 right now.
Expand Down
3 changes: 3 additions & 0 deletions ext/zip/php_zip.stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ function zip_entry_filesize($zip_entry): int|false {}
#[\Deprecated(since: '8.0', message: 'use ZipArchive::statIndex() instead')]
function zip_entry_compressionmethod($zip_entry): string|false {}

/**
* @not-serializable
*/
class ZipArchive implements Countable
{
/**
Expand Down
4 changes: 2 additions & 2 deletions ext/zip/php_zip_arginfo.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions ext/zip/tests/gh21682.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--TEST--
GH-21682 (ZipArchive must not be serializable)
--EXTENSIONS--
zip
--FILE--
<?php
try {
serialize(new ZipArchive());
} catch (\Exception $e) {
echo $e->getMessage(), "\n";
}
?>
--EXPECT--
Serialization of 'ZipArchive' is not allowed
Loading