Alex Monk has submitted this change and it was merged.
Change subject: Disable external entities in Import
......................................................................
Disable external entities in Import
Temporarily disable loading entities in XMLReader when calling read()
during import.
(cherry-pick from 77a8d576918b6a47b80a67a3653662a2d705d6c3)
bug: 47251
Change-Id: I0b39386e6cf4ec0244aab8ebc4095922511e2964
---
M includes/Import.php
1 file changed, 8 insertions(+), 1 deletion(-)
Approvals:
Alex Monk: Verified; Looks good to me, approved
diff --git a/includes/Import.php b/includes/Import.php
index e906c7f..c4c7c26 100644
--- a/includes/Import.php
+++ b/includes/Import.php
@@ -396,10 +396,16 @@
* Primary entry point
*/
public function doImport() {
+
+ // Calls to reader->read need to be wrapped in calls to
+ // libxml_disable_entity_loader() to avoid local file
+ // inclusion attacks (bug 46932).
+ $oldDisable = libxml_disable_entity_loader( true );
$this->reader->read();
if ( $this->reader->name != 'mediawiki' ) {
- throw new MWException( "Expected <mediawiki> tag, got ".
+ libxml_disable_entity_loader( $oldDisable );
+ throw new MWException( "Expected <mediawiki> tag, got "
.
$this->reader->name );
}
$this->debug( "<mediawiki> tag is correct." );
@@ -437,6 +443,7 @@
}
}
+ libxml_disable_entity_loader( $oldDisable );
return true;
}
--
To view, visit https://gerrit.wikimedia.org/r/59349
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0b39386e6cf4ec0244aab8ebc4095922511e2964
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: REL1_19
Gerrit-Owner: CSteipp <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits