[php-src] PR #22452: ext/dom: fix UAF when setting an attribute colliding by local name.
| From: | devnexen | Date: | Thu, 25 Jun 2026 12:14:11 +0000 |
| Subject: | [php-src] PR #22452: ext/dom: fix UAF when setting an attribute colliding by local name. | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-36636@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/22452
Author: devnexen
Fix #gh22447
xmlHasProp() matches an attribute by local name only, ignoring its namespace, whereas
xmlAddChild()/xmlAddPrevSibling() dedup an incoming no-namespace attribute via xmlHasNsProp(...,
NULL), which matches only attributes with no namespace. When both a no-namespace and a namespaced
attribute share a local name, the pre-insertion check unlinked the wrong (namespaced) attribute,
leaving libxml to free the still-wrapped no-namespace duplicate and producing a use-after-free at
request shutdown.
Use xmlHasNsProp(..., NULL) so the pre-insertion check matches libxml's internal duplicate
detection, as advised by @nwellnhof.