]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 706271: CSRF vulnerability in token.cgi allows possible unauthorized password...
authorFrédéric Buclin <LpSolit@gmail.com>
Mon, 6 Aug 2012 21:44:33 +0000 (23:44 +0200)
committerFrédéric Buclin <LpSolit@gmail.com>
Mon, 6 Aug 2012 21:44:33 +0000 (23:44 +0200)
r=reed a=LpSolit

template/en/default/account/auth/login-small.html.tmpl
template/en/default/account/auth/login.html.tmpl
token.cgi

index fbe40fb434711870559742362c1da73f3b85844c..cb43354660812eb6665b60803a2390b3ef587cd4 100644 (file)
@@ -36,8 +36,8 @@
   [% IF cgi.request_method == "GET" AND cgi.query_string %]
     [% connector = "&" %]
   [% END %]
-  [% script_name = login_target _ connector _ "GoAheadAndLogIn=1" %]
-  <a id="login_link[% qs_suffix %]" href="[% script_name FILTER html %]"
+  [% script_url = login_target _ connector _ "GoAheadAndLogIn=1" %]
+  <a id="login_link[% qs_suffix %]" href="[% script_url FILTER html %]"
      onclick="return show_mini_login_form('[% qs_suffix %]')">Log In</a>
 
   [% Hook.process('additional_methods') %]
 </li>
 <li id="forgot_container[% qs_suffix %]">
   <span class="separator">| </span>
-  <a id="forgot_link[% qs_suffix %]" href="[% script_name FILTER html %]#forgot"
+  <a id="forgot_link[% qs_suffix %]" href="[% script_url FILTER html %]#forgot"
      onclick="return show_forgot_form('[% qs_suffix %]')">Forgot Password</a>
   <form action="token.cgi" method="post" id="forgot_form[% qs_suffix %]"
         class="mini_forgot bz_default_hidden">
     <input id="forgot_button[% qs_suffix %]" value="Reset Password" 
            type="submit">
     <input type="hidden" name="a" value="reqpw">
+    <input type="hidden" id="token" name="token" value="[% issue_hash_token(['reqpw']) FILTER html %]">
     <a href="#" onclick="return hide_forgot_form('[% qs_suffix %]')">[x]</a>
   </form>
 </li>
index 122ef6f7ce7370e5594afe651b9952aa92f4e4eb..3de52b6a0d9059447f35205ac4782f57f1f3af47 100644 (file)
       enter your login name below and submit a request
       to change your password.<br>
       <input size="35" name="loginname">
+      <input type="hidden" id="token" name="token" value="[% issue_hash_token(['reqpw']) FILTER html %]">
       <input type="submit" id="request" value="Reset Password">
     </form>
   [% END %]
index fa262e76a40b2050d02377ac8086aafed2df9cd2..20870159a5e85395be285e68404ff33f76dbf77f 100755 (executable)
--- a/token.cgi
+++ b/token.cgi
@@ -108,6 +108,11 @@ if ( $action eq 'reqpw' ) {
         ThrowUserError("password_change_requests_not_allowed");
     }
 
+    # Check the hash token to make sure this user actually submitted
+    # the forgotten password form.
+    my $token = $cgi->param('token');
+    check_hash_token($token, ['reqpw']);
+
     validate_email_syntax($login_name)
         || ThrowUserError('illegal_email_address', {addr => $login_name});