-
Notifications
You must be signed in to change notification settings - Fork 705
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
[Bug] HTML-only headers are legitimate for non-HTML requests #3403
Comments
Thanks @chrisgraham ! We have a few hints about headers and the panorama across browsers is changing with new standards appearing or default behavior changing. We have a few issues open where we discussed this but we had to put on hold while we did some major refactoring in other areas. That work is almost done so maybe it is time to look again into this? Here are the list of open issues I've found:
At one moment we even talk about consolidating information into a single package. We would really appreciate your feedback on these. If you have a better idea or preference please share it. Additionally, we've updated the reported severity for all the hints (the code should ship sometime this week, it's part of the major refactor I talked earlier). The new severities are indicated in each of the following issues:
Pinging @Malvoz just in case he has missed this issue. He's been very active in all these issues 😁 |
The issue to iterate over CSP rules is #25. But I'll answer here and we can reference or move over any conclusions as needed. Sending headers based on media-types is an approach that is inherently error prone, for several reasons:
While the easiest thing to do is to just send the header for everything, the downside is, as stated already, the performance hit when doing so, especially if the header value is really large. The folks creating HTTP headers are very much taking into consideration what they'll mean in terms of header bloat, as an example, there were changes to the I'm not opposed to sending CSP in all responses, but depending on the header value size it may have a noticeable effect on performance, and also wastes user's bandwidth. However, websites that are using CSP (which according to the HTTP Archive Almanac of 2019 is only about 5%) are more likely to care about their users and thus performance optimization in other areas can be assumed. Hopefully soon, the webappsec WG will provide some clarification on how to best approach this, (@chrisgraham I encourage you to raise your concerns) in w3c/webappsec#520. |
Thanks, great reply. From the webappsec issue, I think this is great advice:
What I'd suggest to you guys is to not raise the error for the case of small CSP headers that are disabling JS. Continue to raise the error for non-HTML CSP headers that are too long or impotent (implies poor server configuration as per your original intent here). |
Thanks @chrisgraham! I've copied your feedback in the CSP issue so we don't forget about it when we implement it. |
- For all requests other than our HTML entrypoints and the playground worker script, serve a super strict policy, just in case a response that shouldn't normally allow any code execution somehow actually does. Based on [this](w3c/webappsec#520 (comment)) and [this](webhintio/hint#3403 (comment)) comment. - Add some directives that I found through https://csp-evaluator.withgoogle.com/ and [this comment](w3c/webappsec#520 (comment)). - Temporary fix for inline Google Analytics script which was being reported as a violation. See #531 for details. Will fix properly in followup.
Using webhint.io...
I got:
Response should not include unneeded 'content-security-policy' and 'x-xss-protection' headers.
...for images.
While it does use a few bytes to send these, it is a legitimate security approach. Internet Explorer will do MIME sniffing even if an accurate mime-type is sent, unless explicitly disabled. All browsers will do MIME sniffing if no mime-type is sent. Potentially mime type configuration on a server could get corrupted, or change over time.
Imagine this scenario...
Hacker uploads .webp file containing HTML code, containing JavaScript code.
Server is now serving .webp file with correct mime type with no CSP headers.
Website owner switches to different server configuration, without built in default mime-type for .webp
Now the site has an XSS vulnerability, as browsers will sniff text/html for the .webp file.
There are many other scenarios. Specifying CSP broadly is for many people a good safety measure.
The text was updated successfully, but these errors were encountered: