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

CSP2: Default value of default-src is incorrect #514

Open
april opened this issue Apr 15, 2016 · 11 comments
Open

CSP2: Default value of default-src is incorrect #514

april opened this issue Apr 15, 2016 · 11 comments
Assignees

Comments

@april
Copy link

april commented Apr 15, 2016

Here is what the current specification says:

Let the default sources be the result of parsing the default-src directive’s value as a source list if a default-src directive is explicitly specified, and otherwise the U+002A ASTERISK character (*).

Which is incorrect, as it reads that these two statements are equivalent:

Content-Security-Policy: default-src *; upgrade-insecure-requests
Content-Security-Policy: upgrade-insecure-requests

The statement should probably read something like:

Let the default sources be the result of parsing the default-src directive’s value as a source list if a default-src directive is explicitly specified, and otherwise the list of all possible sources.

(cc: @hillbrad, as @mikewest told me to)

@april
Copy link
Author

april commented Apr 15, 2016

Note that this appears to be fixed in CSP3, as near as I can tell.

@mikewest
Copy link
Member

Yup. This is broken in CSP2. Although I think that we decided in some other bug that it didn't matter because CSP2 was so loosely specified that the * was never "enforced". Let me see if I can track that down.

@mikewest
Copy link
Member

w3c/webappsec-csp#9 (comment) is what I was thinking of. @hillbrad, @wseltzer, @dveditz: Is it worth revising CSP2 at this point? WDYT?

@april
Copy link
Author

april commented Apr 17, 2016

Well, I'm fine with this being loosely specified as well, just as long as it's clear that the two hand-wavingly vague definitions are distinct.

The browsers treat them very differently, and so this line was very confusing to me both when it came to writing documentation about CSP as well as when writing a CSP analyzer.

@mikewest
Copy link
Member

The browsers treat them very differently

Do you mean that browsers treat a missing default-src (like Content-Security-Policy: script-src 'self') differently? Or that * means something very different from "nothing"?

@april
Copy link
Author

april commented Apr 18, 2016

The latter. Not having a default-src is very different than default-src *, but the CSP2 spec implies that they are the same.

@hillbrad
Copy link
Contributor

So, by "fixed in CSP3" does that mean we expect different behavior from the
same policy strings? Or do you mean the existing behavior is more clearly
explained?

I think we can maybe punt on updating CSP2 if we verify by the test suite
that our implementations behave similarly. If they have diverged due to
unclear language we need to fix it.

On Mon, Apr 18, 2016 at 2:22 PM April King [email protected] wrote:

The latter. Not having a default-src is very different than default-src *,
but the CSP2 spec implies that they are the same.


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
#514 (comment)

@april
Copy link
Author

april commented Apr 18, 2016

The behavior hasn't changed in CSP3, it's just that the CSP3 accurately describes the implemented behavior where as CSP2 does not.

@hillbrad
Copy link
Contributor

Test shows that Chrome, Firefox and Safari Tech Preview are all compliant, so we can try to make this correction as a non-conformance affecting edit. (I'll manage that, @mikewest )

@mikewest
Copy link
Member

You are the best, @hillbrad. Thank you!

mikewest added a commit to w3c/webappsec-csp that referenced this issue Apr 25, 2016
This addresses w3c/webappsec#514 in the editor's draft. @hillbrad
will work out what that means for the CR->PR->REC transitions.
@mikewest
Copy link
Member

mikewest commented Apr 25, 2016

Fixed this in the editor's draft, using @marumari's suggestion. Brad, perhaps you could sneakily apply w3c/webappsec-csp@bc9577d to the CR? (Let's leave this bug open until that's addressed)

ryandel8834 added a commit to ryandel8834/WebAppSec-CSP that referenced this issue Aug 13, 2022
This addresses w3c/webappsec#514 in the editor's draft. @hillbrad
will work out what that means for the CR->PR->REC transitions.
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

No branches or pull requests

3 participants