Skip to content

fix(sri): grant same-origin bonus only if all scripts use SRI - #674

Open
caugner wants to merge 1 commit into
464-protocol-relative-urls-with-httpsfrom
464-sri-bonus-requires-all-scripts
Open

caugner wants to merge 1 commit into
464-protocol-relative-urls-with-httpsfrom
464-sri-bonus-requires-all-scripts

Conversation

@caugner

@caugner caugner commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Description

Update the subresource-integrity analyzer to grant the same-origin SRI bonus only when every same-origin script uses SRI:

  • Withhold SriImplementedAndAllScriptsLoadedSecurely (+5) when only some same-origin scripts have an integrity attribute.
  • Report SriImplementedAndExternalScriptsLoadedSecurely instead of SriImplementedAndAllScriptsLoadedSecurely when external scripts are present and all use SRI over HTTPS (same +5).

Motivation

Prevent a single same-origin script with SRI from earning the bonus for the whole page, and ensure the reported result matches the scripts actually loaded.

Additional details

Scripts Before After
/a.js with SRI + /b.js without sri-implemented-and-all-scripts-loaded-securely (+5) sri-not-implemented-but-all-scripts-loaded-from-secure-origin (0)
/a.js with SRI + https://cdn/b.js with SRI sri-implemented-and-all-scripts-loaded-securely (+5) sri-implemented-and-external-scripts-loaded-securely (+5)

Related issues and pull requests

Fixes #675.

Depends on:

@caugner
caugner added this pull request to stack #642 November 24, 2026 15:55
@caugner
caugner marked this pull request as ready for review November 24, 2026 16:23
@caugner
caugner requested a review from a team as a code owner November 24, 2026 16:23
@caugner
caugner requested a review from LeoMcA November 24, 2026 16:23
A single same-origin script with `integrity` earned
`SriImplementedAndAllScriptsLoadedSecurely` (+5), even when other
same-origin scripts lacked SRI. It also mislabeled pages whose external
scripts all use SRI over HTTPS as loading all scripts from a similar
origin.

Decide the result after the loop: require SRI on every same-origin
script for the bonus, and report `SriImplementedAndExternalScriptsLoadedSecurely`
whenever foreign scripts are present.
@caugner
caugner force-pushed the 464-sri-bonus-requires-all-scripts branch from cda7e46 to 4c4b191 Compare November 24, 2026 17:38

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SRI bonus granted when only some same-origin scripts use SRI

1 participant