Fix HashTable UAF when rebound from a parameter __toString() - #23252
Open
iliaal wants to merge 1 commit into
Open
Fix HashTable UAF when rebound from a parameter __toString()#23252iliaal wants to merge 1 commit into
iliaal wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.