Closed Bug 2091295 Opened 10 days ago Closed

[wpt-sync] Sync PR 64491 - WebKit export of https://bugs.webkit.org/show_bug.cgi?id=322934

Categories

(Core :: DOM: Security, task, P4)

task

Tracking

()

RESOLVED FIXED
162 Branch
Tracking Status
firefox162 --- fixed

People

(Reporter: wpt-sync, Unassigned)

References

()

Details

(Whiteboard: [wptsync downstream])

Sync web-platform-tests PR 64491 into mozilla-central (this bug is closed when the sync is complete).

PR: https://github.com/web-platform-tests/wpt/pull/64491
Details from upstream follow.

Roberto Rodriguez <roberto_rodriguez2@apple.com> wrote:

WebKit export of https://bugs.webkit.org/show_bug.cgi?id=322934

WebKit export from bug: CSP style-<!---->src-<!---->attr does not block a style attribute parsed in a document with no browsing context

<pre>
CSP style-src-attr does not block a style attribute parsed in a document with no browsing context

StyledElement::styleAttributeChanged() checks a style attribute against the policy of the
element's own document when the attribute is set. A document created by DOMParser,
createHTMLDocument or a template has no browsing context and starts with an empty policy,
so the check allows the attribute and the parsed style stays on the element. When the
element moves into a page whose policy sets style-src-attr to none, nothing checks the
style again and it is applied. CSP Level 3 4.2.3 defines this check, and HTML section
3.2.6.5 requires that blocked style rules are not applied to the element.

Fix by checking the style attribute against the policy of the document returned by
contextDocument(). That is the document recorded as the creator of a DOMParser result,
a createHTMLDocument document or template contents, and the element's own document when
none is recorded. Add three web-platform tests for the DOMParser, createHTMLDocument
and template paths.

WebKit-Bug: <a href="https://bugs.webkit.org/show_bug.cgi?id=322934">https://bugs.webkit.org/show_bug.cgi?id=322934</a>
WebKit-Canonical-Link: <a href="https://commits.webkit.org/322461@main">https://commits.webkit.org/322461@main</a>
</pre>

Component: web-platform-tests → DOM: Security
Product: Testing → Core

CI Results

Ran 9 Firefox configurations based on mozilla-central, and Firefox, Chrome, and Safari on GitHub CI

Total 45 tests and 2 subtests

Status Summary

Firefox

OK : 3[GitHub] 43[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
PASS : 6[GitHub] 86[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug, Gecko-linux2404-64-opt, Gecko-windows11-32-25h2-debug, Gecko-windows11-32-25h2-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
FAIL : 3

Chrome

OK : 2
PASS : 5
TIMEOUT: 1
NOTRUN : 1

Safari

OK : 3
PASS : 6

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Tests Disabled in Gecko Infrastructure

Status: NEW → RESOLVED
Closed: 6 days ago
Closed: 6 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.