]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1031035: xmlrpc can be DoS'd with billion laughs attack
authorByron Jones <glob@mozilla.com>
Sat, 29 Aug 2015 09:46:40 +0000 (11:46 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Sat, 29 Aug 2015 09:46:40 +0000 (11:46 +0200)
r=LpSolit a=justdave

Bugzilla/WebService/Server/XMLRPC.pm
importxml.pl

index 5f9cb4515766f58c9c3638e74c895eb26513cc04..266376aa0b2c3b174ca28f4994ecef36cf1b6f31 100644 (file)
@@ -96,6 +96,15 @@ use Bugzilla::WebService::Constants qw(XMLRPC_CONTENT_TYPE_WHITELIST);
 use Bugzilla::WebService::Util qw(fix_credentials);
 use Scalar::Util qw(tainted);
 
+sub new {
+    my $self = shift->SUPER::new(@_);
+    # Initialise XML::Parser to not expand references to entities, to prevent DoS
+    require XML::Parser;
+    my $parser = XML::Parser->new( NoExpand => 1, Handlers => { Default => sub {} } );
+    $self->{_parser}->parser($parser, $parser);
+    return $self;
+}
+
 sub deserialize {
     my $self = shift;
 
index e7dc9761be1452ceb17a1d28df243eb60c021e3d..97c022f6a867e449dae71e5ff5f983a45e789dc4 100755 (executable)
@@ -1264,6 +1264,9 @@ my $twig = XML::Twig->new(
     },
     start_tag_handlers => { bugzilla => \&init }
 );
+# Prevent DoS using the billion laughs attack.
+$twig->{NoExpand} = 1;
+
 $twig->parse($xml);
 my $root       = $twig->root;
 my $maintainer = $root->{'att'}->{'maintainer'};