Repository navigation
Fix HEIF EXIF extraction with variable-width iloc entries - #25200
Open
jorge-zopitech wants to merge 1 commit into
Open
jorge-zopitech wants to merge 1 commit into
jorge-zopitech wants to merge 1 commit into
Conversation
jorge-zopitech
marked this pull request as ready for review
November 12, 2026 07:18
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull request - SUBMITTED AS DRAFT
URL: #25200
Title: Fix HEIF EXIF extraction with variable-width iloc entries
Author: Jorge Moya A. - ZopiTech
GitHub: jorge-zopitech
Git commit email: jorge.moya@zopitech.cl
Target: php/php-src master
Source: jorge-zopitech:fix/exif-heif-iloc-variable-width
Commit: 0d7c9a6
Summary
PHP's EXIF HEIF parser assumes a fixed 16-byte stride for iloc
item records even though the box specifies variable widths for
the offset, length and base-offset fields. Valid HEIC files may
therefore fail to return Exif metadata via exif_read_data().
This change parses the declared field widths and extent_count,
performs bounded reads and integer overflow checks, and handles
iloc preceding iinf. The parser intentionally supports only
single-extent, local-file EXIF items when the result fits its
current offset and length representation.
Reproduction
An HEIC file encoded with libheif/x265 and tagged using ExifTool
is recognized by heif-info and ExifTool but PHP 8.5.12 returns
false from exif_read_data(). With this change, the same file
returns IFD0 Make and Model.
Tests
PHP 8.5.12 builds: 957 isolated executions. No ASan/UBSan reports.
Make/Model from all 4; original PHP extracts none.
PHP 8.5.12 build and passes on the patched build.
104 passed, 4 skipped, 0 failures.
Scope
This fixes HEIF/HEIC EXIF compatibility. No RCE, corruption of
memory or vulnerability has been demonstrated.
Multi-extent and non-local construction methods are not covered.
Notes for reviewers
Please review the bounded parsing and supported iloc versions
(v0/v1/v2), including base offsets, extent counts and unusual
box ordering. The fixture files are locally generated, without
personal photographs or metadata.
Signed-off-by: Jorge Moya A. jorge.moya@zopitech.cl