Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 0234ea9857fdf248287ecf0bfc5521566a5282e4
      
https://github.com/WebKit/WebKit/commit/0234ea9857fdf248287ecf0bfc5521566a5282e4
  Author: Roberto Rodriguez <[email protected]>
  Date:   2026-10-01 (Thu, 01 Oct 2026)

  Changed paths:
    M 
LayoutTests/http/tests/security/contentSecurityPolicy/extensions/manifest-v3/default-src/manifest-v3-default-src-block-non-https-scheme.html
    M 
LayoutTests/http/tests/security/contentSecurityPolicy/extensions/manifest-v3/script-src/manifest-v3-script-src-block-non-https-scheme.html
    A 
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/parsing/keyword-source-with-trailing-characters-expected.txt
    A 
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/parsing/keyword-source-with-trailing-characters.html
    M Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp

  Log Message:
  -----------
  CSP keyword source expressions must match the whole token
https://bugs.webkit.org/show_bug.cgi?id=319577
rdar://183020796

Reviewed by Anne van Kesteren.

ContentSecurityPolicySourceList::parseSource() checks a keyword source
expression such as 'self' or 'unsafe-inline' by testing only that the
token starts with the keyword. A token with extra characters after a
valid keyword like 'unsafe-inline'X is treated as a normal keyword
instead of being rejected.

Fix by comparing each keyword, including 'none', against the whole token
with equalIgnoringASCIICase() instead of matching a prefix. A token that
does not match a keyword exactly now falls through to host source
parsing, which rejects it. This follows the CSP Level 3 grammar.
https://w3c.github.io/webappsec-csp/#grammardef-keyword-source

Adds a new test and updates two existing tests to account for this
change.

Test: 
imported/w3c/web-platform-tests/content-security-policy/parsing/keyword-source-with-trailing-characters.html

* 
LayoutTests/http/tests/security/contentSecurityPolicy/extensions/manifest-v3/default-src/manifest-v3-default-src-block-non-https-scheme.html:
* 
LayoutTests/http/tests/security/contentSecurityPolicy/extensions/manifest-v3/script-src/manifest-v3-script-src-block-non-https-scheme.html:
* 
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/parsing/keyword-source-with-trailing-characters-expected.txt:
 Added.
* 
LayoutTests/imported/w3c/web-platform-tests/content-security-policy/parsing/keyword-source-with-trailing-characters.html:
 Added.
* Source/WebCore/page/csp/ContentSecurityPolicySourceList.cpp:
(WebCore::ContentSecurityPolicySourceList::parseSource):

Canonical link: https://commits.webkit.org/322470@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to