]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 705474 - CSRF vulnerability in createaccount.cgi allows possible unauthorized...
authorReed Loden <reed@reedloden.com>
Tue, 13 Dec 2011 22:30:07 +0000 (14:30 -0800)
committerReed Loden <reed@reedloden.com>
Tue, 13 Dec 2011 22:30:07 +0000 (14:30 -0800)
[r=mkanat a=mkanat]

Bugzilla/Token.pm
createaccount.cgi
template/en/default/account/create.html.tmpl

index 86220aa29dab90d74ddb64c1e5209e719aa7815f..2bb68e72122aa372948fc1c7012c97f74b9c95a8 100644 (file)
@@ -176,9 +176,14 @@ sub issue_hash_token {
     $data ||= [];
     $time ||= time();
 
+    # For the user ID, use the actual ID if the user is logged in.
+    # Otherwise, use the remote IP, in case this is for something
+    # such as creating an account or logging in.
+    my $user_id = Bugzilla->user->id || remote_ip();
+
     # The concatenated string is of the form
-    # token creation time + site-wide secret + user ID + data
-    my @args = ($time, Bugzilla->localconfig->{'site_wide_secret'}, Bugzilla->user->id, @$data);
+    # token creation time + site-wide secret + user ID (either ID or remote IP) + data
+    my @args = ($time, Bugzilla->localconfig->{'site_wide_secret'}, $user_id, @$data);
 
     my $token = join('*', @args);
     # Wide characters cause md5_hex() to die.
index db0727adda7e50ede1d1d370b89b0c872ff2e6c8..2348d4e9146f90988b03d1baf205aefb0056eba8 100755 (executable)
@@ -62,6 +62,11 @@ unless ($createexp) {
 my $login = $cgi->param('login');
 
 if (defined($login)) {
+    # Check the hash token to make sure this user actually submitted
+    # the create account form.
+    my $token = $cgi->param('token');
+    check_hash_token($token, ['create_account']);
+
     $login = Bugzilla::User->check_login_name_for_creation($login);
     $vars->{'login'} = $login;
 
index 5b82201930f5a6fb22f2a4e6fcceef940a028fc6..5acd9f54164b6364f067069802a9a42c10fc2345 100644 (file)
@@ -73,6 +73,7 @@
     </tr>
   </table>
   <br>
+  <input type="hidden" id="token" name="token" value="[% issue_hash_token(['create_account']) FILTER html %]">
   <input type="submit" id="send" value="Send">
 </form>