Commit 55f2fbeb authored by Dominic Farolino's avatar Dominic Farolino Committed by Commit Bot

Catch incorrect referrer at network::ResourceRequest serialization

This CL moves logic from NetworkServiceNetworkDelegate that performs a
DumpWithoutCrash() on incorrect referrer detection, to where
serialization of a network::ResourceRequest is performed before being
passed to the network service. This is a temporary migration to aid in
debugging long-standing referrer mismatches (crbug.com/912680) as well
as recently-introduced referrer mismatches (crbug.com/1020592).

Bug: 912680,1020592
Change-Id: Id6d7db1c7105bd86f125004868a49beea8c2c3a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1896251Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarMatt Menke <mmenke@chromium.org>
Reviewed-by: default avatarYutaka Hirano <yhirano@chromium.org>
Commit-Queue: Dominic Farolino <dom@chromium.org>
Cr-Commit-Position: refs/heads/master@{#712487}
parent 4488f10c
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <string> #include <string>
#include "base/bind.h" #include "base/bind.h"
#include "base/debug/dump_without_crashing.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "components/domain_reliability/monitor.h" #include "components/domain_reliability/monitor.h"
...@@ -272,14 +271,6 @@ bool NetworkServiceNetworkDelegate:: ...@@ -272,14 +271,6 @@ bool NetworkServiceNetworkDelegate::
LOG(ERROR) << "Cancelling request to " << target_url LOG(ERROR) << "Cancelling request to " << target_url
<< " with invalid referrer " << referrer_url; << " with invalid referrer " << referrer_url;
// Record information to help debug issues like http://crbug.com/422871.
if (target_url.SchemeIsHTTPOrHTTPS()) {
auto referrer_policy = request.referrer_policy();
base::debug::Alias(&referrer_policy);
DEBUG_ALIAS_FOR_GURL(target_buf, target_url);
DEBUG_ALIAS_FOR_GURL(referrer_buf, referrer_url);
base::debug::DumpWithoutCrashing();
}
return true; return true;
} }
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <utility> #include <utility>
#include "base/component_export.h" #include "base/component_export.h"
#include "base/debug/dump_without_crashing.h"
#include "base/memory/scoped_refptr.h" #include "base/memory/scoped_refptr.h"
#include "mojo/public/cpp/base/file_mojom_traits.h" #include "mojo/public/cpp/base/file_mojom_traits.h"
#include "mojo/public/cpp/base/file_path_mojom_traits.h" #include "mojo/public/cpp/base/file_path_mojom_traits.h"
...@@ -17,6 +18,7 @@ ...@@ -17,6 +18,7 @@
#include "mojo/public/cpp/bindings/pending_remote.h" #include "mojo/public/cpp/bindings/pending_remote.h"
#include "mojo/public/cpp/bindings/struct_traits.h" #include "mojo/public/cpp/bindings/struct_traits.h"
#include "net/base/request_priority.h" #include "net/base/request_priority.h"
#include "net/url_request/url_request_job.h"
#include "services/network/public/cpp/data_element.h" #include "services/network/public/cpp/data_element.h"
#include "services/network/public/cpp/network_isolation_key_mojom_traits.h" #include "services/network/public/cpp/network_isolation_key_mojom_traits.h"
#include "services/network/public/cpp/resource_request.h" #include "services/network/public/cpp/resource_request.h"
...@@ -96,6 +98,22 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE) ...@@ -96,6 +98,22 @@ struct COMPONENT_EXPORT(NETWORK_CPP_BASE)
return request.isolated_world_origin; return request.isolated_world_origin;
} }
static const GURL& referrer(const network::ResourceRequest& request) { static const GURL& referrer(const network::ResourceRequest& request) {
// TODO(crbug.com/912680, crbug.com/1020592): Move this back to
// NetworkServiceNetworkDelegate when the current cause of referrer
// mismatches is found.
if (request.referrer != net::URLRequestJob::ComputeReferrerForPolicy(
request.referrer_policy, request.referrer,
request.request_initiator, request.url)) {
// Record information to help debug issues like http://crbug.com/422871.
if (request.url.SchemeIsHTTPOrHTTPS()) {
auto referrer_policy = request.referrer_policy;
base::debug::Alias(&referrer_policy);
DEBUG_ALIAS_FOR_GURL(target_buf, request.url);
DEBUG_ALIAS_FOR_GURL(referrer_buf, request.referrer);
base::debug::DumpWithoutCrashing();
}
}
return request.referrer; return request.referrer;
} }
static net::URLRequest::ReferrerPolicy referrer_policy( static net::URLRequest::ReferrerPolicy referrer_policy(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment