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

Unified Diff: content/browser/service_worker/service_worker_version.cc

Issue 980383004: Relax same-origin policy for ServiceWorker openWindow() in Chromium. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 9 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_version.cc
diff --git a/content/browser/service_worker/service_worker_version.cc b/content/browser/service_worker/service_worker_version.cc
index 22c6c8ec10ae7bd8bd53116edc04885d2dd463d8..f02e26f22ccf5119ba654f0f7bf525afadabfcf5 100644
--- a/content/browser/service_worker/service_worker_version.cc
+++ b/content/browser/service_worker/service_worker_version.cc
@@ -11,6 +11,7 @@
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "base/time/time.h"
+#include "content/browser/child_process_security_policy_impl.h"
#include "content/browser/message_port_message_filter.h"
#include "content/browser/message_port_service.h"
#include "content/browser/service_worker/embedded_worker_instance.h"
@@ -271,15 +272,6 @@ void OpenWindowOnUI(
base::Bind(&DidOpenURL, callback));
}
-void KillEmbeddedWorkerProcess(int process_id, ResultCode code) {
- DCHECK_CURRENTLY_ON(BrowserThread::UI);
-
- RenderProcessHost* render_process_host =
- RenderProcessHost::FromID(process_id);
- if (render_process_host->GetHandle() != base::kNullProcessHandle)
- render_process_host->ReceivedBadMessage();
-}
-
void ClearTick(base::TimeTicks* time) {
*time = base::TimeTicks();
}
@@ -1171,22 +1163,26 @@ void ServiceWorkerVersion::OnOpenWindow(int request_id, const GURL& url) {
if (!context_)
return;
- if (url.GetOrigin() != script_url_.GetOrigin()) {
- // There should be a same origin check by Blink, if the request is still not
- // same origin, the process might be compromised and should be eliminated.
- DVLOG(1) << "Received a cross origin openWindow() request from a service "
- "worker. Killing associated process.";
- BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
- base::Bind(&KillEmbeddedWorkerProcess,
- embedded_worker_->process_id(),
- RESULT_CODE_KILLED_BAD_MESSAGE));
- return;
+ GURL sanitized_url = url;
+
+ // Blink consider all about: scheme URLs as about:blank. We need to sanitize
+ // them accordingly to prevent CanRequestURL() call below to fail on them.
+ if (sanitized_url.SchemeIs(url::kAboutScheme))
+ sanitized_url = GURL(url::kAboutBlankURL);
+
+ // This call will check whether the process should be able to access the given
+ // URL. It is possible to receive requests to open such URLs because the
+ // renderer side checks are slightly different. For example, view-source
+ // scheme will not be filtered out by Blink.
+ if (!ChildProcessSecurityPolicyImpl::GetInstance()->CanRequestURL(
+ embedded_worker_->process_id(), sanitized_url)) {
+ sanitized_url = GURL(url::kAboutBlankURL);
michaeln 2015/03/06 23:26:03 Are you sure about opening about:blank in this cas
mlamouri (slow - plz ping) 2015/03/06 23:40:40 Just to make sure it's clear: the CanRequestURL()
}
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&OpenWindowOnUI,
- url,
+ sanitized_url,
script_url_,
embedded_worker_->process_id(),
make_scoped_refptr(context_->wrapper()),
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698