Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Dec 15, 2024

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().

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

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

LGTM! Thank you!

$box->value = null;
}
}
$box = new stdClass();
Copy link
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
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.

@nielsdos nielsdos closed this in ee0daa5 Dec 15, 2024
charmitro pushed a commit to wasix-org/php that referenced this pull request Mar 13, 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.

zend_array_try_init() with dtor can cause engine UAF
2 participants