Status: Untriaged
Owner: [email protected]
CC: [email protected]
Labels: Type-Bug Pri-2 OS-All Area-BrowserBackend Size-Medium

New issue 21050 by [email protected]: Infinite auth restart loop if  
HttpAuthHandler::GenerateCredentials fails (returns an empty string).
http://code.google.com/p/chromium/issues/detail?id=21050

In HttpNetworkTransaction::BuildAuthorizationHeader, we
call auth_handler_[target]->GenerateCredentials() to generate
the credentials for the authorization header:

   // Add a Authorization/Proxy-Authorization header line.
   std::string credentials = auth_handler_[target]->GenerateCredentials(
       auth_identity_[target].username,
       auth_identity_[target].password,
       request_,
       &proxy_info_);

   return HttpAuth::GetAuthorizationHeaderName(target) +
       ": "  + credentials + "\r\n";

If auth_handler_[target]->GenerateCredentials() fails and returns
an empty string for some reason, we get into an infinite auth
restart loop because we will sent a "Authorization: " header
to the server, and the server will respond with a 401, and the
process repeats.

A band-aid fix is to impose a limit on the maximum number
of auth restarts an HttpNetworkTransaction object can do.
I think we should do this anyway to limit the damage of any
problems that may cause an infinite auth restart loop.

A fix for this particular problem is to make BuildAuthorizationHeader
return a bool to indicate success/failure, and if it fails,
HttpNetworkTransaction::DoWriteHeaders should fail and not go
on to STATE_WRITE_HEADERS_COMPLETE.  This quick-and-dirty patch
for http_network_transaction.cc illustrates this solution:

Index: http_network_transaction.cc
===================================================================
--- http_network_transaction.cc (revision 24904)
+++ http_network_transaction.cc (working copy)
@@ -744,9 +747,12 @@
      if (have_proxy_auth)
        authorization_headers.append(
            BuildAuthorizationHeader(HttpAuth::AUTH_PROXY));
-    if (have_server_auth)
+    if (have_server_auth) {
        authorization_headers.append(
            BuildAuthorizationHeader(HttpAuth::AUTH_SERVER));
+      if (authorization_headers == "Authorization: \r\n")
+        return ERR_UNEXPECTED;  // TODO(wtc): use a better error code.
+    }

      if (establishing_tunnel_) {
        BuildTunnelRequest(request_, authorization_headers,

--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

--~--~---------~--~----~------------~-------~--~----~
Automated mail from issue updates at http://crbug.com/
Subscription options: http://groups.google.com/group/chromium-bugs
-~----------~----~----~----~------~----~------~--~---

Reply via email to