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

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: Update comment 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 9fa9677b4fb48e5ff88842ea7e039a5f757dd04e..cdd32165c7af4eb85d41be6f54d4f3e3688f1d54 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -5667,12 +5667,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
+ // schemes. The exceptions are applied only to the special scheme 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