Skip to content

Fix HashTable UAF when rebound from a parameter __toString() - #23252

Open
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/pdo-param-event-reentry
Open

Fix HashTable UAF when rebound from a parameter __toString()#23252
iliaal wants to merge 1 commit into
php:PHP-8.4from
iliaal:fix/pdo-param-event-reentry

Conversation

@iliaal

@iliaal iliaal commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

dispatch_param_event walks bound_params with ZEND_HASH_FOREACH while sqlite's EXEC_PRE hook can run __toString. From there execute() frees the table and bindValue() replaces buckets. This steals one _reserved bit as in_param_event (no layout size change; the header is installed) and throws Error from bind/execute/closeCursor while the hook is running. 8.5/master already have a refactored uint16_t bitfield with in_fetch; the forward merge needs in_param_event:1 and reserved:11.

dispatch_param_event iterates bound_params with ZEND_HASH_FOREACH
while sqlite's EXEC_PRE hook can run __toString; execute() then
destroys the table and bindValue() replaces buckets. Steal one
_reserved bit as in_param_event (no layout size change; the header
is installed) and throw Error from bindParam, bindValue, bindColumn,
execute, and closeCursor while the hook is running. fetch is left
unguarded: nested FOREACH is read-only and FETCH_POST writes column
zvals, not the HashTable. 8.5/master already have a uint16_t
bitfield with in_fetch; the forward merge needs in_param_event:1
and reserved:11.
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