| Summary: | REGRESSION (iOS 15.4): Worker csp with script-src 'strict-dynamic' and script-src-elem blocks importScripts that should pass | ||||||
|---|---|---|---|---|---|---|---|
| Product: | WebKit | Reporter: | Julian M <webkit> | ||||
| Component: | Page Loading | Assignee: | Patrick Griffis <pgriffis> | ||||
| Status: | RESOLVED FIXED | ||||||
| Severity: | Normal | CC: | beidson, bfulgham, ews-watchlist, katherine_cheney, mkwst, pgriffis, seongil.wi, webkit-bug-importer | ||||
| Priority: | P2 | Keywords: | InRadar | ||||
| Version: | Safari 15 | ||||||
| Hardware: | Unspecified | ||||||
| OS: | Unspecified | ||||||
| Attachments: |
|
||||||
|
Description
Julian M
2022-04-27 23:22:26 PDT
Hi! Thank you for filing this! I just want to confirm I understand - this behavior worked as expected on previous versions of iOS and now fails on 15.4? (In reply to Kate Cheney from comment #2) > Hi! Thank you for filing this! I just want to confirm I understand - this > behavior worked as expected on previous versions of iOS and now fails on > 15.4? Yep! I'm guessing based on the introduction of 'strict-dynamic' support. Didn't write a test for it yet and not sure this is the correct directive for everything that calls this method but the most direct fix:
diff --git a/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp b/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp
index 7d73ac8bfb97..c7466c36f437 100644
--- a/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp
+++ b/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp
@@ -408,8 +408,7 @@ const ContentSecurityPolicyDirective* ContentSecurityPolicyDirectiveList::violat
const ContentSecurityPolicyDirective* ContentSecurityPolicyDirectiveList::violatedDirectiveForScript(const URL& url, bool didReceiveRedirectResponse, const Vector<ResourceCryptographicDigest>& subResourceIntegrityDigests, const String& nonce) const
{
- auto* operativeDirective = this->operativeDirective(m_scriptSrc.get(), ContentSecurityPolicyDirectiveNames::scriptSrcElem);
+ auto* operativeDirective = this->operativeDirective(m_scriptSrcElem.get(), ContentSecurityPolicyDirectiveNames::scriptSrcElem);
if (!operativeDirective
|| operativeDirective->containsAllHashes(subResourceIntegrityDigests)
|| checkNonce(operativeDirective, nonce)
(In reply to Patrick Griffis from comment #5) > Didn't write a test for it yet and not sure this is the correct directive > for everything that calls this method but the most direct fix: > > diff --git a/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp > b/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp > index 7d73ac8bfb97..c7466c36f437 100644 > --- a/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp > +++ b/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp > @@ -408,8 +408,7 @@ const ContentSecurityPolicyDirective* > ContentSecurityPolicyDirectiveList::violat > > const ContentSecurityPolicyDirective* > ContentSecurityPolicyDirectiveList::violatedDirectiveForScript(const URL& > url, bool didReceiveRedirectResponse, const > Vector<ResourceCryptographicDigest>& subResourceIntegrityDigests, const > String& nonce) const > { > - auto* operativeDirective = this->operativeDirective(m_scriptSrc.get(), > ContentSecurityPolicyDirectiveNames::scriptSrcElem); > + auto* operativeDirective = > this->operativeDirective(m_scriptSrcElem.get(), > ContentSecurityPolicyDirectiveNames::scriptSrcElem); > > if (!operativeDirective > || > operativeDirective->containsAllHashes(subResourceIntegrityDigests) > || checkNonce(operativeDirective, nonce) I think this will be fine because violatedDirectiveForScript is called for non-inline script sources which should all fall under script-src-elem. We will need to use operativeDirectiveScript to ensure we fall back to script-src if script-src-elem is not present. Created attachment 458912 [details]
Patch
Committed r293940 (250386@main): <https://commits.webkit.org/250386@main> All reviewed patches have been landed. Closing bug and clearing flags on attachment 458912 [details]. *** Bug 241337 has been marked as a duplicate of this bug. *** |