Skip to content

Conversation

nikic
Copy link
Member

@nikic nikic commented Aug 12, 2020

Currently we only ever increment ifd_nesting_level, so this ends up being a limit on the total number of IFD tags and we regularly get bug reports of it being exceeded. I think the intention behind this limit was to prevent recursion stack overflow, and for that we only need to check actual recursive usage. I've implemented that here, and dropped the nesting limit down to a smaller value (which still passes our tests).

This should fix a number of bugs:

https://bugs.php.net/bug.php?id=78083
https://bugs.php.net/bug.php?id=78701
https://bugs.php.net/bug.php?id=79907

@nikic nikic requested a review from KalleZ August 12, 2020 08:13
@nikic nikic marked this pull request as draft August 12, 2020 09:11
@nikic
Copy link
Member Author

nikic commented Aug 12, 2020

I'm seeing OOMs during fuzzing, so we might still need a global (but much higher) limit or something.

@nikic nikic force-pushed the exif-nesting-level branch from 977c5a7 to a5b6941 Compare August 12, 2020 09:53
@nikic nikic marked this pull request as ready for review August 12, 2020 09:57
@nikic
Copy link
Member Author

nikic commented Aug 12, 2020

Okay, I have now split this into two limits: The nesting limit, and the total limit on the number of tags. The previous "nesting limit" was effectively the "total limit".

I've set the nesting limit to a low number (10) and the total limit to a high number (1000).

@nikic
Copy link
Member Author

nikic commented Aug 12, 2020

Fuzzing has been running for a few hours now and hasn't found any further issues.

@cmb69
Copy link
Member

cmb69 commented Aug 27, 2020

This would fix https://bugs.php.net/bug.php?id=80016 as well. I think we should ship this ASAP. Or do you see issues with this PR, @KalleZ?

Copy link

@kallesommernielsen kallesommernielsen left a comment

Choose a reason for hiding this comment

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

I don’t see any issues with the patch, in fact it makes it makes it easier to also adjust the limits should they become an issue in the future without letting one run wild, as I had to increase this limit a few times over the years to compensate for new formats added

@nikic
Copy link
Member Author

nikic commented Aug 31, 2020

Merged as 376bbbd.

@nikic nikic closed this Aug 31, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants