Skip to content

Fix GH-24740: Unbounded size of .phar/.metadata* entry in TAR phar - #24742

Closed
lazerg wants to merge 1 commit into
php:PHP-8.4from
lazerg:fix/gh-24740-phar-tar-metadata-size
Closed

lazerg wants to merge 1 commit into
php:PHP-8.4from
lazerg:fix/gh-24740-phar-tar-metadata-size

Conversation

@lazerg

@lazerg lazerg commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

The tar parser passed the header size of a .phar/.metadata* entry straight to phar_tar_process_metadata(), which allocates that many bytes before reading. A 1.5 KB tar claiming a 2 GB metadata entry hits the memory limit instead of failing to open. Now a size larger than the archive is rejected up front.

Fixes #24740

@lazerg
lazerg requested a review from LamentXU123 as a code owner October 26, 2026 14:02
@lazerg lazerg changed the title Fix GH-24740: Oversized size in tar .phar/.metadata.bin entry Fix GH-24740: Unbounded size of .phar/.metadata* entry in TAR phar Oct 26, 2026
@lazerg

lazerg commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

The MACOS_ARM64_DEBUG_NTS failure is not from this change. ext/openssl fails to build against OpenSSL 4.1 deprecations, and other master PRs fail the same way.

@iliaal iliaal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase this onto PHP-8.4, which has the same issue and would benefit from the fix.

@lazerg
lazerg force-pushed the fix/gh-24740-phar-tar-metadata-size branch from f9030ed to 45d33c1 Compare October 27, 2026 12:07
@lazerg
lazerg changed the base branch from master to PHP-8.4 October 27, 2026 12:07
@lazerg

lazerg commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

I rebased it onto PHP-8.4 and dropped the NEWS entry. The new test fails on 8.4 without the fix and passes with it.

@iliaal

iliaal commented Oct 27, 2026

Copy link
Copy Markdown
Member

Thanks, I'll merge after ci/cd passes

@iliaal iliaal closed this in f9129bd Oct 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ext/phar: tar .phar/.metadata* entries have no upper bound on claimed size, unlike signature.bin/alias.txt -- unfixed sibling of GH-22556

4 participants