]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 621108: [SECURITY] Creating/editing charts lacks CSRF protection
authorFrédéric Buclin <LpSolit@gmail.com>
Mon, 24 Jan 2011 17:19:26 +0000 (18:19 +0100)
committerFrédéric Buclin <LpSolit@gmail.com>
Mon, 24 Jan 2011 17:19:26 +0000 (18:19 +0100)
r=dkl a=LpSolit

chart.cgi
template/en/default/reports/edit-series.html.tmpl
template/en/default/search/search-create-series.html.tmpl

index c74df4f7b30c5dc5d9e8dfa430df9889800fde57..5da0d7b22cc6915f21c50dfdc99093794fe8f6b7 100755 (executable)
--- a/chart.cgi
+++ b/chart.cgi
@@ -52,6 +52,7 @@ use Bugzilla::Util;
 use Bugzilla::Chart;
 use Bugzilla::Series;
 use Bugzilla::User;
+use Bugzilla::Token;
 
 # For most scripts we don't make $cgi and $template global variables. But
 # when preparing Bugzilla for mod_perl, this script used these
@@ -138,7 +139,9 @@ elsif ($action eq "wrap") {
 }
 elsif ($action eq "create") {
     assertCanCreate($cgi);
-    
+    my $token = $cgi->param('token');
+    check_hash_token($token, ['create-series']);
+
     my $series = new Bugzilla::Series($cgi);
 
     if (!$series->existsInDatabase()) {
@@ -168,7 +171,11 @@ elsif ($action eq "alter") {
     detaint_natural($series_id) || ThrowCodeError("invalid_series_id");
     assertCanEdit($series_id);
 
-    my $series = new Bugzilla::Series($cgi);
+    # We cannot use the $series object below, as its name may have changed.
+    my $series = new Bugzilla::Series($series_id);
+    my $token = $cgi->param('token');
+    check_hash_token($token, [$series->{series_id}, $series->{name}]);
+    $series = new Bugzilla::Series($cgi);
 
     # We need to check if there is _another_ series in the database with
     # our (potentially new) name. So we call existsInDatabase() to see if
index 7fbdcbdfd10c5f2c3ce01fb0bfc49af3874ca959..20db2d667b92a7355a15273f480fe84ca8a25751 100644 (file)
@@ -40,7 +40,9 @@
   [% PROCESS reports/series.html.tmpl 
      button_name = "Change Data Set" %]
   <input type="hidden" name="action" value="alter">
-  
+  <input type="hidden" name="token"
+         value="[% issue_hash_token([default.series_id, default.name]) FILTER html %]">
+
   [% IF default.series_id %]
     <input type="hidden" name="series_id" value="[% default.series_id %]">
   [% END %]
index da1011e10c39f015ec117471c3eecb09e405ab1a..26010af648bc009b3fc020510d918a2b92442de4 100644 (file)
@@ -52,6 +52,7 @@
 [% PROCESS reports/series.html.tmpl 
    button_name = "Create Data Set" %]
   <input type="hidden" name="action" value="create">
+  <input type="hidden" name="token" value="[% issue_hash_token(['create-series']) FILTER html %]">
 
 <script type="text/javascript">
   document.chartform.category[0].selected = true;