-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix UAF when removing doctype and using foreach iteration
This is an old bug, but this is pretty easy to fix. It's basically applying the same fix as I did for e878b9f. Reported by YuanchengJiang. Closes GH-15143.
- Loading branch information
Showing
5 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
--TEST-- | ||
UAF when removing doctype and iterating over the child nodes | ||
--EXTENSIONS-- | ||
dom | ||
--CREDITS-- | ||
Yuancheng Jiang | ||
--FILE-- | ||
<?php | ||
$dom = new DOMDocument; | ||
$dom->loadXML(<<<XML | ||
<!DOCTYPE foo [ | ||
<!ENTITY foo1 "bar1"> | ||
]> | ||
<foo>&foo1;</foo> | ||
XML); | ||
$ref = $dom->documentElement->firstChild; | ||
$nodes = $ref->childNodes; | ||
$dom->removeChild($dom->doctype); | ||
foreach($nodes as $str) {} | ||
var_dump($nodes); | ||
?> | ||
--EXPECTF-- | ||
object(DOMNodeList)#%d (1) { | ||
["length"]=> | ||
int(0) | ||
} |