Commit 64df9b75 authored by Dylan William Hardison's avatar Dylan William Hardison Committed by David Lawrence

Bug 1268989 - Inefficient check of "Bugzilla_api_token" might lead to CSRF/data…

Bug 1268989 - Inefficient check of "Bugzilla_api_token" might lead to CSRF/data disclosure vulnerability in Bugzilla's REST API r=dkl
parent c3b2af3a
...@@ -55,15 +55,7 @@ sub get_login_info { ...@@ -55,15 +55,7 @@ sub get_login_info {
# If the call is for a web service, and an api token is provided, check # If the call is for a web service, and an api token is provided, check
# it is valid. # it is valid.
if (i_am_webservice()) { if (i_am_webservice()) {
if ($login_cookie if (exists Bugzilla->input_params->{Bugzilla_api_token}) {
&& 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}) {
my $api_token = Bugzilla->input_params->{Bugzilla_api_token}; my $api_token = Bugzilla->input_params->{Bugzilla_api_token};
my ($token_user_id, undef, undef, $token_type) my ($token_user_id, undef, undef, $token_type)
= Bugzilla::Token::GetTokenData($api_token); = Bugzilla::Token::GetTokenData($api_token);
...@@ -74,6 +66,11 @@ sub get_login_info { ...@@ -74,6 +66,11 @@ sub get_login_info {
ThrowUserError('auth_invalid_token', { token => $api_token }); 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 = '';
}
} }
} }
......
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