Skip to content

Conversation

@Oblivionsage
Copy link
Contributor

@Oblivionsage Oblivionsage commented Dec 2, 2025

When pos.size is less than 2, the subtraction pos.size - 2 causes an unsigned integer underflow, resulting in a ~4GB allocation attempt.

Add minimum size check (pos.size >= 2) to prevent the underflow.

Closes #20631

When pos.size is less than 2, the subtraction pos.size - 2 causes
an unsigned integer underflow, resulting in a ~4GB allocation attempt.

Add minimum size check (pos.size >= 2) to prevent the underflow.
Copy link
Member

@ndossche ndossche left a comment

Choose a reason for hiding this comment

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

Thanks!
For the future, this should actually target the PHP-8.5 branch. That's because bugfixes always should target the lowest supported branch and we will merge upwards.
Doesn't matter now as I'll just cherry-pick into the right branch.
Leaving this open for a bit to see if anyone else has comments.

Copy link
Member

@bukka bukka left a comment

Choose a reason for hiding this comment

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

Can you add a test with that malicious image that you have?

@Oblivionsage
Copy link
Contributor Author

Can you add a test with that malicious image that you have?

added a test in the second commit , it patches image029.heic to set extent_length=1 and verifies the fix handles it gracefully

Copy link
Member

@ndossche ndossche left a comment

Choose a reason for hiding this comment

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

Thanks

@ndossche ndossche closed this in 6a0da6d Dec 3, 2025
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.

Integer underflow in exif HEIF parsing when pos.size < 2

3 participants