From 595ef4772d330a20c757635ab090acdcc9b2a2fa 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 9a02dc14f1d..3ebd1060af0 100644 --- a/mod/imscp/locallib.php +++ b/mod/imscp/locallib.php @@ -104,9 +104,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/'; @@ -204,10 +206,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')) {