Title: [289022] trunk
Revision
289022
Author
[email protected]
Date
2022-02-02 18:17:13 -0800 (Wed, 02 Feb 2022)

Log Message

CSP: Implement wasm-unsafe-eval
https://bugs.webkit.org/show_bug.cgi?id=235408

Reviewed by Kate Cheney.

LayoutTests/imported/w3c:

Update expectations with new passes.

* web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any-expected.txt:
* web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any.serviceworker-expected.txt:
* web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any.worker-expected.txt:
* web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any-expected.txt:
* web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any.serviceworker-expected.txt:
* web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any.worker-expected.txt:

Source/WebCore:

This is similar to 'unsafe-eval' except limited in scope to WebAssembly.

* page/csp/ContentSecurityPolicyDirectiveList.cpp:
(WebCore::checkWasmEval):
(WebCore::ContentSecurityPolicyDirectiveList::create):
* page/csp/ContentSecurityPolicySourceList.cpp:
(WebCore::ContentSecurityPolicySourceList::parseSource):
* page/csp/ContentSecurityPolicySourceList.h:
(WebCore::ContentSecurityPolicySourceList::allowWasmEval const):
* page/csp/ContentSecurityPolicySourceListDirective.h:
(WebCore::ContentSecurityPolicySourceListDirective::allowWasmEval const):

LayoutTests:

Update expectations with new CSP message.

* http/tests/security/contentSecurityPolicy/WebAssembly-blocked-expected.txt:
* http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-about-blank-iframe-expected.txt:
* http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-external-script-expected.txt:
* http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-subframe-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (289021 => 289022)


--- trunk/LayoutTests/ChangeLog	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/LayoutTests/ChangeLog	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,5 +1,19 @@
 2022-02-02  Patrick Griffis  <[email protected]>
 
+        CSP: Implement wasm-unsafe-eval
+        https://bugs.webkit.org/show_bug.cgi?id=235408
+
+        Reviewed by Kate Cheney.
+
+        Update expectations with new CSP message.
+
+        * http/tests/security/contentSecurityPolicy/WebAssembly-blocked-expected.txt:
+        * http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-about-blank-iframe-expected.txt:
+        * http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-external-script-expected.txt:
+        * http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-subframe-expected.txt:
+
+2022-02-02  Patrick Griffis  <[email protected]>
+
         CSP: Fix matching wildcard hosts
         https://bugs.webkit.org/show_bug.cgi?id=235992
 

Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/WebAssembly-blocked-expected.txt (289021 => 289022)


--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/WebAssembly-blocked-expected.txt	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/WebAssembly-blocked-expected.txt	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,13 +1,13 @@
-CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
 
-CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
 
-CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
 
-CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
 
-CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
 
-CONSOLE MESSAGE: CompileError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: CompileError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
  (evaluating 'new WebAssembly.Instance(new WebAssembly.Module(empty))')
 

Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-about-blank-iframe-expected.txt (289021 => 289022)


--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-about-blank-iframe-expected.txt	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-about-blank-iframe-expected.txt	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,4 +1,4 @@
 ALERT: /PASS/
-CONSOLE MESSAGE: CompileError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: CompileError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
  (evaluating 'new WebAssembly.Instance(new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x1, 0x00, 0x00, 0x00)))')
  WebAssembly should be blocked in the iframe, but inline script should be allowed.

Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-external-script-expected.txt (289021 => 289022)


--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-external-script-expected.txt	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-external-script-expected.txt	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,3 +1,3 @@
-CONSOLE MESSAGE: CompileError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'".
+CONSOLE MESSAGE: CompileError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline'".
  (evaluating 'new WebAssembly.Instance(new WebAssembly.Module(Uint8Array.of(0x0, 0x61, 0x73, 0x6d, 0x1, 0x00, 0x00, 0x00)))')
 

Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-subframe-expected.txt (289021 => 289022)


--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-subframe-expected.txt	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/WebAssembly-blocked-in-subframe-expected.txt	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,14 +1,14 @@
-CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
 
-CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
 
-CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
 
-CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
 
-CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: EvalError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
 
-CONSOLE MESSAGE: CompileError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
+CONSOLE MESSAGE: CompileError: Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'unsafe-inline'".
  (evaluating 'new WebAssembly.Instance(new WebAssembly.Module(empty))')
 Tests that WebAssembly is blocked in a subframe that disallows WebAssembly when the parent frame allows WebAssembly.
 

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (289021 => 289022)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,5 +1,21 @@
 2022-02-02  Patrick Griffis  <[email protected]>
 
+        CSP: Implement wasm-unsafe-eval
+        https://bugs.webkit.org/show_bug.cgi?id=235408
+
+        Reviewed by Kate Cheney.
+
+        Update expectations with new passes.
+
+        * web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any-expected.txt:
+        * web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any.serviceworker-expected.txt:
+        * web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any.worker-expected.txt:
+        * web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any-expected.txt:
+        * web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any.serviceworker-expected.txt:
+        * web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any.worker-expected.txt:
+
+2022-02-02  Patrick Griffis  <[email protected]>
+
         CSP: Fix matching wildcard hosts
         https://bugs.webkit.org/show_bug.cgi?id=235992
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any-expected.txt (289021 => 289022)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any-expected.txt	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any-expected.txt	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,4 +1,3 @@
 
-FAIL default-src-wasm-unsafe-eval-allows-wasm promise_test: Unhandled rejection with value: object "CompileError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'".
-"
+PASS default-src-wasm-unsafe-eval-allows-wasm
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any.serviceworker-expected.txt (289021 => 289022)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any.serviceworker-expected.txt	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any.serviceworker-expected.txt	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,4 +1,3 @@
 
-FAIL default-src-wasm-unsafe-eval-allows-wasm promise_test: Unhandled rejection with value: object "CompileError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'".
-"
+PASS default-src-wasm-unsafe-eval-allows-wasm
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any.worker-expected.txt (289021 => 289022)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any.worker-expected.txt	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/default-src-wasm-unsafe-eval-allows-wasm.any.worker-expected.txt	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,4 +1,3 @@
 
-FAIL default-src-wasm-unsafe-eval-allows-wasm promise_test: Unhandled rejection with value: object "CompileError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'".
-"
+PASS default-src-wasm-unsafe-eval-allows-wasm
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any-expected.txt (289021 => 289022)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any-expected.txt	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any-expected.txt	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,4 +1,3 @@
 
-FAIL script-src-wasm-unsafe-eval-allows-wasm promise_test: Unhandled rejection with value: object "CompileError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'".
-"
+PASS script-src-wasm-unsafe-eval-allows-wasm
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any.serviceworker-expected.txt (289021 => 289022)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any.serviceworker-expected.txt	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any.serviceworker-expected.txt	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,4 +1,3 @@
 
-FAIL script-src-wasm-unsafe-eval-allows-wasm promise_test: Unhandled rejection with value: object "CompileError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'".
-"
+PASS script-src-wasm-unsafe-eval-allows-wasm
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any.worker-expected.txt (289021 => 289022)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any.worker-expected.txt	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/wasm-unsafe-eval/script-src-wasm-unsafe-eval-allows-wasm.any.worker-expected.txt	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,4 +1,3 @@
 
-FAIL script-src-wasm-unsafe-eval-allows-wasm promise_test: Unhandled rejection with value: object "CompileError: Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' 'unsafe-inline' 'wasm-unsafe-eval'".
-"
+PASS script-src-wasm-unsafe-eval-allows-wasm
 

Modified: trunk/Source/WebCore/ChangeLog (289021 => 289022)


--- trunk/Source/WebCore/ChangeLog	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/Source/WebCore/ChangeLog	2022-02-03 02:17:13 UTC (rev 289022)
@@ -1,5 +1,24 @@
 2022-02-02  Patrick Griffis  <[email protected]>
 
+        CSP: Implement wasm-unsafe-eval
+        https://bugs.webkit.org/show_bug.cgi?id=235408
+
+        Reviewed by Kate Cheney.
+
+        This is similar to 'unsafe-eval' except limited in scope to WebAssembly.
+
+        * page/csp/ContentSecurityPolicyDirectiveList.cpp:
+        (WebCore::checkWasmEval):
+        (WebCore::ContentSecurityPolicyDirectiveList::create):
+        * page/csp/ContentSecurityPolicySourceList.cpp:
+        (WebCore::ContentSecurityPolicySourceList::parseSource):
+        * page/csp/ContentSecurityPolicySourceList.h:
+        (WebCore::ContentSecurityPolicySourceList::allowWasmEval const):
+        * page/csp/ContentSecurityPolicySourceListDirective.h:
+        (WebCore::ContentSecurityPolicySourceListDirective::allowWasmEval const):
+
+2022-02-02  Patrick Griffis  <[email protected]>
+
         CSP: Fix matching wildcard hosts
         https://bugs.webkit.org/show_bug.cgi?id=235992
 

Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp (289021 => 289022)


--- trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicyDirectiveList.cpp	2022-02-03 02:17:13 UTC (rev 289022)
@@ -51,6 +51,11 @@
     return !directive || directive->allowEval();
 }
 
+static inline bool checkWasmEval(ContentSecurityPolicySourceListDirective* directive)
+{
+    return !directive || directive->allowWasmEval();
+}
+
 static inline bool checkInline(ContentSecurityPolicySourceListDirective* directive)
 {
     return !directive || directive->allowInline();
@@ -140,11 +145,12 @@
     auto directives = makeUnique<ContentSecurityPolicyDirectiveList>(policy, type);
     directives->parse(header, from);
 
-    if (!checkEval(directives->operativeDirective(directives->m_scriptSrc.get(), ContentSecurityPolicyDirectiveNames::scriptSrc))) {
+    if (!checkEval(directives->operativeDirective(directives->m_scriptSrc.get(), ContentSecurityPolicyDirectiveNames::scriptSrc)))
         directives->setEvalDisabledErrorMessage(makeString("Refused to evaluate a string as _javascript_ because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: \"", directives->operativeDirective(directives->m_scriptSrc.get(), ContentSecurityPolicyDirectiveNames::scriptSrc)->text(), "\".\n"));
-        directives->setWebAssemblyDisabledErrorMessage(makeString("Refused to create a WebAssembly object because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: \"", directives->operativeDirective(directives->m_scriptSrc.get(), ContentSecurityPolicyDirectiveNames::scriptSrc)->text(), "\".\n"));
-    }
 
+    if (!checkWasmEval(directives->operativeDirective(directives->m_scriptSrc.get(), ContentSecurityPolicyDirectiveNames::scriptSrc)))
+        directives->setWebAssemblyDisabledErrorMessage(makeString("Refused to create a WebAssembly object because 'unsafe-eval' or 'wasm-unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: \"", directives->operativeDirective(directives->m_scriptSrc.get(), ContentSecurityPolicyDirectiveNames::scriptSrc)->text(), "\".\n"));
+
     if (directives->isReportOnly() && directives->reportURIs().isEmpty())
         policy.reportMissingReportURI(header);
 

Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp (289021 => 289022)


--- trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp	2022-02-03 02:17:13 UTC (rev 289022)
@@ -253,9 +253,15 @@
 
     if (skipExactlyIgnoringASCIICase(buffer, "'unsafe-eval'")) {
         m_allowEval = true;
+        m_allowWasmEval = true;
         return source;
     }
-    
+
+    if (skipExactlyIgnoringASCIICase(buffer, "'wasm-unsafe-eval'")) {
+        m_allowWasmEval = true;
+        return source;
+    }
+
     if (skipExactlyIgnoringASCIICase(buffer, "'unsafe-hashes'")) {
         m_allowUnsafeHashes = true;
         return source;

Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.h (289021 => 289022)


--- trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.h	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceList.h	2022-02-03 02:17:13 UTC (rev 289022)
@@ -52,6 +52,7 @@
 
     bool allowInline() const { return m_allowInline && m_hashes.isEmpty() && m_nonces.isEmpty(); }
     bool allowEval() const { return m_allowEval; }
+    bool allowWasmEval() const { return m_allowWasmEval; }
     bool allowSelf() const { return m_allowSelf; }
     bool isNone() const { return m_isNone; }
     bool allowNonParserInsertedScripts() const { return m_allowNonParserInsertedScripts; }
@@ -95,6 +96,7 @@
     bool m_allowStar { false };
     bool m_allowInline { false };
     bool m_allowEval { false };
+    bool m_allowWasmEval { false };
     bool m_isNone { false };
     bool m_allowNonParserInsertedScripts { false };
     bool m_allowUnsafeHashes { false };

Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceListDirective.h (289021 => 289022)


--- trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceListDirective.h	2022-02-03 02:00:11 UTC (rev 289021)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicySourceListDirective.h	2022-02-03 02:17:13 UTC (rev 289022)
@@ -45,6 +45,7 @@
     bool allows(const String& nonce) const;
     bool allowInline() const { return m_sourceList.allowInline(); }
     bool allowEval() const { return m_sourceList.allowEval(); }
+    bool allowWasmEval() const { return m_sourceList.allowWasmEval(); }
     bool allowNonParserInsertedScripts() const { return m_sourceList.allowNonParserInsertedScripts(); }
     bool shouldReportSample() const { return m_sourceList.shouldReportSample(); }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to