Changeset 287270 in webkit
- Timestamp:
- Dec 20, 2021 12:12:52 PM (7 months ago)
- Location:
- trunk
- Files:
-
- 2 deleted
- 8 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scripthash-tests-expected.txt (modified) (2 diffs)
-
LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scripthash-tests.html (modified) (2 diffs)
-
LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scripthash-unicode-normalization-expected.txt (deleted)
-
LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scripthash-unicode-normalization.html (deleted)
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/script-src/hash-always-converted-to-utf-8/utf-8-lone-surrogate-expected.txt (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/script-src/scripthash-unicode-normalization.sub-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/page/csp/ContentSecurityPolicy.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r287266 r287270 1 2021-12-20 Patrick Griffis <pgriffis@igalia.com> 2 3 CSP: Always use UTF-8 encoded content when checking hashes 4 https://bugs.webkit.org/show_bug.cgi?id=234159 5 6 Reviewed by Kate Cheney. 7 8 Remove normalization tests that are counter to WPT's CSP normalization tests. 9 10 * http/tests/security/contentSecurityPolicy/1.1/scripthash-tests-expected.txt: 11 * http/tests/security/contentSecurityPolicy/1.1/scripthash-tests.html: 12 * http/tests/security/contentSecurityPolicy/1.1/scripthash-unicode-normalization-expected.txt: Removed. 13 * http/tests/security/contentSecurityPolicy/1.1/scripthash-unicode-normalization.html: Removed. 14 1 15 2021-12-20 Tim Nguyen <ntim@apple.com> 2 16 -
trunk/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scripthash-tests-expected.txt
r286853 r287270 1 CONSOLE MESSAGE: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy. 1 2 CONSOLE MESSAGE: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy. 2 3 CONSOLE MESSAGE: Refused to execute a script because its hash, its nonce, or 'unsafe-inline' does not appear in the script-src directive of the Content Security Policy. … … 42 43 PASS "Script that contains Unicode code point U+00C5" did run inline script. 43 44 PASS "Unicode code point U+00C5 is not equivalent to U+212B" did not run inline script. 44 PASS "Unicode code point U+212B is equivalent to U+00C5" did run inline script. 45 PASS "Big-5 page with Big-5 hash" did run inline script. 45 PASS "Big-5 page with Big-5 hash" did not run inline script. 46 46 PASS "Big-5 page with UTF-8 hash" did not run inline script. 47 47 PASS "Hash source with invalid prefix" did not run inline script. -
trunk/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scripthash-tests.html
r286853 r287270 83 83 expectedResult: DoNotRunInlineScript, 84 84 }, 85 {86 name: "Unicode code point U+212B is equivalent to U+00C5",87 charset: "UTF8",88 script: "didRunInlineScript+%3D+true%3B+//+%E2%84%AB", // %E2%84%AB is the URL encoded UTF-8 byte sequence for U+212B.89 hashSource: "'sha256-K3oo3dJj28X47TIh/UinhDWS3C5DfcQVCRzw4JM7SWE='", // Intentionally not 'sha256-rrdh0QCl46qqHxfnnk08ydh/rkhVi2JvD6DLuUP30MI='90 expectedResult: RunInlineScript,91 },92 85 // Big-5 encoding test cases 93 86 { … … 96 89 script: "didRunInlineScript+%3D+true%3B+//+%A4%F4", 97 90 hashSource: "'sha256-CAEkHFV/oUoz+L2Oa6gIFelb73og89vCbxrz4u/jAY4='", 98 expectedResult: RunInlineScript,91 expectedResult: DoNotRunInlineScript, 99 92 }, 100 93 { -
trunk/LayoutTests/imported/w3c/ChangeLog
r287266 r287270 1 2021-12-20 Patrick Griffis <pgriffis@igalia.com> 2 3 CSP: Always use UTF-8 encoded content when checking hashes 4 https://bugs.webkit.org/show_bug.cgi?id=234159 5 6 Reviewed by Kate Cheney. 7 8 Update expectations as passing. 9 10 * web-platform-tests/content-security-policy/script-src/hash-always-converted-to-utf-8/utf-8-lone-surrogate-expected.txt: 11 * web-platform-tests/content-security-policy/script-src/scripthash-unicode-normalization.sub-expected.txt: 12 1 13 2021-12-20 Tim Nguyen <ntim@apple.com> 2 14 -
trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/script-src/hash-always-converted-to-utf-8/utf-8-lone-surrogate-expected.txt
r283111 r287270 1 1 2 FAIL Should convert the script contents to UTF-8 before hashing assert_unreached: Should not have fired a spv Reached unreachable code 2 PASS Should convert the script contents to UTF-8 before hashing 3 3 -
trunk/LayoutTests/imported/w3c/web-platform-tests/content-security-policy/script-src/scripthash-unicode-normalization.sub-expected.txt
r267651 r287270 2 2 3 3 4 Harness Error (TIMEOUT), message = null 4 PASS Should fire securitypolicyviolation 5 PASS Only matching content runs even with NFC normalization. 5 6 6 NOTRUN Should fire securitypolicyviolation7 FAIL Only matching content runs even with NFC normalization. assert_unreached: nonMatchingContent script ran Reached unreachable code8 -
trunk/Source/WebCore/ChangeLog
r287268 r287270 1 2021-12-20 Patrick Griffis <pgriffis@igalia.com> 2 3 CSP: Always use UTF-8 encoded content when checking hashes 4 https://bugs.webkit.org/show_bug.cgi?id=234159 5 6 Reviewed by Kate Cheney. 7 8 As per the spec: https://www.w3.org/TR/CSP3/#match-element-to-source-list 9 > Regardless of the encoding of the document, source will be converted to UTF-8 10 before applying any hashing algorithms. 11 12 StrictConversionReplacingUnpairedSurrogatesWithFFFD matches Chromiums behavior. 13 14 * page/csp/ContentSecurityPolicy.cpp: 15 (WebCore::ContentSecurityPolicy::findHashOfContentInPolicies const): 16 1 17 2021-12-20 Fujii Hironori <Hironori.Fujii@sony.com> 2 18 -
trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp
r286853 r287270 363 363 return { false, false }; 364 364 365 // FIXME: We should compute the document encoding once and cache it instead of computing it on each invocation. 366 PAL::TextEncoding documentEncoding; 367 if (is<Document>(m_scriptExecutionContext)) 368 documentEncoding = downcast<Document>(*m_scriptExecutionContext).textEncoding(); 369 const PAL::TextEncoding& encodingToUse = documentEncoding.isValid() ? documentEncoding : PAL::UTF8Encoding(); 370 371 // FIXME: Compute the digest with respect to the raw bytes received from the page. 372 // See <https://bugs.webkit.org/show_bug.cgi?id=155184>. 373 auto encodedContent = encodingToUse.encode(content, PAL::UnencodableHandling::Entities); 365 CString utf8Content = content.utf8(StrictConversionReplacingUnpairedSurrogatesWithFFFD); 374 366 bool foundHashInEnforcedPolicies = false; 375 367 bool foundHashInReportOnlyPolicies = false; 376 368 Vector<ContentSecurityPolicyHash> hashes; 377 369 for (auto algorithm : algorithms) { 378 auto hash = cryptographicDigestForBytes(algorithm, encodedContent.data(), encodedContent.size());370 auto hash = cryptographicDigestForBytes(algorithm, utf8Content.data(), utf8Content.length()); 379 371 hashes.append(hash); 380 372 }
Note: See TracChangeset
for help on using the changeset viewer.