Skip to content

Fix GH-21952: UAF in DOMNotation after DOCTYPE removal. #21955

Open
devnexen wants to merge 2 commits intophp:masterfrom
devnexen:gh21952
Open

Fix GH-21952: UAF in DOMNotation after DOCTYPE removal. #21955
devnexen wants to merge 2 commits intophp:masterfrom
devnexen:gh21952

Conversation

@devnexen
Copy link
Copy Markdown
Member

@devnexen devnexen commented May 5, 2026

Commit 9498bc3 wired Dom\Notation to its owning DocType by setting
ret->parent = parent_dtd in create_notation. Because the orphan xmlEntity
allocated for the wrapper is not in any tree, the parent pointer dangles
once the DocType is removed and freed, triggering a use-after-free when
parentNode is read (e.g. via var_dump on the surviving notation).

Drop the parent assignment and align Dom\Notation::$parentNode with the
W3C DOM Level 3 Core specification (always null) and ::$isConnected with
it (always false). ownerDocument and baseURI keep working through doc.

devnexen added 2 commits May 5, 2026 18:05
Commit 9498bc3 wired Dom\Notation to its owning DocType by setting
ret->parent = parent_dtd in create_notation. Because the orphan xmlEntity
allocated for the wrapper is not in any tree, the parent pointer dangles
once the DocType is removed and freed, triggering a use-after-free when
parentNode is read (e.g. via var_dump on the surviving notation).

Drop the parent assignment and align Dom\Notation::$parentNode with the
W3C DOM Level 3 Core specification (always null) and ::$isConnected with
it (always false). ownerDocument and baseURI keep working through doc.
@devnexen devnexen changed the title Gh21952 Fix phpGH-21952: UAF in DOMNotation after DOCTYPE removal. May 5, 2026
@devnexen devnexen changed the title Fix phpGH-21952: UAF in DOMNotation after DOCTYPE removal. Fix GH-21952: UAF in DOMNotation after DOCTYPE removal. May 5, 2026
@devnexen devnexen marked this pull request as ready for review May 5, 2026 17:50
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.

[DOM] heap-use-after-free in php_dom_object_get_data when DOMNotation object is accessed after its owning DOCTYPE is removed

1 participant