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

Unified Diff: content/child/web_url_loader_impl.cc

Issue 1017583002: Set Origin header to "null" for cross origin redirects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Addressed nits Created 5 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/data/url_request_unittest/redirect301-to-ftp » ('j') | net/url_request/url_request.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/web_url_loader_impl.cc
diff --git a/content/child/web_url_loader_impl.cc b/content/child/web_url_loader_impl.cc
index e2cec70d33531e72ea4eb4d3a7a83f4120a9b233..01fad1ccb2059af11645499b2409b51a1af5a1d1 100644
--- a/content/child/web_url_loader_impl.cc
+++ b/content/child/web_url_loader_impl.cc
@@ -34,11 +34,13 @@
#include "net/base/filename_util.h"
#include "net/base/mime_util.h"
#include "net/base/net_errors.h"
+#include "net/http/http_request_headers.h"
#include "net/http/http_response_headers.h"
#include "net/http/http_util.h"
#include "net/url_request/redirect_info.h"
#include "net/url_request/url_request_data_job.h"
#include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h"
+#include "third_party/WebKit/public/platform/WebString.h"
#include "third_party/WebKit/public/platform/WebURL.h"
#include "third_party/WebKit/public/platform/WebURLError.h"
#include "third_party/WebKit/public/platform/WebURLLoadTiming.h"
@@ -562,6 +564,14 @@ bool WebURLLoaderImpl::Context::OnReceivedRedirect(
if (redirect_info.new_method == old_method)
new_request.setHTTPBody(request_.httpBody());
+ // This is necessary to avoid laundering the Origin header across redirects,
+ // which would break some CSRF protections. See the comment in
+ // URLRequest::Redirect in //net/url_request.cc for more information.
+ WebString origin_header =
+ WebString::fromUTF8(net::HttpRequestHeaders::kOrigin);
+ new_request.setHTTPHeaderField(origin_header,
+ request_.httpHeaderField(origin_header));
davidben 2015/03/24 23:47:38 I think this does the opposite of what the comment
jww 2015/03/27 22:16:15 Hm, okay, I'm happy to remove it. All of the tests
davidben 2015/03/27 22:46:51 Well, the cases where Blink's version of the reque
+
// Protect from deletion during call to willSendRequest.
scoped_refptr<Context> protect(this);
« no previous file with comments | « no previous file | net/data/url_request_unittest/redirect301-to-ftp » ('j') | net/url_request/url_request.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698