Skip to content

ext/dom: fix UAF when setting an attribute colliding by local name.#22452

Open
devnexen wants to merge 1 commit into
php:PHP-8.4from
devnexen:gh22447
Open

ext/dom: fix UAF when setting an attribute colliding by local name.#22452
devnexen wants to merge 1 commit into
php:PHP-8.4from
devnexen:gh22447

Conversation

@devnexen

@devnexen devnexen commented Jun 25, 2026

Copy link
Copy Markdown
Member

Fix #22447

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.

@devnexen devnexen linked an issue Jun 25, 2026 that may be closed by this pull request
@devnexen devnexen marked this pull request as draft June 25, 2026 12:16
Fix php#22447

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.

close phpGH-22452
@devnexen devnexen marked this pull request as ready for review June 25, 2026 13:25
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.

UAF at dom_objects_free_storage

1 participant