Skip to content

Fix GH-24729: UAF in ReflectionClass::setStaticPropertyValue() - #24732

Open
lazerg wants to merge 2 commits into
php:PHP-8.4from
lazerg:fix/gh-24729-reflection-static-prop-dtor
Open

lazerg wants to merge 2 commits into
php:PHP-8.4from
lazerg:fix/gh-24729-reflection-static-prop-dtor

Conversation

@lazerg

@lazerg lazerg commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

variable_ptr was dereferenced up front and kept across user code. The old value's destructor (or a __toString() call during type coercion) could drop the reference it pointed into, so the write landed in freed memory. Check the property type first, then assign through the static slot with zend_assign_to_variable(), like zend_update_static_property_ex() does. That handles typed references and frees the old value only after the write.

Fixes #24729

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.

1 participant