getimagesize(): WebP VP8 dimensions are accepted with an invalid start code

Open Beginner friendly
#25,964 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

@lazerg is already working on this.

Since Dec 1, 2026.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c, php

Research direction

Start with the lossy VP8 dimension decoding at ext/standard/image.c:1147-1148 and check how nearby image parsing code validates chunk data. Add a regression case using the supplied getimagesizefromstring() sample, then run the relevant image tests. Done means the invalid start code returns false while valid WebP dimensions remain accepted.

Written by the indexing model from the issue text.

Description

Bug Status: Needs Triage
Description

The following code:

<?php
$webp = 'RIFF' . pack('V', 22) . 'WEBP'
      . 'VP8 ' . pack('V', 10)
      . "\x00\x00\x00"
      . "\x9d\x01\x2b"
      . "\xff\x3f\xff\x3f";
var_dump(getimagesizefromstring($webp));

Resulted in this output:

array(8) {
  [0]=>
  int(16383)
  [1]=>
  int(16383)
  [2]=>
  int(18)
  [3]=>
  string(28) "width="16383" height="16383""
  ["bits"]=>
  int(8)
  ["mime"]=>
  string(10) "image/webp"
  ["width_unit"]=>
  string(2) "px"
  ["height_unit"]=>
  string(2) "px"
}

But I expected this output instead:

bool(false)

ext/standard/image.c:1147-1148 decodes lossy VP8 dimensions without first validating the mandatory key-frame start code 9D 01 2A at buf[11..13]. A chunk containing the near-miss 9D 01 2B must be rejected rather than trusting arbitrary bytes at offsets 14-17 as dimensions.

PHP Version
PHP 8.7.0-dev (cli) (built: Nov 29 2026 03:42:09) (NTS)
Copyright © The PHP Group and Contributors
Zend Engine v4.7.0-dev, Copyright © Zend by Perforce
    with Zend OPcache v8.7.0-dev, Copyright ©, by Zend by Perforce
Operating System

Ubuntu 24.04.5 LTS

Dominant language
C
Stars
41.9k
Forks
8.5k
Avg merge
2d 17h
Merged PRs (30d)
111

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from php/php-src

All issues in php/php-src

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.