mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-08-29 01:56:42 +00:00
fix(xcatd): block XML external entities on the legacy parser path
xCAT::XML wraps XML::Simple. It blocks XML external entities. An external entity can read a local file or a network resource. XML::Simple with new_xml_parser() installs an ExternEnt handler. The handler returns the system id, not the content. XML::Simple 2.20 to 2.24 has no new_xml_parser(). On these versions xCAT uses build_tree_xml_parser() instead. This function did not install the handler. A SYSTEM entity then expanded. It leaked a local file into the parsed data. This change adds the same handler to build_tree_xml_parser(). Both paths pass parser options in an array reference. XML::Parser->new ignores that reference. The handler is therefore the real defense. This fix keeps #6917, which retains the compatibility path for those releases. This fix was recovered from the lenovobuild branch. See PR #6505.
This commit is contained in:
@@ -56,6 +56,7 @@ sub build_tree_xml_parser {
|
||||
no_network => 1,
|
||||
expand_entities => 0,
|
||||
]);
|
||||
$xp->setHandlers(ExternEnt => sub { return $_[2] });
|
||||
my($tree);
|
||||
if($filename) {
|
||||
# $tree = $xp->parsefile($filename); # Changed due to prob w/mod_perl
|
||||
|
||||
Reference in New Issue
Block a user