Skip to content

Fix #66783: UAF when appending DOMDocument to element#6765

Closed
cmb69 wants to merge 2 commits intophp:PHP-7.4from
cmb69:cmb/66783
Closed

Fix #66783: UAF when appending DOMDocument to element#6765
cmb69 wants to merge 2 commits intophp:PHP-7.4from
cmb69:cmb/66783

Conversation

@cmb69
Copy link
Member

@cmb69 cmb69 commented Mar 12, 2021

According to the DOM standard, elements may only contain element, text,
processing instruction and comment nodes[1]. It is also specified that
a HierarchyRequestError should be thrown if a document is to be
inserted[2]. We follow that standard, and prevent the use-after-free
this way.

[1] https://dom.spec.whatwg.org/#node-trees
[2] https://dom.spec.whatwg.org/#mutation-algorithms

According to the DOM standard, elements may only contain element, text,
processing instruction and comment nodes[1].  It is also specified that
a HierarchyRequestError should be thrown if a document is to be
inserted[2].  We follow that standard, and prevent the use-after-free
this way.

[1] <https://dom.spec.whatwg.org/#node-trees>
[2] <https://dom.spec.whatwg.org/#mutation-algorithms>
@cmb69 cmb69 added the Bug label Mar 12, 2021
@cmb69
Copy link
Member Author

cmb69 commented Mar 12, 2021

cc @beberlei

@cmb69
Copy link
Member Author

cmb69 commented Mar 15, 2021

The test failures are not related to this PR.

@php-pulls php-pulls closed this in a08847a Mar 17, 2021
@cmb69 cmb69 deleted the cmb/66783 branch March 17, 2021 11:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants