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

Unified Diff: net/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 net_unittests Created 6 years 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 side-by-side diff with in-line comments
Download patch
Index: net/http/proxy_client_socket.cc
diff --git a/net/http/proxy_client_socket.cc b/net/http/proxy_client_socket.cc
index dcfae037ce721c92bd95dfa3aeded77bd2f6bf62..1bbb7000173806460706f8751ff09d5c819312ba 100644
--- a/net/http/proxy_client_socket.cc
+++ b/net/http/proxy_client_socket.cc
@@ -72,22 +72,48 @@ void ProxyClientSocket::LogBlockedTunnelResponse(int http_status_code,
}
// static
-bool ProxyClientSocket::SanitizeProxyRedirect(HttpResponseInfo* response,
- const GURL& url) {
+bool ProxyClientSocket::SanitizeProxyAuth(HttpResponseInfo* response) {
+ DCHECK(response && response->headers.get());
+
+ const char* kHeaderName = "Proxy-Authenticate";
+ void* iter = NULL;
+ std::string auth, ignored;
+ // Make sure there is one Proxy-Authenticate header...
+ if (!response->headers->EnumerateHeader(&iter, kHeaderName, &auth))
+ return false;
+ // ...but not more than one.
Ryan Sleevi 2014/12/08 22:04:39 BUG: This is NOT required by the spec. Per RFC 723
+ if (response->headers->EnumerateHeader(&iter, kHeaderName, &ignored))
+ return false;
+
+ std::string fake_response_headers = base::StringPrintf(
+ "HTTP/1.1 407 Proxy Authentication Required\n"
+ "Proxy-Authenticate: %s\n"
+ "Content-Length: 0\n"
Ryan Hamilton 2014/12/08 22:51:59 Looks like the content-length should not be 0, sin
Deprecated (see juliatuttle) 2014/12/09 15:31:15 The goal was to avoid providing the response body,
Ryan Hamilton 2014/12/10 19:53:42 Oh! I'm sorry. I misread line 94 to be appending a
Deprecated (see juliatuttle) 2014/12/10 20:38:40 I've removed the content-length header entirely, s
+ "Connection: close\n"
Ryan Hamilton 2014/12/08 22:51:59 I'm not sure that you want to make this connection
Deprecated (see juliatuttle) 2014/12/09 15:31:15 Sigh, okay.
Deprecated (see juliatuttle) 2014/12/10 20:38:40 I've passed along Connection headers along with th
+ "\n",
+ auth.c_str());
+ std::string raw_headers = HttpUtil::AssembleRawHeaders(
+ fake_response_headers.data(), fake_response_headers.length());
+ response->headers = new HttpResponseHeaders(raw_headers);
+ return true;
+}
+
+// static
+bool ProxyClientSocket::SanitizeProxyRedirect(HttpResponseInfo* response) {
DCHECK(response && response->headers.get());
std::string location;
if (!response->headers->IsRedirect(&location))
return false;
- // Return minimal headers; set "Content-length: 0" to ignore response body.
- std::string fake_response_headers =
- base::StringPrintf("HTTP/1.0 302 Found\n"
- "Location: %s\n"
- "Content-length: 0\n"
- "Connection: close\n"
- "\n",
- location.c_str());
+ // Return minimal headers; set "Content-Length: 0" to ignore response body.
+ std::string fake_response_headers = base::StringPrintf(
+ "HTTP/1.1 302 Found\n"
Ryan Sleevi 2014/12/08 22:04:40 Note: While this may seem trivial, it's going to r
Ryan Hamilton 2014/12/08 22:53:48 From my reading, I think there are no required res
Deprecated (see juliatuttle) 2014/12/09 15:31:15 I can make them both 1.0, but that would break kee
+ "Location: %s\n"
+ "Content-Length: 0\n"
+ "Connection: close\n"
+ "\n",
+ location.c_str());
std::string raw_headers =
HttpUtil::AssembleRawHeaders(fake_response_headers.data(),
fake_response_headers.length());

Powered by Google App Engine
This is Rietveld 408576698