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

Unified Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 1383483007: Add scheme exceptions for isSecureContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: Fixes Created 5 years, 2 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: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index f0573887629fc669ea47dfd44cdb3d1389c40f38..4dd6e6b710bbd5e33052e0869f6280e68611bfe6 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -5656,12 +5656,45 @@ v8::Local<v8::Object> Document::associateWithWrapper(v8::Isolate* isolate, const
bool Document::isSecureContext(String& errorMessage, const SecureContextCheck privilegeContextCheck) const
{
+ // There may be exceptions for the secure context check defined for certain
+ // origins. The exceptions are applied only to the origin themselves and to
+ // sandboxed URLs from those origins, but *not* to any children.
+ //
+ // For example:
+ // <iframe src="http://host">
+ // <iframe src="scheme-has-exception://host"></iframe>
+ // <iframe sandbox src="scheme-has-exception://host"></iframe>
+ // </iframe>
+ // both inner iframes pass this check, assuming that the scheme
+ // "scheme-has-exception:" is granted an exception.
+ //
+ // However,
+ // <iframe src="http://host">
+ // <iframe sandbox src="http://host"></iframe>
+ // </iframe>
+ // would fail the check (that is, sandbox does not grant an exception itself).
+ //
+ // Additionally, with
+ // <iframe src="scheme-has-exception://host">
+ // <iframe src="http://host"></iframe>
+ // <iframe sandbox src="http://host"></iframe>
+ // </iframe>
+ // both inner iframes would fail the check, even though the outermost iframe
+ // passes.
+ //
+ // In all cases, a frame must be potentially trustworthy in addition to
+ // having an exception listed in order for the exception to be granted.
if (SecurityContext::isSandboxed(SandboxOrigin)) {
- if (!SecurityOrigin::create(url())->isPotentiallyTrustworthy(errorMessage))
+ RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url());
+ if (!origin->isPotentiallyTrustworthy(errorMessage))
return false;
+ if (SchemeRegistry::schemeShouldBypassSecureContextCheck(origin->protocol()))
+ return true;
} else {
if (!securityOrigin()->isPotentiallyTrustworthy(errorMessage))
return false;
+ if (SchemeRegistry::schemeShouldBypassSecureContextCheck(securityOrigin()->protocol()))
+ return true;
}
if (privilegeContextCheck == StandardSecureContextCheck) {

Powered by Google App Engine
This is Rietveld 408576698