diff --git a/actionpack/lib/action_controller/metal/http_authentication.rb b/actionpack/lib/action_controller/metal/http_authentication.rb index e0ff01e9ec..a9b7eb896c 100644 --- a/actionpack/lib/action_controller/metal/http_authentication.rb +++ b/actionpack/lib/action_controller/metal/http_authentication.rb @@ -76,6 +76,8 @@ module ActionController def http_basic_authenticate_or_request_with(name:, password:, realm: nil, message: nil) authenticate_or_request_with_http_basic(realm, message) do |given_name, given_password| + # This comparison uses & so that it doesn't short circuit and + # uses `secure_compare` so that length information isn't leaked. ActiveSupport::SecurityUtils.secure_compare(given_name, name) & ActiveSupport::SecurityUtils.secure_compare(given_password, password) end