Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inconsistent support for wildcards in content security policy overrides #163

Open
dotproto opened this issue Feb 11, 2022 · 3 comments
Open
Labels
inconsistency Inconsistent behavior across browsers topic: csp Related to content security policy enforcement

Comments

@dotproto
Copy link
Member

dotproto commented Feb 11, 2022

This Twitter exchange made me realize that Chrome, Firefox, and Safari do not have a consistent approach to wildcard sources for CSP source values.

As @xeenon noted, MDN's content_security_policy docs state that "All sources must specify a host." As a result, * is not a valid source value. Both Firefox and Safari support this limitation, but Chrome does not.

A material result of this divergence is that extension authors are able to display images on extension pages from arbitrary origins in Chrome by including img-src *; in their extension's CSP, but they cannot do this in Firefox or Safari. Instead, authors targeting Firefox and safari must either manually specify all known origins in their img-src directive or use a workarounds like proxying images requests.

Public signals from browsers

@dotproto dotproto added the inconsistency Inconsistent behavior across browsers label Feb 11, 2022
@zombie
Copy link
Collaborator

zombie commented Feb 17, 2022

It seems this was a documentation error on MDN (based on unclear comments in Firefox code). We don't block the wildcard * from non-script sources, see bug 1752309 comment 3 and comment 5 for more details.

We'll be fixing the wording on MDN, and can mention Safari differences unless they want to align the behavior with Chromium and Firefox.

@Rob--W
Copy link
Member

Rob--W commented Feb 17, 2022

Safari also intends to align the behavior with Chromium and Firefox: https://bugzilla.mozilla.org/show_bug.cgi?id=1752309#c8

This issue can therefore be closed. In the future it may make sense to specify the desired behavior of CSP.

@carlosjeurissen
Copy link
Contributor

carlosjeurissen commented Feb 17, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
inconsistency Inconsistent behavior across browsers topic: csp Related to content security policy enforcement
Projects
None yet
Development

No branches or pull requests

4 participants