Skip to content

Commit

Permalink
Bug 1268989 - Inefficient check of "Bugzilla_api_token" might lead to…
Browse files Browse the repository at this point in the history
… CSRF/data disclosure vulnerability in Bugzilla's REST API

r=dkl
  • Loading branch information
Dylan William Hardison authored and dklawren committed May 3, 2016
1 parent c3b2af3 commit 64df9b7
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions Bugzilla/Auth/Login/Cookie.pm
Expand Up @@ -55,15 +55,7 @@ sub get_login_info {
# If the call is for a web service, and an api token is provided, check
# it is valid.
if (i_am_webservice()) {
if ($login_cookie
&& Bugzilla->usage_mode == USAGE_MODE_REST
&& !exists Bugzilla->input_params->{Bugzilla_api_token})
{
# REST requires an api-token when using cookie authentication
# fall back to a non-authenticated request
$login_cookie = '';

} elsif (Bugzilla->input_params->{Bugzilla_api_token}) {
if (exists Bugzilla->input_params->{Bugzilla_api_token}) {
my $api_token = Bugzilla->input_params->{Bugzilla_api_token};
my ($token_user_id, undef, undef, $token_type)
= Bugzilla::Token::GetTokenData($api_token);
Expand All @@ -74,6 +66,11 @@ sub get_login_info {
ThrowUserError('auth_invalid_token', { token => $api_token });
}
}
elsif ($login_cookie && Bugzilla->usage_mode == USAGE_MODE_REST) {
# REST requires an api-token when using cookie authentication
# fall back to a non-authenticated request
$login_cookie = '';
}
}
}

Expand Down

0 comments on commit 64df9b7

Please sign in to comment.