Title: [291915] branches/safari-613-branch
Revision
291915
Author
[email protected]
Date
2022-03-25 18:51:08 -0700 (Fri, 25 Mar 2022)

Log Message

Cherry-pick r288792. rdar://problem/88227274

    CSP: Properly block image content in object elements
    https://bugs.webkit.org/show_bug.cgi?id=235837

    Reviewed by Kate Cheney.

    LayoutTests/imported/w3c:

    Update expectations with more passes.

    * web-platform-tests/content-security-policy/object-src/object-src-url-blocked-expected.txt:
    * web-platform-tests/content-security-policy/object-src/object-src-url-embed-blocked-expected.txt:
    * web-platform-tests/content-security-policy/object-src/object-src-url-redirect-blocked.sub-expected.txt:

    Source/WebCore:

    When an image is loaded through an object element it now passes through
    the object-src directive check as the spec documents:
    https://www.w3.org/TR/CSP3/#directive-object-src

    * loader/ImageLoader.cpp:
    (WebCore::ImageLoader::updateFromElement):
    * loader/ResourceLoaderOptions.h:
    (WebCore::ResourceLoaderOptions::loadedFromPluginElement):
    (WebCore::ResourceLoaderOptions::ResourceLoaderOptions):
    (WebCore::ResourceLoaderOptions::loadedFromOpaqueSource): Deleted.
    * loader/cache/CachedResourceLoader.cpp:
    (WebCore::CachedResourceLoader::allowedByContentSecurityPolicy const):
    * page/csp/ContentSecurityPolicy.cpp:
    (WebCore::ContentSecurityPolicy::allowObjectFromSource const):
    * page/csp/ContentSecurityPolicy.h:

    LayoutTests:

    * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked-expected.txt:
    * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked2-expected.txt:
    * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked3-expected.txt:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288792 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-613-branch/LayoutTests/ChangeLog (291914 => 291915)


--- branches/safari-613-branch/LayoutTests/ChangeLog	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/LayoutTests/ChangeLog	2022-03-26 01:51:08 UTC (rev 291915)
@@ -1,5 +1,59 @@
 2022-03-22  Alan Coon  <[email protected]>
 
+        Cherry-pick r288792. rdar://problem/88227274
+
+    CSP: Properly block image content in object elements
+    https://bugs.webkit.org/show_bug.cgi?id=235837
+    
+    Reviewed by Kate Cheney.
+    
+    LayoutTests/imported/w3c:
+    
+    Update expectations with more passes.
+    
+    * web-platform-tests/content-security-policy/object-src/object-src-url-blocked-expected.txt:
+    * web-platform-tests/content-security-policy/object-src/object-src-url-embed-blocked-expected.txt:
+    * web-platform-tests/content-security-policy/object-src/object-src-url-redirect-blocked.sub-expected.txt:
+    
+    Source/WebCore:
+    
+    When an image is loaded through an object element it now passes through
+    the object-src directive check as the spec documents:
+    https://www.w3.org/TR/CSP3/#directive-object-src
+    
+    * loader/ImageLoader.cpp:
+    (WebCore::ImageLoader::updateFromElement):
+    * loader/ResourceLoaderOptions.h:
+    (WebCore::ResourceLoaderOptions::loadedFromPluginElement):
+    (WebCore::ResourceLoaderOptions::ResourceLoaderOptions):
+    (WebCore::ResourceLoaderOptions::loadedFromOpaqueSource): Deleted.
+    * loader/cache/CachedResourceLoader.cpp:
+    (WebCore::CachedResourceLoader::allowedByContentSecurityPolicy const):
+    * page/csp/ContentSecurityPolicy.cpp:
+    (WebCore::ContentSecurityPolicy::allowObjectFromSource const):
+    * page/csp/ContentSecurityPolicy.h:
+    
+    LayoutTests:
+    
+    * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked-expected.txt:
+    * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked2-expected.txt:
+    * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked3-expected.txt:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288792 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-29  Patrick Griffis  <[email protected]>
+
+            CSP: Properly block image content in object elements
+            https://bugs.webkit.org/show_bug.cgi?id=235837
+
+            Reviewed by Kate Cheney.
+
+            * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked-expected.txt:
+            * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked2-expected.txt:
+            * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked3-expected.txt:
+
+2022-03-22  Alan Coon  <[email protected]>
+
         Revert r290708. rdar://problem/90113314
 
 2022-03-21  Alan Coon  <[email protected]>

Modified: branches/safari-613-branch/LayoutTests/http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked-expected.txt (291914 => 291915)


--- branches/safari-613-branch/LayoutTests/http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked-expected.txt	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/LayoutTests/http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked-expected.txt	2022-03-26 01:51:08 UTC (rev 291915)
@@ -1,3 +1,3 @@
-CONSOLE MESSAGE: Refused to load http://localhost:8000/security/resources/abe.png because it appears in neither the img-src directive nor the default-src directive of the Content Security Policy.
+CONSOLE MESSAGE: Refused to load http://localhost:8000/security/resources/abe.png because it appears in neither the object-src directive nor the default-src directive of the Content Security Policy.
 ALERT: PASS
 This test passes if it doesn't alert FAIL and does alert PASS.

Modified: branches/safari-613-branch/LayoutTests/http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked2-expected.txt (291914 => 291915)


--- branches/safari-613-branch/LayoutTests/http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked2-expected.txt	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/LayoutTests/http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked2-expected.txt	2022-03-26 01:51:08 UTC (rev 291915)
@@ -1,3 +1,3 @@
-CONSOLE MESSAGE: Refused to load http://localhost:8000/security/resources/abe.png because it appears in neither the img-src directive nor the default-src directive of the Content Security Policy.
+CONSOLE MESSAGE: Refused to load http://localhost:8000/security/resources/abe.png because it appears in neither the object-src directive nor the default-src directive of the Content Security Policy.
 ALERT: PASS
 This test passes if it doesn't alert FAIL and does alert PASS.

Modified: branches/safari-613-branch/LayoutTests/http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked3-expected.txt (291914 => 291915)


--- branches/safari-613-branch/LayoutTests/http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked3-expected.txt	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/LayoutTests/http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked3-expected.txt	2022-03-26 01:51:08 UTC (rev 291915)
@@ -1,3 +1,3 @@
-CONSOLE MESSAGE: Refused to load http://localhost:8000/security/resources/abe.png because it appears in neither the img-src directive nor the default-src directive of the Content Security Policy.
+CONSOLE MESSAGE: Refused to load http://localhost:8000/security/resources/abe.png because it appears in neither the object-src directive nor the default-src directive of the Content Security Policy.
 ALERT: PASS
 This test passes if it doesn't alert FAIL and does alert PASS.

Modified: branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog (291914 => 291915)


--- branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/ChangeLog	2022-03-26 01:51:08 UTC (rev 291915)
@@ -1,3 +1,59 @@
+2022-03-22  Alan Coon  <[email protected]>
+
+        Cherry-pick r288792. rdar://problem/88227274
+
+    CSP: Properly block image content in object elements
+    https://bugs.webkit.org/show_bug.cgi?id=235837
+    
+    Reviewed by Kate Cheney.
+    
+    LayoutTests/imported/w3c:
+    
+    Update expectations with more passes.
+    
+    * web-platform-tests/content-security-policy/object-src/object-src-url-blocked-expected.txt:
+    * web-platform-tests/content-security-policy/object-src/object-src-url-embed-blocked-expected.txt:
+    * web-platform-tests/content-security-policy/object-src/object-src-url-redirect-blocked.sub-expected.txt:
+    
+    Source/WebCore:
+    
+    When an image is loaded through an object element it now passes through
+    the object-src directive check as the spec documents:
+    https://www.w3.org/TR/CSP3/#directive-object-src
+    
+    * loader/ImageLoader.cpp:
+    (WebCore::ImageLoader::updateFromElement):
+    * loader/ResourceLoaderOptions.h:
+    (WebCore::ResourceLoaderOptions::loadedFromPluginElement):
+    (WebCore::ResourceLoaderOptions::ResourceLoaderOptions):
+    (WebCore::ResourceLoaderOptions::loadedFromOpaqueSource): Deleted.
+    * loader/cache/CachedResourceLoader.cpp:
+    (WebCore::CachedResourceLoader::allowedByContentSecurityPolicy const):
+    * page/csp/ContentSecurityPolicy.cpp:
+    (WebCore::ContentSecurityPolicy::allowObjectFromSource const):
+    * page/csp/ContentSecurityPolicy.h:
+    
+    LayoutTests:
+    
+    * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked-expected.txt:
+    * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked2-expected.txt:
+    * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked3-expected.txt:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288792 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-29  Patrick Griffis  <[email protected]>
+
+            CSP: Properly block image content in object elements
+            https://bugs.webkit.org/show_bug.cgi?id=235837
+
+            Reviewed by Kate Cheney.
+
+            Update expectations with more passes.
+
+            * web-platform-tests/content-security-policy/object-src/object-src-url-blocked-expected.txt:
+            * web-platform-tests/content-security-policy/object-src/object-src-url-embed-blocked-expected.txt:
+            * web-platform-tests/content-security-policy/object-src/object-src-url-redirect-blocked.sub-expected.txt:
+
 2022-03-21  Alan Coon  <[email protected]>
 
         Cherry-pick r291527. rdar://problem/88857731

Modified: branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/object-src/object-src-url-blocked-expected.txt (291914 => 291915)


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/object-src/object-src-url-blocked-expected.txt	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/object-src/object-src-url-blocked-expected.txt	2022-03-26 01:51:08 UTC (rev 291915)
@@ -1,6 +1,4 @@
 
 
-Harness Error (TIMEOUT), message = null
+PASS Should block the object and fire a spv
 
-NOTRUN Should block the object and fire a spv
-

Modified: branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/object-src/object-src-url-embed-blocked-expected.txt (291914 => 291915)


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/object-src/object-src-url-embed-blocked-expected.txt	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/object-src/object-src-url-embed-blocked-expected.txt	2022-03-26 01:51:08 UTC (rev 291915)
@@ -1,6 +1,4 @@
 
 
-Harness Error (TIMEOUT), message = null
+PASS Should block the object and fire a spv
 
-NOTRUN Should block the object and fire a spv
-

Modified: branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/object-src/object-src-url-redirect-blocked.sub-expected.txt (291914 => 291915)


--- branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/object-src/object-src-url-redirect-blocked.sub-expected.txt	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/object-src/object-src-url-redirect-blocked.sub-expected.txt	2022-03-26 01:51:08 UTC (rev 291915)
@@ -1,6 +1,3 @@
-Blocked access to external URL http://www1.localhost/content-security-policy/support/pass.png
 
-Harness Error (TIMEOUT), message = null
+PASS Should block the object and fire a spv
 
-NOTRUN Should block the object and fire a spv
-

Modified: branches/safari-613-branch/Source/WebCore/ChangeLog (291914 => 291915)


--- branches/safari-613-branch/Source/WebCore/ChangeLog	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/Source/WebCore/ChangeLog	2022-03-26 01:51:08 UTC (rev 291915)
@@ -1,3 +1,69 @@
+2022-03-22  Alan Coon  <[email protected]>
+
+        Cherry-pick r288792. rdar://problem/88227274
+
+    CSP: Properly block image content in object elements
+    https://bugs.webkit.org/show_bug.cgi?id=235837
+    
+    Reviewed by Kate Cheney.
+    
+    LayoutTests/imported/w3c:
+    
+    Update expectations with more passes.
+    
+    * web-platform-tests/content-security-policy/object-src/object-src-url-blocked-expected.txt:
+    * web-platform-tests/content-security-policy/object-src/object-src-url-embed-blocked-expected.txt:
+    * web-platform-tests/content-security-policy/object-src/object-src-url-redirect-blocked.sub-expected.txt:
+    
+    Source/WebCore:
+    
+    When an image is loaded through an object element it now passes through
+    the object-src directive check as the spec documents:
+    https://www.w3.org/TR/CSP3/#directive-object-src
+    
+    * loader/ImageLoader.cpp:
+    (WebCore::ImageLoader::updateFromElement):
+    * loader/ResourceLoaderOptions.h:
+    (WebCore::ResourceLoaderOptions::loadedFromPluginElement):
+    (WebCore::ResourceLoaderOptions::ResourceLoaderOptions):
+    (WebCore::ResourceLoaderOptions::loadedFromOpaqueSource): Deleted.
+    * loader/cache/CachedResourceLoader.cpp:
+    (WebCore::CachedResourceLoader::allowedByContentSecurityPolicy const):
+    * page/csp/ContentSecurityPolicy.cpp:
+    (WebCore::ContentSecurityPolicy::allowObjectFromSource const):
+    * page/csp/ContentSecurityPolicy.h:
+    
+    LayoutTests:
+    
+    * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked-expected.txt:
+    * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked2-expected.txt:
+    * http/tests/security/contentSecurityPolicy/userAgentShadowDOM/default-src-object-data-url-blocked3-expected.txt:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@288792 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2022-01-29  Patrick Griffis  <[email protected]>
+
+            CSP: Properly block image content in object elements
+            https://bugs.webkit.org/show_bug.cgi?id=235837
+
+            Reviewed by Kate Cheney.
+
+            When an image is loaded through an object element it now passes through
+            the object-src directive check as the spec documents:
+            https://www.w3.org/TR/CSP3/#directive-object-src
+
+            * loader/ImageLoader.cpp:
+            (WebCore::ImageLoader::updateFromElement):
+            * loader/ResourceLoaderOptions.h:
+            (WebCore::ResourceLoaderOptions::loadedFromPluginElement):
+            (WebCore::ResourceLoaderOptions::ResourceLoaderOptions):
+            (WebCore::ResourceLoaderOptions::loadedFromOpaqueSource): Deleted.
+            * loader/cache/CachedResourceLoader.cpp:
+            (WebCore::CachedResourceLoader::allowedByContentSecurityPolicy const):
+            * page/csp/ContentSecurityPolicy.cpp:
+            (WebCore::ContentSecurityPolicy::allowObjectFromSource const):
+            * page/csp/ContentSecurityPolicy.h:
+
 2022-03-22  Alex Christensen  <[email protected]>
 
         Fix build on safari-613-branch

Modified: branches/safari-613-branch/Source/WebCore/loader/ImageLoader.cpp (291914 => 291915)


--- branches/safari-613-branch/Source/WebCore/loader/ImageLoader.cpp	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/Source/WebCore/loader/ImageLoader.cpp	2022-03-26 01:51:08 UTC (rev 291915)
@@ -38,6 +38,7 @@
 #include "HTMLNames.h"
 #include "HTMLObjectElement.h"
 #include "HTMLParserIdioms.h"
+#include "HTMLPlugInElement.h"
 #include "InspectorInstrumentation.h"
 #include "JSDOMPromiseDeferred.h"
 #include "LazyLoadImageObserver.h"
@@ -188,6 +189,7 @@
     if (!attr.isNull() && !stripLeadingAndTrailingHTMLSpaces(attr).isEmpty()) {
         ResourceLoaderOptions options = CachedResourceLoader::defaultCachedResourceOptions();
         options.contentSecurityPolicyImposition = element().isInUserAgentShadowTree() ? ContentSecurityPolicyImposition::SkipPolicyCheck : ContentSecurityPolicyImposition::DoPolicyCheck;
+        options.loadedFromPluginElement = is<HTMLPlugInElement>(element()) ? LoadedFromPluginElement::Yes : LoadedFromPluginElement::No;
         options.sameOriginDataURLFlag = SameOriginDataURLFlag::Set;
         bool isImageElement = is<HTMLImageElement>(element());
         if (isImageElement)

Modified: branches/safari-613-branch/Source/WebCore/loader/ResourceLoaderOptions.h (291914 => 291915)


--- branches/safari-613-branch/Source/WebCore/loader/ResourceLoaderOptions.h	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/Source/WebCore/loader/ResourceLoaderOptions.h	2022-03-26 01:51:08 UTC (rev 291915)
@@ -147,6 +147,12 @@
 };
 static constexpr unsigned bitWidthOfLoadedFromOpaqueSource = 1;
 
+enum class LoadedFromPluginElement : bool {
+    No,
+    Yes
+};
+static constexpr unsigned bitWidthOfLoadedFromPluginElement = 1;
+
 struct ResourceLoaderOptions : public FetchOptions {
     ResourceLoaderOptions()
         : ResourceLoaderOptions(FetchOptions())
@@ -172,6 +178,7 @@
         , clientCredentialPolicy(ClientCredentialPolicy::CannotAskClientForCredentials)
         , preflightPolicy(PreflightPolicy::Consider)
         , loadedFromOpaqueSource(LoadedFromOpaqueSource::No)
+        , loadedFromPluginElement(LoadedFromPluginElement::No)
     { }
 
     ResourceLoaderOptions(SendCallbackPolicy sendLoadCallbacks, ContentSniffingPolicy sniffContent, DataBufferingPolicy dataBufferingPolicy, StoredCredentialsPolicy storedCredentialsPolicy, ClientCredentialPolicy credentialPolicy, FetchOptions::Credentials credentials, SecurityCheckPolicy securityCheck, FetchOptions::Mode mode, CertificateInfoPolicy certificateInfoPolicy, ContentSecurityPolicyImposition contentSecurityPolicyImposition, DefersLoadingPolicy defersLoadingPolicy, CachingPolicy cachingPolicy)
@@ -192,6 +199,7 @@
         , clientCredentialPolicy(credentialPolicy)
         , preflightPolicy(PreflightPolicy::Consider)
         , loadedFromOpaqueSource(LoadedFromOpaqueSource::No)
+        , loadedFromPluginElement(LoadedFromPluginElement::No)
 
     {
         this->credentials = credentials;
@@ -225,6 +233,7 @@
     ClientCredentialPolicy clientCredentialPolicy : bitWidthOfClientCredentialPolicy;
     PreflightPolicy preflightPolicy : bitWidthOfPreflightPolicy;
     LoadedFromOpaqueSource loadedFromOpaqueSource : bitWidthOfLoadedFromOpaqueSource;
+    LoadedFromPluginElement loadedFromPluginElement : bitWidthOfLoadedFromPluginElement;
 };
 
 } // namespace WebCore

Modified: branches/safari-613-branch/Source/WebCore/loader/cache/CachedResourceLoader.cpp (291914 => 291915)


--- branches/safari-613-branch/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/Source/WebCore/loader/cache/CachedResourceLoader.cpp	2022-03-26 01:51:08 UTC (rev 291915)
@@ -496,6 +496,11 @@
     ASSERT(m_document);
     ASSERT(m_document->contentSecurityPolicy());
 
+    // All content loaded through embed or object elements goes through object-src: https://www.w3.org/TR/CSP3/#directive-object-src.
+    if (options.loadedFromPluginElement == LoadedFromPluginElement::Yes
+        && !m_document->contentSecurityPolicy()->allowObjectFromSource(url, redirectResponseReceived, preRedirectURL))
+        return false;
+
     switch (type) {
 #if ENABLE(XSLT)
     case CachedResource::Type::XSLStyleSheet:

Modified: branches/safari-613-branch/Source/WebCore/page/csp/ContentSecurityPolicy.cpp (291914 => 291915)


--- branches/safari-613-branch/Source/WebCore/page/csp/ContentSecurityPolicy.cpp	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/Source/WebCore/page/csp/ContentSecurityPolicy.cpp	2022-03-26 01:51:08 UTC (rev 291915)
@@ -563,7 +563,7 @@
     return allPoliciesAllow(WTFMove(handleViolatedDirective), &ContentSecurityPolicyDirectiveList::violatedDirectiveForPluginType, type, typeAttribute);
 }
 
-bool ContentSecurityPolicy::allowObjectFromSource(const URL& url, RedirectResponseReceived redirectResponseReceived) const
+bool ContentSecurityPolicy::allowObjectFromSource(const URL& url, RedirectResponseReceived redirectResponseReceived, const URL& preRedirectURL) const
 {
     if (LegacySchemeRegistry::schemeShouldBypassContentSecurityPolicy(url.protocol().toStringWithoutCopying()))
         return true;
@@ -572,9 +572,10 @@
     // on the specified type), it MUST be blocked if object-src's value is 'none', but will otherwise be allowed".
     String sourceURL;
     TextPosition sourcePosition(OrdinalNumber::beforeFirst(), OrdinalNumber());
+    const auto& blockedURL = !preRedirectURL.isNull() ? preRedirectURL : url;
     auto handleViolatedDirective = [&] (const ContentSecurityPolicyDirective& violatedDirective) {
         String consoleMessage = consoleMessageForViolation(ContentSecurityPolicyDirectiveNames::objectSrc, violatedDirective, url, "Refused to load");
-        reportViolation(ContentSecurityPolicyDirectiveNames::objectSrc, violatedDirective, url.string(), consoleMessage, sourceURL, StringView(), sourcePosition);
+        reportViolation(ContentSecurityPolicyDirectiveNames::objectSrc, violatedDirective, blockedURL.string(), consoleMessage, sourceURL, StringView(), sourcePosition);
     };
     return allPoliciesAllow(WTFMove(handleViolatedDirective), &ContentSecurityPolicyDirectiveList::violatedDirectiveForObjectSource, url, redirectResponseReceived == RedirectResponseReceived::Yes, ContentSecurityPolicySourceListDirective::ShouldAllowEmptyURLIfSourceListIsNotNone::Yes);
 }

Modified: branches/safari-613-branch/Source/WebCore/page/csp/ContentSecurityPolicy.h (291914 => 291915)


--- branches/safari-613-branch/Source/WebCore/page/csp/ContentSecurityPolicy.h	2022-03-26 01:51:02 UTC (rev 291914)
+++ branches/safari-613-branch/Source/WebCore/page/csp/ContentSecurityPolicy.h	2022-03-26 01:51:08 UTC (rev 291915)
@@ -127,7 +127,7 @@
     WEBCORE_EXPORT bool allowConnectToSource(const URL&, RedirectResponseReceived = RedirectResponseReceived::No, const URL& requestedURL = URL()) const;
     bool allowFormAction(const URL&, RedirectResponseReceived = RedirectResponseReceived::No, const URL& preRedirectURL = URL()) const;
 
-    bool allowObjectFromSource(const URL&, RedirectResponseReceived = RedirectResponseReceived::No) const;
+    bool allowObjectFromSource(const URL&, RedirectResponseReceived = RedirectResponseReceived::No, const URL& preRedirectURL = URL()) const;
     bool allowBaseURI(const URL&, bool overrideContentSecurityPolicy = false) const;
 
     void setOverrideAllowInlineStyle(bool);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to