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

Unified Diff: content/browser/loader/resource_dispatcher_host_impl.cc

Issue 2075273002: Resource requests from Save-Page-As should go through CanRequestURL checks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Replace MarkAsUnauthorized with constructor argument. Created 4 years, 5 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 | « content/browser/download/save_types.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
}
« no previous file with comments | « content/browser/download/save_types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698