]> 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:27:05 +0000 (18:27 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Thu, 17 Apr 2014 16:27:05 +0000 (18:27 +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 56d31dd2d7bde8459c58cbe1537cb69ba5f152ee..6f7900054729f17c794e42746023327df1794179 100644 (file)
@@ -678,6 +678,18 @@ sub create {
                 my ($data) = @_;
                 return encode_base64($data);
             },
+
+            # Strips out control characters excepting whitespace
+            strip_control_chars => sub {
+                my ($data) = @_;
+                state $use_utf8 = Bugzilla->params->{'utf8'};
+                # Only run for utf8 to avoid issues with other multibyte encodings 
+                # that may be reassigning meaning to ascii characters.
+                if ($use_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 5f359c38ccb05f189b99dda9d8976243aeefe991..9bcb6962d1893fa35bd57141f25f04644bc02226 100644 (file)
@@ -75,6 +75,10 @@ sub html_quote {
     state $use_utf8 = Bugzilla->params->{'utf8'};
 
     if ($use_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 95cda7f10670279c32cb05c08d54280081ed2280..1f04db7b12d585f2a5a79b8414205fab75fe2526 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 %]
 
 [% IF referenced_bugs.size %]
index 26b60143d2870825bcf522e7b650f93ee0d58333..fe514e1037a190c37ccf1616a4cf6b45ef65650c 100644 (file)
@@ -69,7 +69,7 @@ Attachment [% attidsummary %]
 [%-# .defined is necessary to avoid a taint issue, 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 %]