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

quips.cgi
template/en/default/list/quips.html.tmpl

index 33b4e23ce7557b435c3821c1e291d32f60345466..97993d488a48a3bff9d69e8eace8bba241102105 100755 (executable)
--- a/quips.cgi
+++ b/quips.cgi
@@ -32,6 +32,7 @@ use Bugzilla::Constants;
 use Bugzilla::Util;
 use Bugzilla::Error;
 use Bugzilla::User;
+use Bugzilla::Token;
 
 my $user = Bugzilla->login(LOGIN_REQUIRED);
 
@@ -41,6 +42,7 @@ my $template = Bugzilla->template;
 my $vars = {};
 
 my $action = $cgi->param('action') || "";
+my $token = $cgi->param('token');
 
 if ($action eq "show") {
     # Read in the entire quip list
@@ -74,6 +76,7 @@ if ($action eq "add") {
     (Bugzilla->params->{'quip_list_entry_control'} eq "closed") &&
       ThrowUserError("no_new_quips");
 
+    check_hash_token($token, ['create-quips']);
     # Add the quip 
     my $approved = (Bugzilla->params->{'quip_list_entry_control'} eq "open")
                    || Bugzilla->user->in_group('admin') || 0;
@@ -92,7 +95,8 @@ if ($action eq 'approve') {
       || ThrowUserError("auth_failure", {group  => "admin",
                                          action => "approve",
                                          object => "quips"});
+
+    check_hash_token($token, ['approve-quips']);
     # Read in the entire quip list
     my $quipsref = $dbh->selectall_arrayref("SELECT quipid, approved FROM quips");
     
@@ -134,6 +138,7 @@ if ($action eq "delete") {
     my $quipid = $cgi->param("quipid");
     ThrowCodeError("need_quipid") unless $quipid =~ /(\d+)/; 
     $quipid = $1;
+    check_hash_token($token, ['quips', $quipid]);
 
     ($vars->{'deleted_quip'}) = $dbh->selectrow_array(
                                     "SELECT quip FROM quips WHERE quipid = ?",
index d6000d5971010db252ee06576ab2e1a4b1ea4ce7..6a98fcc6949dd3797aa5ee65aa5a283bbbcfabe7 100644 (file)
@@ -73,6 +73,8 @@
 
   <form method="post" action="quips.cgi">
     <input type="hidden" name="action" value="add">
+    <input type="hidden" name="token"
+           value="[% issue_hash_token(['create-quips']) FILTER html %]">
     <input size="80" name="quip">
     <p>
       <input type="submit" id="add" value="Add This Quip">
     </p>
     <form name="editform" method="post" action="quips.cgi">
       <input type="hidden" name="action" value="approve">
+      <input type="hidden" name="token"
+             value="[% issue_hash_token(['approve-quips']) FILTER html %]">
       <table border="1">
         <thead><tr>
           <th>Quip</th>
               [% "Unknown" IF NOT users.$userid %]
             </td>
             <td>
-              <a href="quips.cgi?action=delete&amp;quipid=[% quipid FILTER url_quote %]">
+              <a href="quips.cgi?action=delete&amp;quipid=[% quipid FILTER url_quote %]&amp;token=
+                 [%- issue_hash_token(['quips', quipid]) FILTER url_quote %]">
                 Delete
               </a>
             </td>