Skip to content

Fix GH-17162: zend_array_try_init() with dtor can cause engine UAF - #17167

Closed
ndossche wants to merge 2 commits into
php:PHP-8.3from
ndossche:fix-17162
Closed

ndossche wants to merge 2 commits into
php:PHP-8.3from
ndossche:fix-17162

Conversation

@ndossche

@ndossche ndossche commented Dec 15, 2024 •

Copy link
Copy Markdown
Member

The destructor can change the object and cause a UAF. We make the object inaccessible prior to destruction such that it is protected against the overwrite. This is also consistent with the behaviour if we were to comment out the call to getimagesize().

@ndossche ndossche linked an issue Dec 15, 2024 that may be closed by this pull request
@ndossche
ndossche marked this pull request as ready for review December 15, 2024 16:17
@ndossche
ndossche requested a review from dstogov as a code owner December 15, 2024 16:17

@iluuu1994 iluuu1994 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM! Thank you!

Comment thread Zend/tests/gh17162.phpt Outdated
$box->value = null;
}
}
$box = new stdClass();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: I don't think this stdClass is needed? Technically it should be an array, should have the same result. This doesn't fail because $image_info only has a doc-block type.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah fair, forgot this when I changed it from an mbstring function to this one, I'll change it.

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.

zend_array_try_init() with dtor can cause engine UAF

2 participants