Skip to content

Fix GH-23331: UAF when an attribute child keeps a live wrapper - #236

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
fix/gh-23331-dom-attr-child-uaf
Closed

Fix GH-23331: UAF when an attribute child keeps a live wrapper#236
iliaal wants to merge 1 commit into
PHP-8.4from
fix/gh-23331-dom-attr-child-uaf

Conversation

@iliaal

@iliaal iliaal commented Aug 17, 2026

Copy link
Copy Markdown
Owner

node_list_unlink() abandoned an attribute's remaining children at two exits: xmlUnlinkNode() clears node->next, and the entity-reference case broke out of the loop instead of only skipping the borrowed entity children. Anything past either exit was freed by xmlSetProp()/xmlSetNsProp() with a live wrapper still pointing at it. The #37456 recursion guard is kept.

node_list_unlink() detaches attribute children that still have a PHP
wrapper so libxml2 does not free them underneath it, but two exits
abandoned the rest of the list: xmlUnlinkNode() clears node->next, and
the XML_ENTITY_REF_NODE case broke out of the loop instead of only
skipping the borrowed entity children. Anything past either exit was
freed by xmlSetProp(), xmlSetNsProp() or xmlFreeProp() with a live
wrapper still pointing at it.

Fixes phpGH-23331
@iliaal
iliaal force-pushed the fix/gh-23331-dom-attr-child-uaf branch from aa208fd to ec8556a Compare August 17, 2026 19:23
@iliaal

iliaal commented Aug 17, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream: php#23337

@iliaal iliaal closed this Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant