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

Unified Diff: content/browser/frame_host/render_frame_host_impl.cc

Issue 2062523002: Fixing renderer's access to a file from HTTP POST (after a xsite transfer). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixing Windows build. Created 4 years, 6 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
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);
Charlie Reis 2016/06/16 20:18:00 Seems a bit unfortunate we have to do this twice,
Łukasz Anforowicz 2016/06/16 22:05:04 Yes. These 2 scenarios are also transferring the
Charlie Reis 2016/06/16 22:20:00 Ha! Sorry I missed it, and thanks! :)
- }
+
+ // 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() {

Powered by Google App Engine
This is Rietveld 408576698