Index: content/browser/loader/resource_dispatcher_host_impl.cc |
diff --git a/content/browser/loader/resource_dispatcher_host_impl.cc b/content/browser/loader/resource_dispatcher_host_impl.cc |
index d2d0bc1b9e5bfc3cb0b78e5ffbf2ac3215cc6c1a..bc591bd3faf1baf67ab328962689cee757874115 100644 |
--- a/content/browser/loader/resource_dispatcher_host_impl.cc |
+++ b/content/browser/loader/resource_dispatcher_host_impl.cc |
@@ -1887,9 +1887,22 @@ void ResourceDispatcherHostImpl::BeginSaveFile(const GURL& url, |
render_frame_route_id, false, context); |
extra_info->AssociateWithRequest(request.get()); // Request takes ownership. |
- std::unique_ptr<ResourceHandler> handler(new SaveFileResourceHandler( |
+ // Check if the renderer is permitted to request the requested URL. |
+ using AuthorizationState = SaveFileResourceHandler::AuthorizationState; |
+ AuthorizationState authorization_state = AuthorizationState::AUTHORIZED; |
+ if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL(child_id, |
+ url)) { |
+ DVLOG(1) << "Denying unauthorized save of " << url.possibly_invalid_spec(); |
+ authorization_state = AuthorizationState::NOT_AUTHORIZED; |
+ // No need to return here (i.e. okay to begin processing the request below), |
+ // because NOT_AUTHORIZED will cause the request to be cancelled. See also |
+ // doc comments for AuthorizationState enum. |
+ } |
+ |
+ std::unique_ptr<SaveFileResourceHandler> handler(new SaveFileResourceHandler( |
request.get(), save_item_id, save_package_id, child_id, |
- render_frame_route_id, url, save_file_manager_.get())); |
+ render_frame_route_id, url, save_file_manager_.get(), |
+ authorization_state)); |
BeginRequestInternal(std::move(request), std::move(handler)); |
} |