From bbc12d9cb5efb7210665ab1587d498c8d92f89d2 Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Fri, 13 Jun 2014 15:40:15 +0800 Subject: [PATCH] MDL-45417 mod_imscp: Prevent entity injections from package content --- mod/imscp/locallib.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/mod/imscp/locallib.php b/mod/imscp/locallib.php index b3dbafbf9a8..888802a648a 100644 --- a/mod/imscp/locallib.php +++ b/mod/imscp/locallib.php @@ -105,9 +105,11 @@ function imscp_parse_structure($imscp, $context) { */ function imscp_parse_manifestfile($manifestfilecontents, $imscp, $context) { $doc = new DOMDocument(); + $oldentities = libxml_disable_entity_loader(true); if (!$doc->loadXML($manifestfilecontents, LIBXML_NONET)) { return null; } + libxml_disable_entity_loader($oldentities); // we put this fake URL as base in order to detect path changes caused by xml:base attributes $doc->documentURI = 'http://grrr/'; @@ -205,10 +207,14 @@ function imscp_recursive_href($manifestfilename, $imscp, $context) { if (!$manifestfile = $fs->get_file($context->id, 'mod_imscp', 'content', $imscp->revision, $dirname, $filename)) { return null; } + $doc = new DOMDocument(); + $oldentities = libxml_disable_entity_loader(true); if (!$doc->loadXML($manifestfile->get_content(), LIBXML_NONET)) { return null; } + libxml_disable_entity_loader($oldentities); + $xmlresources = $doc->getElementsByTagName('resource'); foreach ($xmlresources as $res) { if (!$href = $res->attributes->getNamedItem('href')) {