Closed Bug 2004710 Opened 10 months ago Closed 9 months ago

SRI interprets certain invalid integrity attributes as having incorrect hash

Categories

(Core :: DOM: Security, defect)

defect

Tracking

()

RESOLVED FIXED
149 Branch
Tracking Status
firefox149 --- fixed

People

(Reporter: jrmuizel, Assigned: maltejur)

References

(Blocks 1 open bug, )

Details

(Keywords: webcompat:platform-bug)

User Story

user-impact-score:200

Attachments

(2 files, 1 external file, 1 obsolete file)

This is a reduced version of bug 2003813.

It seems like Chrome and Safari will not block css loads with integrity if the integrity field is malformed.

Attached file styles.css —
Attached file Test case (obsolete) —
Attached file Test case —
Attachment #9531480 - Attachment is obsolete: true
Blocks: 2003813
User Story: (updated)
Component: Networking → DOM: Security
See Also: → 1205448
Assignee: nobody → maltejur
Status: NEW → ASSIGNED

It looks like this was already raised in the WPT interop repo some time ago, and the SRI WPT has already been expanded to test this.

To quote from https://github.com/web-platform-tests/interop/issues/666#issue-2325261451:

<head>
<link rel="stylesheet" href="demo.css" >
</head>

It's loading normally.

<head>
<link rel="stylesheet" href="demo.css" integrity="..." crossorigin="anonymous">
</head>

The ressource will be allowed in Chrome, FF and Safari.

<head>
<link rel="stylesheet" href="demo.css" integrity="sha256-AAA" crossorigin="anonymous">
</head>

The ressource will be blocked in all thre browers.

<head>
<link rel="stylesheet" href="demo.css" integrity="sha256-..." crossorigin="anonymous">
</head>

The ressource will be allowed in Chrome and Safari but blocked in FF.

And from https://github.com/web-platform-tests/interop/issues/666#issuecomment-2675072474:

I think the spec for this is https://w3c.github.io/webappsec-subresource-integrity/#the-integrity-attribute and that the problem with the integrity="sha256-..." must be that Firefox treats "..." as an invalid or mismatching SHA-256 hash, instead of rejecting the whole "sha256-..." string as not matching the ABNF grammar in the spec.

In other words, I think Firefox isn't following the spec here. I couldn't find any tests for this, so I sent web-platform-tests/wpt#50875 using your example.

Blocks: SRI
See Also: → 1949837
Summary: CSS with invalid integrity attribute doesn't load → SRI interprets certain invalid integrity attributes as having incorrect hash
Pushed by agoloman@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/97f2a0770ea2 https://hg.mozilla.org/integration/autoland/rev/030b567cc3a2 Revert "Bug 2004710 - Check that SRI hash is in base64 format r=tschuster" for causing mochitest failures @test_bug_1364262.html.

Backed out for causing mochitest failures @test_bug_1364262.html.

Flags: needinfo?(maltejur)
Pushed by chorotan@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/686314543e5d https://hg.mozilla.org/integration/autoland/rev/22fb8c10d08c Revert "Bug 2004710 - Check that SRI hash is in base64 format r=tschuster" for causing wpt failures on preload/modulepreload.html

Backed out for causing wpt failures on preload/modulepreload.html

Backout link

Push with failures

Failure log

Flags: needinfo?(maltejur)

The severity field is not set for this bug.
:freddy, could you have a look please?

For more information, please visit BugBot documentation.

Flags: needinfo?(fbraun)
Severity: -- → S3
Flags: needinfo?(fbraun)
Created web-platform-tests PR https://github.com/web-platform-tests/wpt/pull/57243 for changes under testing/web-platform/tests
Status: ASSIGNED → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 149 Branch
Regressions: 2011303
Upstream PR merged by moz-wptsync-bot
QA Whiteboard: [qa-triage-done-c150/b149]
No longer regressions: 2011303
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: