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
In DOMNode::C14N(), improper removal of a xmlns libxml2 attribute from a doubly linked list can lead to a corrupt, circular linked list. The linked list is iterated in many places in PHP and libxml2, leading to DoS through segfaults, or temporal and spatial resource starvation.
$doc = Dom\HTMLDocument::createFromString('<svg foo="foo" xmlns="" bar="bar">');
$doc->C14N();
// Segfault on cleanup// Or$doc = Dom\HTMLDocument::createFromString('<svg foo="foo" xmlns="" bar="bar">');
$doc->C14N();
$svg = $doc->documentElement->childNodes[1]->childNodes[0];
foreach ($svg->attributesas$prop) {} // This will loop forever
Researcher: Nikita Sveshnikov (Positive Technologies)
In
DOMNode::C14N(), improper removal of axmlnslibxml2 attribute from a doubly linked list can lead to a corrupt, circular linked list. The linked list is iterated in many places in PHP and libxml2, leading to DoS through segfaults, or temporal and spatial resource starvation.The attribute is removed incorrectly here:
php-src/ext/dom/node.c
Lines 2134 to 2141 in f0f28b7
Notice the
attr->prev = attr->next;instead ofattr->prev->next = attr->next;. The attribute is later (correctly) restored here:php-src/ext/dom/node.c
Lines 2182 to 2189 in f0f28b7
After both procedures, the following graph:
flowchart TD A -- "Next" --> xmlns xmlns -- "Prev" --> A xmlns -- "Next" --> B B -- "Prev" --> xmlnsWould result in this graph:
flowchart TD A -- "Next" --> xmlns xmlns -- "Prev" --> B xmlns -- "Next" --> B B -- "Prev" --> xmlns B -- "Next" --> xmlnsContinuously following
nextwill result in an infinite loop.