]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 968576: [SECURITY] Dangerous control characters allowed in Bugzilla text
authorManish Goregaokar <manishearth@gmail.com>
Thu, 17 Apr 2014 16:30:14 +0000 (18:30 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Thu, 17 Apr 2014 16:30:14 +0000 (18:30 +0200)
r=glob a=justdave

Bugzilla/Template.pm
Bugzilla/Util.pm
template/en/default/email/bugmail.txt.tmpl
template/en/default/email/flagmail.txt.tmpl

index 44425edaa6fa7e576012a4c045ee8ce61b25fd53..ee610ff38b7a19e4e89167ebd70dd2c97ff28f93 100644 (file)
@@ -645,6 +645,17 @@ sub create {
                 my ($data) = @_;
                 return encode_base64($data);
             },
+
+            # Strips out control characters excepting whitespace
+            strip_control_chars => sub {
+                my ($data) = @_;
+                # Only run for utf8 to avoid issues with other multibyte encodings 
+                # that may be reassigning meaning to ascii characters.
+                if (Bugzilla->params->{'utf8'}) {
+                    $data =~ s/(?![\t\r\n])[[:cntrl:]]//g;
+                }
+                return $data;
+            },
             
             # HTML collapses newlines in element attributes to a single space,
             # so form elements which may have whitespace (ie comments) need
index 15bd7e2203b3461ac9c45193b5d02eae5a58209f..625fee96311dffb18337ce7b3113325c5297c62f 100644 (file)
@@ -68,6 +68,10 @@ sub html_quote {
     # Obscure '@'.
     $var =~ s/\@/\&#64;/g;
     if (Bugzilla->params->{'utf8'}) {
+        # Remove control characters if the encoding is utf8.
+        # Other multibyte encodings may be using this range; so ignore if not utf8.
+        $var =~ s/(?![\t\r\n])[[:cntrl:]]//g;
+
         # Remove the following characters because they're
         # influencing BiDi:
         # --------------------------------------------------------
index 999fab91111837a3a9ec38dee2154a86bdfcddfb..b3c652fcc21769dc8bce4d639ddc8a46afac5e0e 100644 (file)
@@ -19,7 +19,7 @@
 [%- IF comment.count %]
 --- Comment #[% comment.count %] from [% comment.author.identity %] ---
 [% END %]
-[%+ comment.body_full({ is_bugmail => 1, wrap => 1 }) %]
+[%+ comment.body_full({ is_bugmail => 1, wrap => 1 }) FILTER strip_control_chars %]
 [% END %]
 
 -- [%# Protect the trailing space of the signature marker %]
index cdda8d677a9398e075d06d8e0efdf079759c836c..169dfa89259377eb273650ce10db647f0168b0a5 100644 (file)
@@ -68,7 +68,7 @@ Attachment [% attidsummary %]
 [%-# .defined is necessary to avoid a taint issue in Perl < 5.10.1, see bug 509794. %]
 [% IF Bugzilla.cgi.param("comment").defined && Bugzilla.cgi.param("comment").length > 0 %]
 ------- Additional Comments from [% user.identity %]
-[%+ Bugzilla.cgi.param("comment") %]
+[%+ Bugzilla.cgi.param("comment") FILTER strip_control_chars %]
 [% END %]
 
 [%- END %]