Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: net/http/http_proxy_client_socket.cc

Issue 769043003: Sanitize headers in Proxy Authentication Required responses (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix sleevi's nit Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/proxy_client_socket.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_proxy_client_socket.h" 5 #include "net/http/http_proxy_client_socket.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/strings/stringprintf.h" 10 #include "base/strings/stringprintf.h"
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 // attacker can force us into this state by masquerading as the proxy. 476 // attacker can force us into this state by masquerading as the proxy.
477 // The only safe thing to do here is to fail the connection because our 477 // The only safe thing to do here is to fail the connection because our
478 // client is expecting an SSL protected response. 478 // client is expecting an SSL protected response.
479 // See http://crbug.com/7338. 479 // See http://crbug.com/7338.
480 480
481 case 302: // Found / Moved Temporarily 481 case 302: // Found / Moved Temporarily
482 // Attempt to follow redirects from HTTPS proxies, but only if we can 482 // Attempt to follow redirects from HTTPS proxies, but only if we can
483 // sanitize the response. This still allows a rogue HTTPS proxy to 483 // sanitize the response. This still allows a rogue HTTPS proxy to
484 // redirect an HTTPS site load to a similar-looking site, but no longer 484 // redirect an HTTPS site load to a similar-looking site, but no longer
485 // allows it to impersonate the site the user requested. 485 // allows it to impersonate the site the user requested.
486 if (is_https_proxy_ && SanitizeProxyRedirect(&response_, request_.url)) { 486 if (!is_https_proxy_ || !SanitizeProxyRedirect(&response_)) {
487 bool is_connection_reused = http_stream_parser_->IsConnectionReused(); 487 LogBlockedTunnelResponse();
488 redirect_has_load_timing_info_ = 488 return ERR_TUNNEL_CONNECTION_FAILED;
489 transport_->GetLoadTimingInfo(
490 is_connection_reused, &redirect_load_timing_info_);
491 transport_.reset();
492 http_stream_parser_.reset();
493 return ERR_HTTPS_PROXY_TUNNEL_RESPONSE;
494 } 489 }
495 490
496 // We're not using an HTTPS proxy, or we couldn't sanitize the redirect. 491 redirect_has_load_timing_info_ = transport_->GetLoadTimingInfo(
497 LogBlockedTunnelResponse(); 492 http_stream_parser_->IsConnectionReused(),
498 return ERR_TUNNEL_CONNECTION_FAILED; 493 &redirect_load_timing_info_);
494 transport_.reset();
495 http_stream_parser_.reset();
496 return ERR_HTTPS_PROXY_TUNNEL_RESPONSE;
499 497
500 case 407: // Proxy Authentication Required 498 case 407: // Proxy Authentication Required
501 // We need this status code to allow proxy authentication. Our 499 // We need this status code to allow proxy authentication. Our
502 // authentication code is smart enough to avoid being tricked by an 500 // authentication code is smart enough to avoid being tricked by an
503 // active network attacker. 501 // active network attacker.
504 // The next state is intentionally not set as it should be STATE_NONE; 502 // The next state is intentionally not set as it should be STATE_NONE;
503 if (!SanitizeProxyAuth(&response_)) {
504 LogBlockedTunnelResponse();
505 return ERR_TUNNEL_CONNECTION_FAILED;
506 }
505 return HandleProxyAuthChallenge(auth_.get(), &response_, net_log_); 507 return HandleProxyAuthChallenge(auth_.get(), &response_, net_log_);
506 508
507 default: 509 default:
508 // Ignore response to avoid letting the proxy impersonate the target 510 // Ignore response to avoid letting the proxy impersonate the target
509 // server. (See http://crbug.com/137891.) 511 // server. (See http://crbug.com/137891.)
510 // We lose something by doing this. We have seen proxy 403, 404, and 512 // We lose something by doing this. We have seen proxy 403, 404, and
511 // 501 response bodies that contain a useful error message. For 513 // 501 response bodies that contain a useful error message. For
512 // example, Squid uses a 404 response to report the DNS error: "The 514 // example, Squid uses a 404 response to report the DNS error: "The
513 // domain name does not exist." 515 // domain name does not exist."
514 LogBlockedTunnelResponse(); 516 LogBlockedTunnelResponse();
(...skipping 29 matching lines...) Expand all
544 546
545 int HttpProxyClientSocket::DoTCPRestartComplete(int result) { 547 int HttpProxyClientSocket::DoTCPRestartComplete(int result) {
546 if (result != OK) 548 if (result != OK)
547 return result; 549 return result;
548 550
549 next_state_ = STATE_GENERATE_AUTH_TOKEN; 551 next_state_ = STATE_GENERATE_AUTH_TOKEN;
550 return result; 552 return result;
551 } 553 }
552 554
553 } // namespace net 555 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_network_transaction_unittest.cc ('k') | net/http/proxy_client_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698