]> 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:37:11 +0000 (18:37 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Thu, 17 Apr 2014 16:37:11 +0000 (18:37 +0200)
r=glob a=justdave

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

index cd7507963d9b03e53a19b1f107c07084b50dd744..08999b27a7b89abb9283d642ef76ffd4663bc35a 100644 (file)
@@ -672,6 +672,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 c2dbdc97d55ace462ecee019ba8c84eece2386c7..48507ff9e73005b679a3cbd70cb7238a6a034d94 100644 (file)
@@ -91,6 +91,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 0b349fb1560228f1f45345fd230160f930a98edb..a3a0b873c28c17a3eba06f6dbdfc45fdd85eb387 100644 (file)
@@ -32,7 +32,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 fb957484b55c1d60762b418c8e4c5d6ca441b374..65946a1e19aae5e7e2601875014a39234dd0b7fd 100644 (file)
@@ -84,7 +84,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 %]