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

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

index c8f606b98718e1dca0f8c6b03c91a9b4ad516823..ca551fa48340d5b4b3863cccd0cf03c9da9d0dd6 100644 (file)
@@ -657,6 +657,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 e83893d9a8158eec871cb4314926284d7e7762d4..652f863d5e57a2f5635025760d9a62e0cde10800 100644 (file)
@@ -88,6 +88,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 05e453adae40fe24d738297dc643936c0b708146..7316333ee64af9fc0528e4c79cfab469231e7435 100644 (file)
@@ -53,7 +53,7 @@ X-Bugzilla-Changed-Fields: [% changedfields.join(" ") %]
 [%- IF comment.count %]
 --- Comment #[% comment.count %] from [% comment.author.identity %] [%+ comment.creation_ts FILTER time(undef, to_user.timezone) %] ---
 [% 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 b7a9932e41bdcbaf03db85ccad42d896e65ef4af..7cf75b867c9cdb59258000e9ce3f2d2b5faf6df9 100644 (file)
@@ -81,7 +81,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 %]