You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Reject DTD declaration nodes in modern DOM adoptNode() #25750
On current php-src master, Dom\Document::adoptNode() accepts DTD declaration nodes exposed through the modern DOM API as Dom\Entity. Adopting an XML_ELEMENT_DECL or XML_ENTITY_DECL into another document mutates libxml ownership while the node remains owned by the source DTD. The call returns, then the process crashes during document teardown (ASan reports a read in xmlFreeDocElementContent/xmlFreeDtd in the tested build).
Reproduction
$source = Dom\XMLDocument::createFromString('<!DOCTYPE r [<!ELEMENT r EMPTY>]><r/>');
$target = Dom\XMLDocument::createFromString('<target/>');
$target->adoptNode($source->doctype->childNodes->item(0));
Expected: reject unsupported DTD declarations with NotSupportedError before changing ownership.
This is distinct from #23352, which concerns stale PHP wrappers for attribute-value text nodes after adoption. This report concerns native ownership of the DTD declaration nodes themselves.
Activity
nwellnhof commentedon Nov 26, 2026
In libxml2, it's generally unsafe to move DTD-related nodes between documents, so this might affect other functions as well.
imattas commentedon Nov 26, 2026
should this be closed then?
nwellnhof commentedon Nov 26, 2026
No, I'm just saying that other code in PHP might be affected as well.
ext/dom: Reject DTD declaration nodes in adoptNode()