getimagesize(): negative TIFF dimensions are narrowed into huge unsigned sizes
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 76/100
Research direction
Read ext/standard/image.c:823-850, focusing on how TIFF dimensions are parsed and checked before being returned. Use the provided getimagesizefromstring() example as a reproduction; done means negative dimensions return bool(false) while valid TIFF dimensions still work.
Written by the indexing model from the issue text.
Description
Description
The following code:
<?php
$tiff = "II\x2a\x00" . pack('V', 8) . pack('v', 2)
. pack('vvVv', 256, 8, 1, 0xFFFF) . "\0\0"
. pack('vvVv', 257, 8, 1, 0xFFFE) . "\0\0"
. pack('V', 0);
var_dump(getimagesizefromstring($tiff));
Resulted in this output:
array(7) {
[0]=>
int(4294967295)
[1]=>
int(4294967294)
[2]=>
int(7)
[3]=>
string(22) "width="-1" height="-2""
["mime"]=>
string(10) "image/tiff"
["width_unit"]=>
string(2) "px"
["height_unit"]=>
string(2) "px"
}
But I expected this output instead:
bool(false)
The signed TIFF values are assigned to size_t and then narrowed into unsigned result fields in ext/standard/image.c:823-850, while the guard at line 846 checks only that the dimensions are nonzero. Negative dimensions must be rejected rather than sign-extended and published as 4294967295 and 4294967294.
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
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from php/php-src
-
dns_get_record(): A record with short RDATA publishes a wrong IP address (bytes taken from the next record)Possibly taken A pull request linked to this issue is open or already merged. OpenBug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
getimagesize(): WebP VP8 dimensions are accepted with an invalid start codePossibly taken A pull request linked to this issue is open or already merged. OpenBug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Bug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
getimagesize(): JPEG 2000 Csiz is accepted without component descriptorsPossibly taken A pull request linked to this issue is open or already merged. OpenBug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Bug Status: Needs Triage
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
libsdl-org/SDL#16873 ·
Maintainers usually reply within 1 day
-
cwc.kbd.xkb_layout/xkb_options changes are not applied to all keyboard groups after reload/runtimeOpen
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
ionut-mihalache/aqua#31 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
harfbuzz/harfbuzz#6966 · 1 comment ·
Maintainers usually reply within 1 day