Skip to content

Commit

Permalink
Add a few cases to preload SRI (#33326)
Browse files Browse the repository at this point in the history
* Add two cases to preload SRI

* Add test for stronger/weaker digest

* Fix expected results for video loading from multiple origins

See whatwg/html#7655

When loading video from multiple opaque origins (by a middleman service-worker),
video loading should fail rather than be alllowed and taint the canvas.

That's because some of the video responses may contain metadata such as duration that
would leak to the subsequent requests.

See whatwg/html#2814 (comment) for further details.

This change makes the test case pass in all browsers.

* Add another case
  • Loading branch information
noamr authored Mar 29, 2022
1 parent 3cf8b13 commit 6a214e8
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 4 deletions.
45 changes: 45 additions & 0 deletions preload/subresource-integrity.html
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,51 @@
{integrity: "sha256-deaddeadbeefYHFvsYdWumweeFAw0hJDTFt9seErghA="}
)

SRIPreloadTest(
true,
true,
`Same-origin ${destination} with matching digest does not reuse preload without digest.`,
2,
destination,
same_origin_prefix + destination + ext + `?${token()}`,
{},
{integrity: sha256}
)

// This is an acceptable failure
SRIPreloadTest(
true,
true,
`[Tentative] Same-origin ${destination} with matching digest does not reuse preload with matching but stronger digest.`,
2,
destination,
same_origin_prefix + destination + ext + `?${token()}`,
{integrity: sha384},
{integrity: sha256},
)

SRIPreloadTest(
true,
true,
`Same-origin ${destination} with matching digest does not reuse preload with matching but weaker digest.`,
2,
destination,
same_origin_prefix + destination + ext + `?${token()}`,
{integrity: sha256},
{integrity: sha384},
)

SRIPreloadTest(
true,
false,
`Same-origin ${destination} with non-matching digest reuses preload with no digest but fails.`,
2,
destination,
same_origin_prefix + destination + ext + `?${token()}`,
{},
{integrity: "sha256-sha256-deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdead"},
)

} // if.

} // for-of.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,11 @@

// (3) Range responses come from multiple origins. The first response comes from
// cross-origin (and without CORS sharing, so is opaque). Subsequent
// responses come from same-origin. The canvas should be tainted (but in
// Chrome this is a LOAD_ERROR since it disallows range responses from
// multiple origins, period).
// responses come from same-origin. This should result in a load error, as regardless of canvas
// loading range requests from multiple opaque origins can reveal information across those origins.
range_request_test(
'resources/range-request-to-different-origins-worker.js',
'TAINTED',
'LOAD_ERROR',
'range responses from multiple origins (cross-origin first)');

// (4) Range responses come from multiple origins. The first response comes from
Expand Down

0 comments on commit 6a214e8

Please sign in to comment.