Closed Bug 2075014 Opened 2 months ago Closed 24 days ago

[wpt-sync] Sync PR 62906 - [Blink] Resolve CSS Image and Font values per-document

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 62906 into mozilla-central (this bug is closed when the sync is complete).

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

Hoch Hochkeppel <mhochk@microsoft.com> wrote:

[Blink] Resolve CSS Image and Font values per-document

CSS style resources referenced from a stylesheet were cached directly on
the CSSValue objects owned by StyleSheetContents. Because two
same-origin documents that link the same stylesheet share a single
StyleSheetContents instance, a resource already fetched by the first
document was reused by the second document without any fetch of its own.
This let the second document display a resource that its own Content
Security Policy would have blocked, defeating per-document CSP
enforcement.

This change caches each fetched style resource in a per-ResourceFetcher
map keyed on the requesting document's fetcher, rather than in a single
shared slot. A document whose fetcher has not fetched the resource now
re-fetches it under its own CSP. The performance and memory impact
should usually be minimal due to the re-fetch resolving in the
MemoryCache instead of the network, but that is not guaranteed (e.g.
if the resource was marked no-store). Same-fetcher lookups still hit the
cache, so there is no additional fetching within a single document.

A null ResourceFetcher route is still supported for contexts that have
no fetcher (e.g. cross-thread style values).

A route for taking a snapshot (used by StyleFetchedImage) is also
introduced, with the snapshot being available in all contexts regardless
of ResourceFetcher.

The new behavior is on-by-default, but gated behind the
StyleResourceFetcherIdentityCheck runtime-enabled feature in case it
needs to be stopped.

This change does not attempt to key based on the CSP or an initial
CanRequest result. That would validate only the starting CSP decision,
not the full set of per-document request checks an actual fetch performs
(e.g. each stage of redirects, or resulting URL differing from requested
URL).

Authorship of these WPTs is attributed to Dileep, based on
crrev.com/c/7867457

Fixed: 504107363
Change-Id: Icd98ac13320cfc7238a7236c23e83143b7359144
Reviewed-on: https://chromium-review.googlesource.com/8410893
WPT-Export-Revision: 318df78cd096958b702299c348fc6b38f3eb2aa0

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 28 tests and 1 subtests

Status Summary

Firefox

OK : 2[GitHub] 21[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] 22[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 : 5[GitHub] 25[Gecko-windows11-32-25h2-opt] 26[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-windows11-32-25h2-debug] 27[Gecko-android-em-14-x86_64-opt-geckoview, Gecko-linux2404-64-debug] 28[Gecko-linux2404-64-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt]
FAIL : 1[Gecko-windows11-32-25h2-debug] 2[Gecko-windows11-32-25h2-opt] 3[GitHub] 4[Gecko-android-em-14-x86_64-opt-geckoview] 5[Gecko-android-em-14-x86_64-debug-geckoview, Gecko-android-em-14-x86_64-lite-opt-geckoview, Gecko-linux2404-64-opt, Gecko-windows11-64-25h2-debug, Gecko-windows11-64-25h2-opt] 6[Gecko-linux2404-64-debug]

Chrome

OK : 2
PASS : 4
FAIL : 4

Safari

OK : 2
PASS : 3
FAIL : 2
TIMEOUT: 3

Links

Gecko CI (Treeherder)
GitHub PR Head
GitHub PR Base

Details

New Tests That Don't Pass

Tests Disabled in Gecko Infrastructure

  • /content-security-policy/img-src/icon-blocked.sub.html [wpt.fyi]: OK [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], SKIP [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]
Status: NEW → RESOLVED
Closed: 24 days ago
Resolution: --- → FIXED
Target Milestone: --- → 162 Branch
You need to log in before you can comment on or make changes to this bug.