-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
X-Content-Type-Options header (and others) #33090
Comments
Some headers like CSP can't be added due to some legacy problems (still need a lot of refactorings): Content-Security-Policy #305 Some options like STS might not satisfy every user, some users do not want it. At least, you could setup a reverse proxy and add any header you like. |
Yeah I know, and actually linked that issue in my message. ;)
Quoting myself:
That’s actually what I do (using nginx as stated above), but it is not very convenient for two reasons:
|
Yep, agree. Just some thoughts:
I guess no .... because all reverse proxy could merge duplicate headers. And yes, I agree that if we could have a clear solution in Gitea, it is better.
Yep, that's a problem, nginx doesn't inherit other headers if a header is set in a section ..... |
Feature Description
Hi there,
While reviewing my nginx and gitea configuration, I see that gitea is still far from optimal regarding emitted HTTP headers. And I could not find any place discussing this particular header (the one in the title, see after for others).
If you do a quick security headers check (e.g. https://securityheaders.com/?q=https%3A%2F%2Fgitea.com%2Fexplore%2Frepos&hide=on&followRedirects=on), you will see that almost everything is red (see screenshot below).
There is a very easy one (at least it seems to me), the one in the title. Only one possible value, as explained here:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
https://scotthelme.co.uk/hardening-your-http-response-headers/#x-content-type-options
If you wonder why that should be set, this is likely the best answer I could find: https://stackoverflow.com/a/37201425/3845564
I think I can provide a PR for this, based on how X-Frame-Options currently works (i.e. adapting https://github.com/go-gitea/gitea/pull/30256/files).
Now regarding that last one, it has been obsoleted https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options. The new solution is CSP but I see there is already #305 on the topic, and I guess that moving to the new iframe handling should be done as part of it.
(Note: Strict-Transport-Security and Referrer-Policy are not to be set by Gitea, this is admin policy and likely configured more globally)
Regards.
Screenshots
The text was updated successfully, but these errors were encountered: