Commit 83874a6f authored by Lukasz Anforowicz's avatar Lukasz Anforowicz Committed by Commit Bot

Enforce presence of |request_initiator_site_lock| in renderer factories.

Thanks to an earlier CL (https://crrev.com/c/2274591), this CL can
modify CorsURLLoaderFactory::IsValidRequest to enforce the presence of
|request_initiator_site_lock| (see the mojo::ReportBadMessage call in
the InitiatorLockCompatibility::kNoLock case).  This is a big security
win - it means that the |request_initiator| can no longer be spoofed on
the Android platform (the CL modifies
//docs/security/compromised-renderers.md accordingly).

Bug: 1114906
Change-Id: I9e52ea33d8e929e31c1b4bfaf8fc85e5d2e185f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2347195
Commit-Queue: Łukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799116}
parent bbecd73e
...@@ -242,13 +242,20 @@ network::mojom::URLLoaderFactory* ChildURLLoaderFactoryBundle::GetFactory( ...@@ -242,13 +242,20 @@ network::mojom::URLLoaderFactory* ChildURLLoaderFactoryBundle::GetFactory(
// All renderer-initiated requests need to provide a value for // All renderer-initiated requests need to provide a value for
// |request_initiator| - this is enforced by // |request_initiator| - this is enforced by
// CorsURLLoaderFactory::IsValidRequest. // CorsURLLoaderFactory::IsValidRequest (see the
// InitiatorLockCompatibility::kNoInitiator case).
DCHECK(request.request_initiator.has_value()); DCHECK(request.request_initiator.has_value());
if (is_deprecated_process_wide_factory_ && if (is_deprecated_process_wide_factory_) {
!request.request_initiator->opaque()) { // The CHECK condition below (in a Renderer process) is also enforced later
NOTREACHED(); // (in the NetworkService process) by CorsURLLoaderFactory::IsValidRequest
ScopedRequestCrashKeys crash_keys(request); // (see the InitiatorLockCompatibility::kNoLock case) - this enforcement may
base::debug::DumpWithoutCrashing(); // result in a renderer kill when the NetworkService is hosted in a separate
// process from the Browser process. Despite the redundancy, we want to
// also have the CHECK below, so that the Renderer process terminates
// earlier, with a callstack that (unlike the NetworkService
// mojo::ReportBadMessage) is hopefully useful for tracking down the source
// of the problem.
CHECK(request.request_initiator->opaque());
} }
InitDirectNetworkFactoryIfNecessary(); InitDirectNetworkFactoryIfNecessary();
......
...@@ -381,10 +381,6 @@ below. ...@@ -381,10 +381,6 @@ below.
Some web storage protections depend on `CanAccessDataForOrigin` calls Some web storage protections depend on `CanAccessDataForOrigin` calls
on the IO thread. on the IO thread.
See also https://crbug.com/764958. See also https://crbug.com/764958.
- `request_initiator_site_lock` may be missing in unlocked renderer
processes on Android (for example affecting protections of CORB, CORP,
Sec-Fetch-Site and in the future SameSite cookies and Origin
protections). See also https://crbug.com/1114906.
## Renderer processes hosting DevTools frontend ## Renderer processes hosting DevTools frontend
......
...@@ -382,13 +382,13 @@ bool CorsURLLoaderFactory::IsValidRequest(const ResourceRequest& request, ...@@ -382,13 +382,13 @@ bool CorsURLLoaderFactory::IsValidRequest(const ResourceRequest& request,
break; break;
case InitiatorLockCompatibility::kNoLock: case InitiatorLockCompatibility::kNoLock:
// TODO(lukasza): https://crbug.com/1114906: Browser process should always // |request_initiator_site_lock| should always be set in a
// specify the request_initiator_site_lock in URLLoaderFactories given to // URLLoaderFactory vended to a renderer process. See also
// a renderer process. Once issues blocking https://crbug.com/1114906 are // https://crbug.com/1114906.
// fixed, the case below should return |false| and call
// mojo::ReportBadMessage.
NOTREACHED(); NOTREACHED();
break; mojo::ReportBadMessage(
"CorsURLLoaderFactory: no initiator lock in a renderer request");
return false;
case InitiatorLockCompatibility::kNoInitiator: case InitiatorLockCompatibility::kNoInitiator:
// Requests from the renderer need to always specify an initiator. // Requests from the renderer need to always specify an initiator.
......
...@@ -24,8 +24,8 @@ enum class InitiatorLockCompatibility { ...@@ -24,8 +24,8 @@ enum class InitiatorLockCompatibility {
// |request_initiator_site_lock| doesn't apply. // |request_initiator_site_lock| doesn't apply.
kBrowserProcess = 0, kBrowserProcess = 0,
// |request_initiator_site_lock| is missing - see https://crbug.com/1098938 // |request_initiator_site_lock| is missing. For historical context see
// and RenderProcessHostImpl::CreateURLLoaderFactoryForRendererProcess. // https://crbug.com/1098938.
kNoLock = 1, kNoLock = 1,
// |request_initiator| is missing. This indicates that the renderer has a bug // |request_initiator| is missing. This indicates that the renderer has a bug
......
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