Commit cc86e1bc authored by Reed Loden's avatar Reed Loden

Bug 705474 - CSRF vulnerability in createaccount.cgi allows possible…

Bug 705474 - CSRF vulnerability in createaccount.cgi allows possible unauthorized account creation e-mail request [r=mkanat a=mkanat]
parent 49445ac5
......@@ -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.
......
......@@ -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;
......
......@@ -71,6 +71,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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment