From 326df19f6b0ec34eb382a8014a65607cb380ac98 Mon Sep 17 00:00:00 2001 From: lazerg Date: Tue, 1 Dec 2026 06:33:47 +0500 Subject: [PATCH 1/2] Fix GH-25964: WebP VP8/VP8L dimensions accepted with an invalid signature --- ext/standard/image.c | 8 ++++++++ ext/standard/tests/image/gh25964.phpt | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 ext/standard/tests/image/gh25964.phpt diff --git a/ext/standard/image.c b/ext/standard/image.c index 7544f8556cd2..503897ef88da 100644 --- a/ext/standard/image.c +++ b/ext/standard/image.c @@ -1144,10 +1144,18 @@ static struct php_gfxinfo *php_handle_webp(php_stream * stream) switch (format) { case ' ': + if (buf[11] != 0x9d || buf[12] != 0x01 || buf[13] != 0x2a) { + efree(result); + return NULL; + } result->width = buf[14] + ((buf[15] & 0x3F) << 8); result->height = buf[16] + ((buf[17] & 0x3F) << 8); break; case 'L': + if (buf[8] != 0x2f) { + efree(result); + return NULL; + } result->width = buf[9] + ((buf[10] & 0x3F) << 8) + 1; result->height = (buf[10] >> 6) + (buf[11] << 2) + ((buf[12] & 0xF) << 10) + 1; break; diff --git a/ext/standard/tests/image/gh25964.phpt b/ext/standard/tests/image/gh25964.phpt new file mode 100644 index 000000000000..f9a876cb2189 --- /dev/null +++ b/ext/standard/tests/image/gh25964.phpt @@ -0,0 +1,22 @@ +--TEST-- +GH-25964 (getimagesize(): WebP VP8/VP8L dimensions are accepted with an invalid signature) +--CREDITS-- +kid-lxy +--FILE-- + +--EXPECT-- +bool(false) +bool(false) From c54a5c84a51a91f15b0f895bea77acb2e52d6353 Mon Sep 17 00:00:00 2001 From: lazerg Date: Tue, 1 Dec 2026 18:28:19 +0500 Subject: [PATCH 2/2] Fix GH-25964: pad VP8L test chunk --- ext/standard/tests/image/gh25964.phpt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/ext/standard/tests/image/gh25964.phpt b/ext/standard/tests/image/gh25964.phpt index f9a876cb2189..42657052e6bb 100644 --- a/ext/standard/tests/image/gh25964.phpt +++ b/ext/standard/tests/image/gh25964.phpt @@ -11,10 +11,11 @@ $webp = 'RIFF' . pack('V', 22) . 'WEBP' . "\xff\x3f\xff\x3f"; var_dump(getimagesizefromstring($webp)); -$webp = 'RIFF' . pack('V', 17) . 'WEBP' - . 'VP8L' . pack('V', 5) +$webp = 'RIFF' . pack('V', 22) . 'WEBP' + . 'VP8L' . pack('V', 10) . "\x00" - . "\xff\xff\xff\xff"; + . "\xff\xff\xff\xff" + . "\x00\x00\x00\x00\x00"; var_dump(getimagesizefromstring($webp)); ?> --EXPECT--