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 3369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3380 // Additionally, with | 3380 // Additionally, with |
3381 // <iframe src="scheme-has-exception://host"> | 3381 // <iframe src="scheme-has-exception://host"> |
3382 // <iframe src="http://host"></iframe> | 3382 // <iframe src="http://host"></iframe> |
3383 // <iframe sandbox src="http://host"></iframe> | 3383 // <iframe sandbox src="http://host"></iframe> |
3384 // </iframe> | 3384 // </iframe> |
3385 // both inner iframes would fail the check, even though the outermost iframe | 3385 // both inner iframes would fail the check, even though the outermost iframe |
3386 // passes. | 3386 // passes. |
3387 // | 3387 // |
3388 // In all cases, a frame must be potentially trustworthy in addition to | 3388 // In all cases, a frame must be potentially trustworthy in addition to |
3389 // having an exception listed in order for the exception to be granted. | 3389 // having an exception listed in order for the exception to be granted. |
3390 if (SecurityContext::isSandboxed(SandboxOrigin)) { | 3390 if (!isOriginPotentiallyTrustworthy(securityOrigin(), errorMessage)) |
3391 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(url()); | 3391 return false; |
3392 if (!isOriginPotentiallyTrustworthy(origin.get(), errorMessage)) | 3392 if (securityOrigin()->bypassSecureContextCheck()) |
3393 return false; | 3393 return true; |
3394 if (SchemeRegistry::schemeShouldBypassSecureContextCheck(origin->protoco
l())) | |
3395 return true; | |
3396 } else { | |
3397 if (!isOriginPotentiallyTrustworthy(securityOrigin(), errorMessage)) | |
3398 return false; | |
3399 if (SchemeRegistry::schemeShouldBypassSecureContextCheck(securityOrigin(
)->protocol())) | |
3400 return true; | |
3401 } | |
3402 | 3394 |
3403 if (privilegeContextCheck == StandardSecureContextCheck) { | 3395 if (privilegeContextCheck == StandardSecureContextCheck) { |
3404 Document* context = parentDocument(); | 3396 if (!m_frame) |
3405 while (context) { | 3397 return true; |
3406 // Skip to the next ancestor if it's a srcdoc. | 3398 Frame* parent = m_frame->tree().parent(); |
3407 if (!context->isSrcdocDocument()) { | 3399 while (parent) { |
3408 if (context->securityContext().isSandboxed(SandboxOrigin)) { | 3400 if (!isOriginPotentiallyTrustworthy(parent->securityContext()->secur
ityOrigin(), errorMessage)) |
3409 // For a sandboxed origin, use the document's URL. | 3401 return false; |
3410 RefPtr<SecurityOrigin> origin = SecurityOrigin::create(conte
xt->url()); | 3402 parent = parent->tree().parent(); |
3411 if (!isOriginPotentiallyTrustworthy(origin.get(), errorMessa
ge)) | |
3412 return false; | |
3413 } else { | |
3414 if (!isOriginPotentiallyTrustworthy(context->securityOrigin(
), errorMessage)) | |
3415 return false; | |
3416 } | |
3417 } | |
3418 context = context->parentDocument(); | |
3419 } | 3403 } |
3420 } | 3404 } |
3421 return true; | 3405 return true; |
3422 } | 3406 } |
3423 | 3407 |
3424 StyleSheetList* Document::styleSheets() | 3408 StyleSheetList* Document::styleSheets() |
3425 { | 3409 { |
3426 if (!m_styleSheetList) | 3410 if (!m_styleSheetList) |
3427 m_styleSheetList = StyleSheetList::create(this); | 3411 m_styleSheetList = StyleSheetList::create(this); |
3428 return m_styleSheetList.get(); | 3412 return m_styleSheetList.get(); |
(...skipping 1506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4935 // This can occur via document.implementation.createDocument(). | 4919 // This can occur via document.implementation.createDocument(). |
4936 m_cookieURL = KURL(ParsedURLString, emptyString()); | 4920 m_cookieURL = KURL(ParsedURLString, emptyString()); |
4937 setSecurityOrigin(SecurityOrigin::createUnique()); | 4921 setSecurityOrigin(SecurityOrigin::createUnique()); |
4938 initContentSecurityPolicy(); | 4922 initContentSecurityPolicy(); |
4939 return; | 4923 return; |
4940 } | 4924 } |
4941 | 4925 |
4942 // In the common case, create the security context from the currently | 4926 // In the common case, create the security context from the currently |
4943 // loading URL with a fresh content security policy. | 4927 // loading URL with a fresh content security policy. |
4944 m_cookieURL = m_url; | 4928 m_cookieURL = m_url; |
| 4929 // Set the origin initially based on the URL. enforceSandboxFlags() |
| 4930 // will adjust it to be a unique origin if necessary. |
| 4931 setSecurityOrigin(SecurityOrigin::create(m_url)); |
4945 enforceSandboxFlags(initializer.getSandboxFlags()); | 4932 enforceSandboxFlags(initializer.getSandboxFlags()); |
4946 if (initializer.shouldEnforceStrictMixedContentChecking()) | 4933 if (initializer.shouldEnforceStrictMixedContentChecking()) |
4947 enforceStrictMixedContentChecking(); | 4934 enforceStrictMixedContentChecking(); |
4948 setInsecureRequestsPolicy(initializer.getInsecureRequestsPolicy()); | 4935 setInsecureRequestsPolicy(initializer.getInsecureRequestsPolicy()); |
4949 if (initializer.insecureNavigationsToUpgrade()) { | 4936 if (initializer.insecureNavigationsToUpgrade()) { |
4950 for (auto toUpgrade : *initializer.insecureNavigationsToUpgrade()) | 4937 for (auto toUpgrade : *initializer.insecureNavigationsToUpgrade()) |
4951 addInsecureNavigationUpgrade(toUpgrade); | 4938 addInsecureNavigationUpgrade(toUpgrade); |
4952 } | 4939 } |
4953 setSecurityOrigin(isSandboxed(SandboxOrigin) ? SecurityOrigin::createUnique(
) : SecurityOrigin::create(m_url)); | |
4954 | 4940 |
4955 if (importsController()) { | 4941 if (importsController()) { |
4956 // If this document is an HTML import, grab a reference to it's master d
ocument's Content | 4942 // If this document is an HTML import, grab a reference to it's master d
ocument's Content |
4957 // Security Policy. We don't call 'initContentSecurityPolicy' in this ca
se, as we can't | 4943 // Security Policy. We don't call 'initContentSecurityPolicy' in this ca
se, as we can't |
4958 // rebind the master document's policy object: its ExecutionContext need
s to remain tied | 4944 // rebind the master document's policy object: its ExecutionContext need
s to remain tied |
4959 // to the master document. | 4945 // to the master document. |
4960 setContentSecurityPolicy(importsController()->master()->contentSecurityP
olicy()); | 4946 setContentSecurityPolicy(importsController()->master()->contentSecurityP
olicy()); |
4961 } else { | 4947 } else { |
4962 initContentSecurityPolicy(); | 4948 initContentSecurityPolicy(); |
4963 } | 4949 } |
(...skipping 25 matching lines...) Expand all Loading... |
4989 // If we do not obtain a meaningful origin from the URL, then we try to | 4975 // If we do not obtain a meaningful origin from the URL, then we try to |
4990 // find one via the frame hierarchy. | 4976 // find one via the frame hierarchy. |
4991 | 4977 |
4992 if (!initializer.owner()) { | 4978 if (!initializer.owner()) { |
4993 didFailToInitializeSecurityOrigin(); | 4979 didFailToInitializeSecurityOrigin(); |
4994 return; | 4980 return; |
4995 } | 4981 } |
4996 | 4982 |
4997 if (isSandboxed(SandboxOrigin)) { | 4983 if (isSandboxed(SandboxOrigin)) { |
4998 // If we're supposed to inherit our security origin from our owner, | 4984 // If we're supposed to inherit our security origin from our owner, |
4999 // but we're also sandboxed, the only thing we inherit is the ability | 4985 // but we're also sandboxed, the only things we inherit are the |
5000 // to load local resources. This lets about:blank iframes in file:// | 4986 // potential trustworthiness of the origin and the ability to |
| 4987 // load local resources. The latter lets about:blank iframes in file:// |
5001 // URL documents load images and other resources from the file system. | 4988 // URL documents load images and other resources from the file system. |
| 4989 if (initializer.owner()->securityOrigin()->isPotentiallyTrustworthy()) |
| 4990 securityOrigin()->setIsPotentiallyTrustworthySandboxedOrigin(); |
5002 if (initializer.owner()->securityOrigin()->canLoadLocalResources()) | 4991 if (initializer.owner()->securityOrigin()->canLoadLocalResources()) |
5003 securityOrigin()->grantLoadLocalResources(); | 4992 securityOrigin()->grantLoadLocalResources(); |
5004 return; | 4993 return; |
5005 } | 4994 } |
5006 | 4995 |
5007 m_cookieURL = initializer.owner()->cookieURL(); | 4996 m_cookieURL = initializer.owner()->cookieURL(); |
5008 // We alias the SecurityOrigins to match Firefox, see Bug 15313 | 4997 // We alias the SecurityOrigins to match Firefox, see Bug 15313 |
5009 // https://bugs.webkit.org/show_bug.cgi?id=15313 | 4998 // https://bugs.webkit.org/show_bug.cgi?id=15313 |
5010 setSecurityOrigin(initializer.owner()->securityOrigin()); | 4999 setSecurityOrigin(initializer.owner()->securityOrigin()); |
5011 } | 5000 } |
(...skipping 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5995 #ifndef NDEBUG | 5984 #ifndef NDEBUG |
5996 using namespace blink; | 5985 using namespace blink; |
5997 void showLiveDocumentInstances() | 5986 void showLiveDocumentInstances() |
5998 { | 5987 { |
5999 Document::WeakDocumentSet& set = Document::liveDocumentSet(); | 5988 Document::WeakDocumentSet& set = Document::liveDocumentSet(); |
6000 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); | 5989 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); |
6001 for (Document* document : set) | 5990 for (Document* document : set) |
6002 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); | 5991 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str
ing().utf8().data()); |
6003 } | 5992 } |
6004 #endif | 5993 #endif |
OLD | NEW |