OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) | 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) |
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. | 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r
ights reserved. |
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) | 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t
orchmobile.com/) |
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. | 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. |
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) | 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) |
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. |
(...skipping 3407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3418 // Additionally, with | 3418 // Additionally, with |
3419 // <iframe src="scheme-has-exception://host"> | 3419 // <iframe src="scheme-has-exception://host"> |
3420 // <iframe src="http://host"></iframe> | 3420 // <iframe src="http://host"></iframe> |
3421 // <iframe sandbox src="http://host"></iframe> | 3421 // <iframe sandbox src="http://host"></iframe> |
3422 // </iframe> | 3422 // </iframe> |
3423 // both inner iframes would fail the check, even though the outermost iframe | 3423 // both inner iframes would fail the check, even though the outermost iframe |
3424 // passes. | 3424 // passes. |
3425 // | 3425 // |
3426 // In all cases, a frame must be potentially trustworthy in addition to | 3426 // In all cases, a frame must be potentially trustworthy in addition to |
3427 // having an exception listed in order for the exception to be granted. | 3427 // having an exception listed in order for the exception to be granted. |
3428 if (SecurityContext::isSandboxed(SandboxOrigin)) { | 3428 if (!isOriginPotentiallyTrustworthy(getSecurityOrigin(), errorMessage)) |
3429 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url()); | 3429 return false; |
3430 if (!isOriginPotentiallyTrustworthy(origin.get(), errorMessage)) | 3430 |
3431 return false; | 3431 if (SchemeRegistry::schemeShouldBypassSecureContextCheck(getSecurityOrigin()
->protocol())) |
3432 if (SchemeRegistry::schemeShouldBypassSecureContextCheck(origin->protoco
l())) | 3432 return true; |
3433 return true; | |
3434 } else { | |
3435 if (!isOriginPotentiallyTrustworthy(getSecurityOrigin(), errorMessage)) | |
3436 return false; | |
3437 if (SchemeRegistry::schemeShouldBypassSecureContextCheck(getSecurityOrig
in()->protocol())) | |
3438 return true; | |
3439 } | |
3440 | 3433 |
3441 if (privilegeContextCheck == StandardSecureContextCheck) { | 3434 if (privilegeContextCheck == StandardSecureContextCheck) { |
3442 Document* context = parentDocument(); | 3435 if (!m_frame) |
3443 while (context) { | 3436 return true; |
3444 // Skip to the next ancestor if it's a srcdoc. | 3437 Frame* parent = m_frame->tree().parent(); |
3445 if (!context->isSrcdocDocument()) { | 3438 while (parent) { |
3446 if (context->securityContext().isSandboxed(SandboxOrigin)) { | 3439 if (!isOriginPotentiallyTrustworthy(parent->securityContext()->getSe
curityOrigin(), errorMessage)) |
3447 // For a sandboxed origin, use the document's URL. | 3440 return false; |
3448 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(conte
xt->url()); | 3441 parent = parent->tree().parent(); |
3449 if (!isOriginPotentiallyTrustworthy(origin.get(), errorMessa
ge)) | |
3450 return false; | |
3451 } else { | |
3452 if (!isOriginPotentiallyTrustworthy(context->getSecurityOrig
in(), errorMessage)) | |
3453 return false; | |
3454 } | |
3455 } | |
3456 context = context->parentDocument(); | |
3457 } | 3442 } |
3458 } | 3443 } |
3459 return true; | 3444 return true; |
3460 } | 3445 } |
3461 | 3446 |
3462 StyleSheetList* Document::styleSheets() | 3447 StyleSheetList* Document::styleSheets() |
3463 { | 3448 { |
3464 if (!m_styleSheetList) | 3449 if (!m_styleSheetList) |
3465 m_styleSheetList = StyleSheetList::create(this); | 3450 m_styleSheetList = StyleSheetList::create(this); |
3466 return m_styleSheetList.get(); | 3451 return m_styleSheetList.get(); |
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4973 enforceStrictMixedContentChecking(); | 4958 enforceStrictMixedContentChecking(); |
4974 setInsecureRequestsPolicy(initializer.getInsecureRequestsPolicy()); | 4959 setInsecureRequestsPolicy(initializer.getInsecureRequestsPolicy()); |
4975 if (initializer.insecureNavigationsToUpgrade()) { | 4960 if (initializer.insecureNavigationsToUpgrade()) { |
4976 for (auto toUpgrade : *initializer.insecureNavigationsToUpgrade()) | 4961 for (auto toUpgrade : *initializer.insecureNavigationsToUpgrade()) |
4977 addInsecureNavigationUpgrade(toUpgrade); | 4962 addInsecureNavigationUpgrade(toUpgrade); |
4978 } | 4963 } |
4979 | 4964 |
4980 if (isSandboxed(SandboxOrigin)) { | 4965 if (isSandboxed(SandboxOrigin)) { |
4981 m_cookieURL = m_url; | 4966 m_cookieURL = m_url; |
4982 setSecurityOrigin(SecurityOrigin::createUnique()); | 4967 setSecurityOrigin(SecurityOrigin::createUnique()); |
4983 // If we're supposed to inherit our security origin from our owner, | 4968 // If we're supposed to inherit our security origin from our |
4984 // but we're also sandboxed, the only thing we inherit is the ability | 4969 // owner, but we're also sandboxed, the only things we inherit are |
4985 // to load local resources. This lets about:blank iframes in file:// | 4970 // the origin's potential trustworthiness and the ability to |
4986 // URL documents load images and other resources from the file system. | 4971 // load local resources. The latter lets about:blank iframes in |
| 4972 // file:// URL documents load images and other resources from |
| 4973 // the file system. |
| 4974 if (initializer.owner() && initializer.owner()->getSecurityOrigin()->isP
otentiallyTrustworthy()) |
| 4975 getSecurityOrigin()->setUniqueOriginIsPotentiallyTrustworthy(true); |
4987 if (initializer.owner() && initializer.owner()->getSecurityOrigin()->can
LoadLocalResources()) | 4976 if (initializer.owner() && initializer.owner()->getSecurityOrigin()->can
LoadLocalResources()) |
4988 getSecurityOrigin()->grantLoadLocalResources(); | 4977 getSecurityOrigin()->grantLoadLocalResources(); |
4989 } else if (initializer.owner()) { | 4978 } else if (initializer.owner()) { |
4990 m_cookieURL = initializer.owner()->cookieURL(); | 4979 m_cookieURL = initializer.owner()->cookieURL(); |
4991 // We alias the SecurityOrigins to match Firefox, see Bug 15313 | 4980 // We alias the SecurityOrigins to match Firefox, see Bug 15313 |
4992 // https://bugs.webkit.org/show_bug.cgi?id=15313 | 4981 // https://bugs.webkit.org/show_bug.cgi?id=15313 |
4993 setSecurityOrigin(initializer.owner()->getSecurityOrigin()); | 4982 setSecurityOrigin(initializer.owner()->getSecurityOrigin()); |
4994 } else { | 4983 } else { |
4995 m_cookieURL = m_url; | 4984 m_cookieURL = m_url; |
4996 setSecurityOrigin(SecurityOrigin::create(m_url)); | 4985 setSecurityOrigin(SecurityOrigin::create(m_url)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5032 getSecurityOrigin()->blockLocalAccessFromLocalOrigin(); | 5021 getSecurityOrigin()->blockLocalAccessFromLocalOrigin(); |
5033 } | 5022 } |
5034 } | 5023 } |
5035 } | 5024 } |
5036 | 5025 |
5037 if (initializer.shouldTreatURLAsSrcdocDocument()) { | 5026 if (initializer.shouldTreatURLAsSrcdocDocument()) { |
5038 m_isSrcdocDocument = true; | 5027 m_isSrcdocDocument = true; |
5039 setBaseURLOverride(initializer.parentBaseURL()); | 5028 setBaseURLOverride(initializer.parentBaseURL()); |
5040 } | 5029 } |
5041 | 5030 |
5042 if (getSecurityOrigin()->hasSuborigin()) | 5031 if (getSecurityOrigin()->isUnique() && SecurityOrigin::create(m_url)->isPote
ntiallyTrustworthy()) |
5043 enforceSuborigin(getSecurityOrigin()->suboriginName()); | 5032 getSecurityOrigin()->setUniqueOriginIsPotentiallyTrustworthy(true); |
5044 } | 5033 } |
5045 | 5034 |
5046 void Document::initContentSecurityPolicy(PassRefPtrWillBeRawPtr<ContentSecurityP
olicy> csp) | 5035 void Document::initContentSecurityPolicy(PassRefPtrWillBeRawPtr<ContentSecurityP
olicy> csp) |
5047 { | 5036 { |
5048 setContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::create()); | 5037 setContentSecurityPolicy(csp ? csp : ContentSecurityPolicy::create()); |
5049 if (m_frame && m_frame->tree().parent() && m_frame->tree().parent()->isLocal
Frame()) { | 5038 if (m_frame && m_frame->tree().parent() && m_frame->tree().parent()->isLocal
Frame()) { |
5050 ContentSecurityPolicy* parentCSP = toLocalFrame(m_frame->tree().parent()
)->document()->contentSecurityPolicy(); | 5039 ContentSecurityPolicy* parentCSP = toLocalFrame(m_frame->tree().parent()
)->document()->contentSecurityPolicy(); |
5051 if (shouldInheritSecurityOriginFromOwner(m_url)) { | 5040 if (shouldInheritSecurityOriginFromOwner(m_url)) { |
5052 contentSecurityPolicy()->copyStateFrom(parentCSP); | 5041 contentSecurityPolicy()->copyStateFrom(parentCSP); |
5053 } else if (isPluginDocument()) { | 5042 } else if (isPluginDocument()) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5094 LocalFrame* frame = executingFrame(); | 5083 LocalFrame* frame = executingFrame(); |
5095 if (!frame) | 5084 if (!frame) |
5096 return false; | 5085 return false; |
5097 if (!node->document().executingFrame()) | 5086 if (!node->document().executingFrame()) |
5098 return false; | 5087 return false; |
5099 if (!frame->script().canExecuteScripts(AboutToExecuteScript)) | 5088 if (!frame->script().canExecuteScripts(AboutToExecuteScript)) |
5100 return false; | 5089 return false; |
5101 return true; | 5090 return true; |
5102 } | 5091 } |
5103 | 5092 |
| 5093 void Document::enforceSandboxFlags(SandboxFlags mask) |
| 5094 { |
| 5095 RefPtr<SecurityOrigin> standInOrigin = getSecurityOrigin(); |
| 5096 applySandboxFlags(mask); |
| 5097 // Send a notification if the origin has been updated. |
| 5098 if (standInOrigin && !standInOrigin->isUnique() && getSecurityOrigin()->isUn
ique()) { |
| 5099 getSecurityOrigin()->setUniqueOriginIsPotentiallyTrustworthy(standInOrig
in->isPotentiallyTrustworthy()); |
| 5100 if (frame()) |
| 5101 frame()->loader().client()->didUpdateToUniqueOrigin(); |
| 5102 } |
| 5103 } |
| 5104 |
5104 void Document::updateSecurityOrigin(PassRefPtr<SecurityOrigin> origin) | 5105 void Document::updateSecurityOrigin(PassRefPtr<SecurityOrigin> origin) |
5105 { | 5106 { |
5106 setSecurityOrigin(origin); | 5107 setSecurityOrigin(origin); |
5107 didUpdateSecurityOrigin(); | 5108 didUpdateSecurityOrigin(); |
5108 } | 5109 } |
5109 | 5110 |
5110 void Document::didUpdateSecurityOrigin() | 5111 void Document::didUpdateSecurityOrigin() |
5111 { | 5112 { |
5112 if (!m_frame) | 5113 if (!m_frame) |
5113 return; | 5114 return; |
(...skipping 920 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6034 #ifndef NDEBUG | 6035 #ifndef NDEBUG |
6035 using namespace blink; | 6036 using namespace blink; |
6036 void showLiveDocumentInstances() | 6037 void showLiveDocumentInstances() |
6037 { | 6038 { |
6038 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 6039 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
6039 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 6040 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
6040 for (Document* document : set) | 6041 for (Document* document : set) |
6041 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); | 6042 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().get
String().utf8().data()); |
6042 } | 6043 } |
6043 #endif | 6044 #endif |
OLD | NEW |