Title: [293603] trunk
Revision
293603
Author
[email protected]
Date
2022-04-28 18:59:02 -0700 (Thu, 28 Apr 2022)

Log Message

CSP: Fix mixing strict-dynamic and unsafe-inline policies
https://bugs.webkit.org/show_bug.cgi?id=239862

Reviewed by Kate Cheney.

Source/WebCore:

Test: http/tests/security/contentSecurityPolicy/script-src-strict-dynamic-and-unsafe-inline-policies.html

* page/csp/ContentSecurityPolicyDirectiveList.cpp:
(WebCore::ContentSecurityPolicyDirectiveList::violatedDirectiveForNonParserInsertedScripts const):

LayoutTests:

If you had multiple policies, one including strict-dynamic and another with unsafe-inline, the unsafe-inline
policy was incorrectly handled.

* http/tests/security/contentSecurityPolicy/script-src-strict-dynamic-and-unsafe-inline-policies-expected.txt: Added.
* http/tests/security/contentSecurityPolicy/script-src-strict-dynamic-and-unsafe-inline-policies.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (293602 => 293603)


--- trunk/LayoutTests/ChangeLog	2022-04-29 01:46:53 UTC (rev 293602)
+++ trunk/LayoutTests/ChangeLog	2022-04-29 01:59:02 UTC (rev 293603)
@@ -1,3 +1,16 @@
+2022-04-28  Patrick Griffis  <[email protected]>
+
+        CSP: Fix mixing strict-dynamic and unsafe-inline policies
+        https://bugs.webkit.org/show_bug.cgi?id=239862
+
+        Reviewed by Kate Cheney.
+
+        If you had multiple policies, one including strict-dynamic and another with unsafe-inline, the unsafe-inline
+        policy was incorrectly handled.
+
+        * http/tests/security/contentSecurityPolicy/script-src-strict-dynamic-and-unsafe-inline-policies-expected.txt: Added.
+        * http/tests/security/contentSecurityPolicy/script-src-strict-dynamic-and-unsafe-inline-policies.html: Added.
+
 2022-04-28  Oriol Brufau  <[email protected]>
 
         [css-cascade] Mark properties sharing a computed value as related

Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/script-src-strict-dynamic-and-unsafe-inline-policies-expected.txt (0 => 293603)


--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/script-src-strict-dynamic-and-unsafe-inline-policies-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/script-src-strict-dynamic-and-unsafe-inline-policies-expected.txt	2022-04-29 01:59:02 UTC (rev 293603)
@@ -0,0 +1,2 @@
+CONSOLE MESSAGE: allowed
+

Added: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/script-src-strict-dynamic-and-unsafe-inline-policies.html (0 => 293603)


--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/script-src-strict-dynamic-and-unsafe-inline-policies.html	                        (rev 0)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/script-src-strict-dynamic-and-unsafe-inline-policies.html	2022-04-29 01:59:02 UTC (rev 293603)
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+<html lang="en">
+  <head>
+    <!-- This tests that we properly handle multiple policies when one includes strict-dynamic and another unsafe-inline. -->
+    <meta http-equiv="Content-Security-Policy" content="script-src 'nonce-dummy' 'strict-dynamic'">
+    <meta http-equiv="Content-Security-Policy" content="script-src 'unsafe-inline'">
+    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+    <script nonce="dummy">
+      if (window.testRunner) {
+        testRunner.dumpAsText();
+      }
+    </script>
+  </head>
+  <body>
+    <script type="text/_javascript_" nonce="dummy">console.log('allowed');</script>
+  </body>
+</html>
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (293602 => 293603)


--- trunk/Source/WebCore/ChangeLog	2022-04-29 01:46:53 UTC (rev 293602)
+++ trunk/Source/WebCore/ChangeLog	2022-04-29 01:59:02 UTC (rev 293603)
@@ -1,3 +1,15 @@
+2022-04-28  Patrick Griffis  <[email protected]>
+
+        CSP: Fix mixing strict-dynamic and unsafe-inline policies
+        https://bugs.webkit.org/show_bug.cgi?id=239862
+
+        Reviewed by Kate Cheney.
+
+        Test: http/tests/security/contentSecurityPolicy/script-src-strict-dynamic-and-unsafe-inline-policies.html
+
+        * page/csp/ContentSecurityPolicyDirectiveList.cpp:
+        (WebCore::ContentSecurityPolicyDirectiveList::violatedDirectiveForNonParserInsertedScripts const):
+
 2022-04-28  Oriol Brufau  <[email protected]>
 
         [css-cascade] Mark properties sharing a computed value as related

Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp (293602 => 293603)


--- trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp	2022-04-29 01:46:53 UTC (rev 293602)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp	2022-04-29 01:59:02 UTC (rev 293603)
@@ -246,7 +246,8 @@
     if (checkHashes(operativeDirective, hashes)
         || checkNonParserInsertedScripts(operativeDirective, parserInserted)
         || checkNonce(operativeDirective, nonce)
-        || checkSource(operativeDirective, url))
+        || checkSource(operativeDirective, url)
+        || (url.isEmpty() && checkInline(operativeDirective)))
         return nullptr;
     return operativeDirective;
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to