-
-
Notifications
You must be signed in to change notification settings - Fork 834
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
Hardening HTTP Headers #353
Comments
I may be wrong but most of the information concerning http headers on the link your provided is for server administrators to apply on the server side and not really via an application since most of the configurations there have to do with how a server response and replies. Most of the rules and configurations there are using the htaccess file to overwrite standard headers and when it comes to playing with the htaccess file many servers will respond differently or will just give a 500 error for miss configuration. And not only that but most apply to either virtual servers or dedicated servers where you have more control, when it comes to share hosting that's where problems may happen since some of the configurations may not be available. Some share hosts don't even allow for you to have an htaccess file or a php.ini file, to turn on or off some of the configurations. The reason for this is because most people don't really know what they are doing so instead of making their site more secure they end up making it less secure or to the point of overloading because of miss configuration And yes you can have some control of certain headers with PHP but they still rely on the rules of the server so even though you're sending a particular header if the server decides not to send it or to allow to overwrite it then it won't be applied.. I wouldn't put this as a feature or start playing on how an application should send headers since it will become more of a headache because of the many types of servers and configurations there are out there but it should be something people should have as a reference no matter what type of site they are running is always good to know what you can apply for "security" on a server that allows it.. But then again I may be wrong, is not like I read the whole thing but just by browsing I did notice a lot of configurations there I have done on my own server via htaccess, again it was not something that many of my applications required or could be apply through them but because is good standards to follow when you're running a server. |
I think things like the Frame-Options headers (or Content-Security-Policy, as it's now called if I'm not mistaken) are pretty useful (e.g. for preventing clickjacking attacks). We'll be careful about what we consider. :) |
Yes those are headers that need to be applied via the htaccess file as a user or the server response header configurations file or similar by the server admin or host server admins. Most content security headers are use for CDNs and calls for REST requests and API requests as far as clickjacking this is not just a concern for Flarum this is for any site out there. As I said before is should not be a feature but a reference somewhere in the installation guide or best practises. Looking at other applications out there you can see that none of them will try to do this not because they can't but because not every server out there is capable of applying such settings via the application. Just look at how many problems many people have because the htaccess file doesn't have the right configuration for re routing URLs for their server configuration. To me just be careful trying to play with the htaccess file and headers, the application shouldn't rely too much on this unless really necessary. But it is nice to have that link as a reference somewhere in the docs is always nice to have a second look at what a user can apply on their server for security. Here is another great reference for the htaccess file and the many setting you can apply through it. |
@franzliedke maybe we can solve this by just adding these into the default skeleton? |
On second thought, another idea. Django's middleware processes both requests and responses. I don't know if we want to have our current middleware stack do both (although I'd like that), but there should definitely be a way to apply some form of response processing, including applying relevant security headers. |
Some notes on the linked list:
So out of all of those I only see 2-3 that we can/should do, the rest should be up to the admin, we could possibly have a link in the docs someplace to consistently updated security header information for various web servers officially listed (Apache, Nginx, Caddy) |
Agree as to all of these. I guess the next step would be a Middleware that adds frame options, xss protection, and content type options. As to CSP, I like it, but it's something that we'd need to support first. I think that should be split into its own issue, with incremental steps taken (both in core and in extensions) to achieve it. Discourse has it on by default, I see no reason why we couldn't do the same. |
@askvortsov1 the best way I can see CSP being done is if we bring in a lib that specializes in building CSP strings, and then allowing extension devs to using an extender or something that uses that lib to add to the default string. |
Some additional stuff for CSP if we did it, there are two CSP string builders that I can find that look decent: A CSP string builder would be required to properly support extensions, further I would love to see proper use of nounce for any inline scripts. |
To clarify, for this issue, we don't need CSP (or optimizing for CSP) yet. Although if someone is up for it, I definitely wouldn't complain |
Actionable steps:
This should be an array in CSP should be a separate issue (https://github.com/flarum/core/issues/2702) |
We might also want to consider Referrer Policy and Permissions Policy (the latter needs an extender): https://securityheaders.com/?followRedirects=on&hide=on&q=discuss.flarum.org |
I agree we should also include the referrer policy header and use a config for that. |
After further research it appears that X-Frame-Options doesn't make sense as it's basically deprecated at this point. We could set it to |
Lets drop it then, one less thing to configure |
Probably a good idea... here's a nice checklist: https://scotthelme.co.uk/hardening-your-http-response-headers/
The text was updated successfully, but these errors were encountered: