]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 1269236 - Incorrect checking of API tokens possibly leads to CSRF and data disclo...
authorDylan Hardison <dylan@mozilla.com>
Tue, 3 May 2016 13:30:48 +0000 (09:30 -0400)
committerDylan Hardison <dylan@mozilla.com>
Tue, 3 May 2016 13:30:59 +0000 (09:30 -0400)
Bugzilla/Auth/Login/Cookie.pm

index 0b5842523d71dba6bd4ef06324c90a71a541655d..0a2386ee95d302ad0598dbe9c8c423febf96e458 100644 (file)
@@ -64,15 +64,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);
@@ -84,6 +76,11 @@ sub get_login_info {
                 }
                 $is_internal = 1;
             }
+            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 = '';
+            }
         }
     }