]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 842038: (CVE-2013-0785) [SECURITY] XSS in show_bug.cgi when using an invalid...
authorFrédéric Buclin <LpSolit@gmail.com>
Tue, 19 Feb 2013 17:26:26 +0000 (18:26 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Tue, 19 Feb 2013 17:26:26 +0000 (18:26 +0100)
r=glob a=LpSolit

Bugzilla/Template.pm
show_bug.cgi
template/en/default/global/user-error.html.tmpl

index 11411e8e6222cb63f67c6a8f74a31e334ec9acce..c1f49a22479bb06b1fcc1a1bc8fa078a3ccbe365 100644 (file)
@@ -98,9 +98,12 @@ sub get_format {
     $ctype ||= 'html';
     $format ||= '';
 
-    # Security - allow letters and a hyphen only
-    $ctype =~ s/[^a-zA-Z\-]//g;
-    $format =~ s/[^a-zA-Z\-]//g;
+    # ctype and format can have letters and a hyphen only.
+    if ($ctype =~ /[^a-zA-Z\-]/ || $format =~ /[^a-zA-Z\-]/) {
+        ThrowUserError('format_not_found', {'format' => $format,
+                                            'ctype'  => $ctype,
+                                            'invalid' => 1});
+    }
     trick_taint($ctype);
     trick_taint($format);
 
@@ -126,6 +129,7 @@ sub get_format {
     return
     {
         'template'    => $template,
+        'format'      => $format,
         'extension'   => $ctype,
         'ctype'       => Bugzilla::Constants::contenttypes->{$ctype}
     };
index 10d35956dc6d0aad6dd140195dab833d53c3105c..846cf64d51262ee82506eb597d0f36f1f8c6d620 100755 (executable)
@@ -22,9 +22,11 @@ my $vars = {};
 
 my $user = Bugzilla->login();
 
+my $format = $template->get_format("bug/show", scalar $cgi->param('format'),
+                                   scalar $cgi->param('ctype'));
+
 # Editable, 'single' HTML bugs are treated slightly specially in a few places
-my $single = !$cgi->param('format')
-  && (!$cgi->param('ctype') || $cgi->param('ctype') eq 'html');
+my $single = !$format->{format} && $format->{extension} eq 'html';
 
 # If we don't have an ID, _AND_ we're only doing a single bug, then prompt
 if (!$cgi->param('id') && $single) {
@@ -34,9 +36,6 @@ if (!$cgi->param('id') && $single) {
     exit;
 }
 
-my $format = $template->get_format("bug/show", scalar $cgi->param('format'), 
-                                   scalar $cgi->param('ctype'));
-
 my (@bugs, @illegal_bugs);
 my %marks;
 
@@ -126,5 +125,5 @@ $vars->{'displayfields'} = \%displayfields;
 
 print $cgi->header($format->{'ctype'});
 
-$template->process("$format->{'template'}", $vars)
+$template->process($format->{'template'}, $vars)
   || ThrowTemplateError($template->error());
index 479691ad01367a13a201511d9ede20cd2df01ee4..30ca3e86b6dacfd3aaefc3c0f09279371c0d7458 100644 (file)
     [% title = "Format Not Found" %]
     The requested format <em>[% format FILTER html %]</em> does not exist with
     a content type of <em>[% ctype FILTER html %]</em>.
-    
+    [% IF invalid %]
+      Both parameters must contain letters and hyphens only.
+    [% END %]
+
   [% ELSIF error == "flag_type_sortkey_invalid" %]
     [% title = "Flag Type Sort Key Invalid" %]
     The sort key <em>[% sortkey FILTER html %]</em> must be an integer