Please sign in to comment.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
REGRESSION (r196012): Subresource may be blocked by Content Security …
…Policy if it only matches 'self' https://bugs.webkit.org/show_bug.cgi?id=156935 <rdar://problem/25351286> Reviewed by Darin Adler. Source/WebCore: Fixes an issue where subresource load may be blocked by the Content Security Policy (CSP) if its URL only matched 'self'. In particular, the load would be blocked if initiated from a document that inherited the origin of its owner document (e.g. the document contained in <iframe src="about:blank"></iframe>). Following r196012 we compute and cache 'self' and its protocol on instantiation of a ContentSecurityPolicy object for use when matching a URL against it. These cached values become out-of-date if the document subsequently inherits the origin of its owner document. Therefore matches against 'self' will fail and CSP will block a load if its not otherwise allowed by the policy. Previously we would compute 'self' when parsing the definition of a source list and compute the protocol for 'self' each time we tried to match a URL against 'self'. So, 'self' would always be up-to-date with respect to the origin of the document. Tests: http/tests/security/contentSecurityPolicy/iframe-blank-url-programmatically-add-external-script.html http/tests/security/contentSecurityPolicy/iframe-srcdoc-external-script.html * page/csp/ContentSecurityPolicy.cpp: (WebCore::ContentSecurityPolicy::ContentSecurityPolicy): Extract out logic for computing and caching 'self' and its protocol into ContentSecurityPolicy::updateSourceSelf() and make use of this function. (WebCore::ContentSecurityPolicy::updateSourceSelf): Computes and caches 'self' and its protocol with respect to the specified SecurityOrigin. (WebCore::ContentSecurityPolicy::applyPolicyToScriptExecutionContext): Call ContentSecurityPolicy::updateSourceSelf() to ensure that we have an up-to-date representation for 'self' and the protocol of 'self' which can become out-of-date if the document inherited the origin of its owner document. * page/csp/ContentSecurityPolicy.h: LayoutTests: Add tests to ensure that we match 'self' correctly in an iframe with an about:blank document. * http/tests/security/contentSecurityPolicy/iframe-blank-url-programmatically-add-external-script-expected.txt: Added. * http/tests/security/contentSecurityPolicy/iframe-blank-url-programmatically-add-external-script.html: Added. * http/tests/security/contentSecurityPolicy/iframe-srcdoc-external-script-expected.txt: Added. * http/tests/security/contentSecurityPolicy/iframe-srcdoc-external-script.html: Added. Canonical link: https://commits.webkit.org/175086@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200030 268f45cc-cd09-0410-ab3c-d52691b4dbfc
- Loading branch information
Showing with 110 additions and 5 deletions.
- +15 −0 LayoutTests/ChangeLog
- +7 −0 ...security/contentSecurityPolicy/iframe-blank-url-programmatically-add-external-script-expected.txt
- +25 −0 ...p/tests/security/contentSecurityPolicy/iframe-blank-url-programmatically-add-external-script.html
- +2 −0 LayoutTests/http/tests/security/contentSecurityPolicy/iframe-srcdoc-external-script-expected.txt
- +13 −0 LayoutTests/http/tests/security/contentSecurityPolicy/iframe-srcdoc-external-script.html
- +32 −0 Source/WebCore/ChangeLog
- +15 −5 Source/WebCore/page/csp/ContentSecurityPolicy.cpp
- +1 −0 Source/WebCore/page/csp/ContentSecurityPolicy.h