]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1259881 - CSV export vulnerable to formulae injection (again)
authorFrédéric Buclin <LpSolit@gmail.com>
Mon, 25 Apr 2016 21:39:50 +0000 (23:39 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Mon, 25 Apr 2016 21:39:50 +0000 (23:39 +0200)
r=sgreen a=dkl

Bugzilla/Template.pm

index cfcbc665547d0e3fb259675a871b79301b62474d..b9cbfcce015fb723e822a9bfed32aed0327c5fb0 100644 (file)
@@ -713,12 +713,13 @@ sub create {
             },
 
             # In CSV, quotes are doubled, and any value containing a quote or a
-            # comma is enclosed in quotes. If a field starts with an equals
-            # sign, it is proceed by a space.
+            # comma is enclosed in quotes.
+            # If a field starts with either "=", "+", "-" or "@", it is preceded
+            # by a space to prevent stupid formula execution from Excel & co.
             csv => sub
             {
                 my ($var) = @_;
-                $var = ' ' . $var if substr($var, 0, 1) eq '=';
+                $var = ' ' . $var if $var =~ /^[+=@-]/;
                 # backslash is not special to CSV, but it can be used to confuse some browsers...
                 # so we do not allow it to happen. We only do this for logged-in users.
                 $var =~ s/\\/\x{FF3C}/g if Bugzilla->user->id;