Index: content/browser/frame_host/render_frame_host_impl.cc |
diff --git a/content/browser/frame_host/render_frame_host_impl.cc b/content/browser/frame_host/render_frame_host_impl.cc |
index 3855d7ee223446aa05e556519fe12961131e149a..3d9fcdddaf1ec5f164a5e9dd3c1a9356f086c334 100644 |
--- a/content/browser/frame_host/render_frame_host_impl.cc |
+++ b/content/browser/frame_host/render_frame_host_impl.cc |
@@ -2757,6 +2757,18 @@ void RenderFrameHostImpl::DidUseGeolocationPermission() { |
->last_committed_url().GetOrigin()); |
} |
+void RenderFrameHostImpl::GrantFileAccessFromResourceRequestBody( |
+ const ResourceRequestBody& body) { |
+ ChildProcessSecurityPolicyImpl* policy = |
+ ChildProcessSecurityPolicyImpl::GetInstance(); |
+ |
+ std::vector<base::FilePath> file_paths = body.GetReferencedFiles(); |
+ for (const auto& file : file_paths) { |
+ if (!policy->CanReadFile(GetProcess()->GetID(), file)) |
+ policy->GrantReadFile(GetProcess()->GetID(), file); |
+ } |
+} |
+ |
void RenderFrameHostImpl::UpdatePermissionsForNavigation( |
const CommonNavigationParams& common_params, |
const RequestNavigationParams& request_params) { |
@@ -2776,11 +2788,20 @@ void RenderFrameHostImpl::UpdatePermissionsForNavigation( |
// We may be returning to an existing NavigationEntry that had been granted |
// file access. If this is a different process, we will need to grant the |
- // access again. The files listed in the page state are validated when they |
- // are received from the renderer to prevent abuse. |
- if (request_params.page_state.IsValid()) { |
+ // access again. Abuse is prevented, because the files listed in the page |
+ // state are validated earlier, when they are received from the renderer (in |
+ // RenderFrameHostImpl::CanAccessFilesOfPageState). |
+ if (request_params.page_state.IsValid()) |
render_view_host_->GrantFileAccessFromPageState(request_params.page_state); |
- } |
+ |
+ // We may be here after transferring navigation to different renderer process. |
+ // In this case, we need to ensure that the new renderer retains ability to |
+ // access files that the old renderer could access. Abuse is prevented, |
+ // because the files listed in ResourceRequestBody are validated earlier, when |
+ // they are recieved by the renderer (in |
+ // ResourceDispatcherHostImpl::BeginRequest). |
+ if (common_params.post_data) |
+ GrantFileAccessFromResourceRequestBody(*common_params.post_data); |
} |
bool RenderFrameHostImpl::CanExecuteJavaScript() { |