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

Unified Diff: content/browser/child_process_security_policy_impl.cc

Issue 2908433003: RenderFrameProxyHost::OnOpenURL needs to validate resource request body. (Closed)
Patch Set: Rebasing... Created 3 years, 7 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/child_process_security_policy_impl.cc
diff --git a/content/browser/child_process_security_policy_impl.cc b/content/browser/child_process_security_policy_impl.cc
index 28ce45ad809ad34567726a34478ff43627bf5f67..9c0c21cab98257e34919624176442710568b5620 100644
--- a/content/browser/child_process_security_policy_impl.cc
+++ b/content/browser/child_process_security_policy_impl.cc
@@ -17,15 +17,20 @@
#include "base/strings/string_util.h"
#include "build/build_config.h"
#include "content/browser/site_instance_impl.h"
+#include "content/common/resource_request_body_impl.h"
#include "content/common/site_isolation_policy.h"
+#include "content/public/browser/browser_context.h"
+#include "content/public/browser/browser_thread.h"
#include "content/public/browser/child_process_data.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/render_process_host.h"
+#include "content/public/browser/storage_partition.h"
#include "content/public/common/bindings_policy.h"
#include "content/public/common/url_constants.h"
#include "net/base/filename_util.h"
#include "net/url_request/url_request.h"
#include "storage/browser/fileapi/file_permission_policy.h"
+#include "storage/browser/fileapi/file_system_context.h"
#include "storage/browser/fileapi/file_system_url.h"
#include "storage/browser/fileapi/isolated_context.h"
#include "storage/common/fileapi/file_system_util.h"
@@ -744,6 +749,68 @@ bool ChildProcessSecurityPolicyImpl::CanReadAllFiles(
});
}
+bool ChildProcessSecurityPolicyImpl::CanReadRequestBody(
+ int child_id,
+ const storage::FileSystemContext* file_system_context,
+ const scoped_refptr<ResourceRequestBodyImpl>& body) {
+ if (!body)
+ return true;
+
+ for (const ResourceRequestBodyImpl::Element& element : *body->elements()) {
+ switch (element.type()) {
+ case ResourceRequestBodyImpl::Element::TYPE_FILE:
+ if (!CanReadFile(child_id, element.path()))
+ return false;
+ break;
+
+ case ResourceRequestBodyImpl::Element::TYPE_FILE_FILESYSTEM:
+ if (!CanReadFileSystemFile(child_id, file_system_context->CrackURL(
+ element.filesystem_url())))
+ return false;
+ break;
+
+ case ResourceRequestBodyImpl::Element::TYPE_DISK_CACHE_ENTRY:
+ // TYPE_DISK_CACHE_ENTRY can't be sent via IPC according to
+ // content/common/resource_messages.cc
+ NOTREACHED();
+ return false;
+
+ case ResourceRequestBodyImpl::Element::TYPE_BYTES:
+ case ResourceRequestBodyImpl::Element::TYPE_BYTES_DESCRIPTION:
+ // Data is self-contained within |body| - no need to check access.
+ break;
+
+ case ResourceRequestBodyImpl::Element::TYPE_BLOB:
+ // No need to validate - the unguessability of the uuid of the blob is a
+ // sufficient defense against access from an unrelated renderer.
+ break;
+
+ case ResourceRequestBodyImpl::Element::TYPE_UNKNOWN:
+ default:
+ // Fail safe - deny access.
+ NOTREACHED();
+ return false;
+ }
+ }
+ return true;
+}
+
+bool ChildProcessSecurityPolicyImpl::CanReadRequestBody(
+ SiteInstance* site_instance,
+ const scoped_refptr<ResourceRequestBodyImpl>& body) {
+ DCHECK(site_instance);
+ DCHECK_CURRENTLY_ON(BrowserThread::UI);
+
+ int child_id = site_instance->GetProcess()->GetID();
+
+ StoragePartition* storage_partition = BrowserContext::GetStoragePartition(
+ site_instance->GetBrowserContext(), site_instance);
+ const storage::FileSystemContext* file_system_context =
+ storage_partition->GetFileSystemContext();
+
+ return CanReadRequestBody(child_id, file_system_context, body);
+}
+
bool ChildProcessSecurityPolicyImpl::CanCreateReadWriteFile(
int child_id,
const base::FilePath& file) {
« no previous file with comments | « content/browser/child_process_security_policy_impl.h ('k') | content/browser/cross_site_transfer_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698