-
Notifications
You must be signed in to change notification settings - Fork 149
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
CSP3: The effect of multiple policies #515
Comments
I think this spec doesn't need to be responsible for defining UA behavior around headers, but I do think it should be clear about the situation in which two headers are present. Chrome deals with this by splitting on I think the CSP3 spec mandates this behavior today by defining the header's grammar as |
(Also, please keep filing bugs! But please file them against https://github.com/w3c/webappsec-csp/issues rather than the generic webappsec repo. :) ) |
Oops, sorry! There were a bunch of CSP bugs in this repo, so I didn't realize there was a separate place I should file. Anyways, regardless of UA behavior, I just feel like the example given should be the most likely scenario — that is, that of a CSP header and a CSP meta tag — and not multiple HTTP headers, something that the HTTP specification says that senders MUST NOT do, despite frequently doing it anyways. |
This affects CSP2 as well, but I don't think it's likely to get updated there.
The example used is this:
In reality, it seems pretty much every user agent I've seen just joins multiple copies of the same header (except Set-Cookie) together with
,
or,
. This is in violation of RFC 7230, but they all do it anyways -- something I only found because it broke a lot of my HTTP Observatory scans. It doesn't help that the RFC 7230 isn't particularly clear on what clients should do if they can't be joined.When looking at Chrome with req.getAllResponseHeaders() with the CSP header, CSP headers are joined with
,
. Not sure if they're processed that way, but overall there's just a ton of weird things that happen in pretty much all HTTP clients when they receive the same header multiple times. So for this case, it gets processed like this:So I think it would get treated as
,
andconnect-src
, but possibly,connect-src
in other clients. Given the ambiguity, this whole long ramble-y post is my way of saying that the example should probably not use multipleContent-Security-Policy:
headers, and instead use a header and a meta tag.It's far more likely to occur anyways: in my scan of the Top 1M sites, multiple CSP headers only occurs once. This compares to about 3400 times for multiple X-Frame-Option headers.
The text was updated successfully, but these errors were encountered: