Repository navigation
Conversation
The analyzer only checked `script-src` and `style-src`, so policies that allow inline code via `script-src-attr`, `script-src-elem`, `style-src-attr` or `style-src-elem` were graded as safe. These directives override the base directive for their checks, so apply the same rules to them: `'unsafe-inline'` counts unless a nonce or hash is in the same list (CSP3 6.7.3.2), and the `-elem` variants also reject `data:` and overly broad sources.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Update the CSP analyzer to also check
script-src-elem,script-src-attr,style-src-elemandstyle-src-attr:'unsafe-inline'in all four, unless a nonce or hash is in the same source list.data:and overly broad sources in the-elemvariants, and apply the existing'strict-dynamic'handling toscript-src-elem.Motivation
Ensure that policies allowing inline code through these directives are no longer graded as free of
'unsafe-inline', since the directives overridescript-srcandstyle-srcfor their respective checks.Additional details
When a directive is absent, it falls back to its base directive, so policies without these directives keep their grade. Policies that use them can only stay the same or drop, e.g. the policy from the issue now gets
csp-implemented-with-unsafe-inline-in-style-src-only(0 instead of +5).Related issues and pull requests
Fixes #338.