mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-09-04 20:17:55 +00:00
fix(xcatd): refuse an XML request that carries a document type declaration
The daemon reads the XML of every request through this parser. A request could declare an entity in its own document type declaration, and the parser expanded it. An entity that refers to other entities grows on each level, so a short request expands into a large document and consumes the memory and the time of the daemon. A client holds a certificate before it can send a request, so this needs an account, but the daemon should not accept the work. Refuse the declaration itself. The option that stops the parser from expanding an entity does not cover an entity that a request names inside an attribute, so it leaves the same growth available through a different part of the document. Measured on XML::Parser 2.46, a request of 204 bytes that names its entity in an attribute still grew to 1014 bytes with that option set, which is what the parser does without it. No request that xCAT sends carries a document type declaration. The client builds every request with XML::Simple, which does not write one. The handler that refuses an external entity stays, so a parser that reaches it by another route still refuses to read the named file.
This commit is contained in:
@@ -51,7 +51,8 @@ sub build_tree_xml_parser {
|
||||
}
|
||||
|
||||
my $xp = XML::Parser->new(Style => 'Tree');
|
||||
$xp->setHandlers(ExternEnt => sub { return $_[2] });
|
||||
$xp->setHandlers(ExternEnt => sub { return $_[2] },
|
||||
Doctype => sub { croak 'XML document type declaration is not accepted' });
|
||||
my($tree);
|
||||
if($filename) {
|
||||
# $tree = $xp->parsefile($filename); # Changed due to prob w/mod_perl
|
||||
@@ -68,7 +69,8 @@ sub build_tree_xml_parser {
|
||||
sub new_xml_parser {
|
||||
my($self) = @_;
|
||||
my $xp = XML::Parser->new(Style => 'Tree');
|
||||
$xp->setHandlers(ExternEnt => sub {return $_[2]});
|
||||
$xp->setHandlers(ExternEnt => sub {return $_[2]},
|
||||
Doctype => sub { croak 'XML document type declaration is not accepted' });
|
||||
return $xp;
|
||||
}
|
||||
1;
|
||||
|
||||
Reference in New Issue
Block a user