Repository navigation
Conversation
Member
|
Thanks for working on this. I tested this PR and current master under ASAN ( Still needed
Can be dropped
So on master, the fix reduces to this, plus the bug73927.phpt void phpdbg_backup_watch_element(phpdbg_watch_element *element) {
+ if (!element->watch) {
+ return;
+ }
memcpy(&element->backup, &element->watch->backup, /* element->watch->size */ sizeof(element->backup));
}
@@ void phpdbg_clean_watch_element(phpdbg_watch_element *element) {
if (zend_hash_num_elements(elements) == 0) {
phpdbg_remove_watchpoint(element->watch);
}
+ element->watch = NULL;
}
} |
phpdbg_clean_watch_element() left element->watch pointing at the watchpoint that phpdbg_remove_watchpoint() had just freed, so a later phpdbg_backup_watch_element() on the same chain copied from freed memory. Clear the pointer and skip the backup for a detached element. Drop the SKIP_ASAN guard from bug73927.phpt, which reproduces the read. Fixes phpGH-13230
iliaal
force-pushed
the
fix/gh-13230-phpdbg-watch-uaf
branch
from
November 9, 2026 13:34
fd289bc to
88c00cb
Compare
Member
Author
|
Confirmed on master: bug73927.phpt still hits the UAF in |
Member
|
@ndossche If you have a chance, could you please take a look at it to see if it makes sense? |
ndossche
approved these changes
Nov 11, 2026
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.
When a watched element is removed and its watchpoint freed,
element->watchkept pointing at the freed watchpoint, and a later backup on the same watch chain copied from it. Clear the pointer and skip the backup for a detached element. bug73927.phpt reproduces the read under ASAN once its SKIP_ASAN guard is dropped.Fixes #13230