]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1268989 - Inefficient check of "Bugzilla_api_token" might lead to CSRF/data discl...
authorDylan William Hardison <dylan@mozilla.com>
Tue, 3 May 2016 13:59:02 +0000 (13:59 +0000)
committerDylan William Hardison <dylan@hardison.net>
Wed, 4 May 2016 18:32:50 +0000 (14:32 -0400)
r=dkl

Bugzilla/Auth/Login/Cookie.pm

index b67fb73db4b0599ddcbd7423a7f24d84a65b9c7d..d8bf2f08f8c8ed04e1d1ba9414411b7e13ba55d8 100644 (file)
@@ -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);
@@ -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 = '';
+            }
         }
     }