-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Fix response header check #5492
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
Conversation
If a webserver or reverse proxy itself also sets the required headers, the check will yield a false negative since the header will be set twice (once from nextcloud, once from the webserver). From https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getResponseHeader: `If there are multiple response headers with the same name, then their values are returned as a single concatenated string, where each value is separated from the previous one by a pair of comma and space`. So in case the header is set twice, `getResponseHeader` will return something like `SAMEORIGIN, SAMEORIGIN` and the equals check will fail and therefore result in a false negative. Using String.indexOf() to search for a substring will prevent this.
|
@vbrandl, thanks for your PR! By analyzing the history of the files in this pull request, we identified @LukasReschke, @rullzer and @MorrisJobke to be potential reviewers. |
Forgot the `-` sign
LukasReschke
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I consider this expected behaviour. The web server should not set these headers as they could collide with Nextclouds configuration.
|
Ok I get that. And what about a more differentiated error message in case the header is set twice? Something like |
|
I had the same behavior. (my Apache sets some security headers if they're unset; some default security). /etc/apache2/conf-enabled/security.conf in nextcloud/.htaccess replace: The problem on this solution is just the changed checksum which results in an error on integrity-check. If default is not ok, value could be changed in apache vhost with: |
|
I'm using nginx and I just have to disable the headers for the warning to disappear. I just think that there is a difference between 'header is not set' and 'header is set twice' and that this difference should be made clear by showing different messages to the user. |
|
There was a different approach also merged in via #4856. Also the text states that the configured header does not equal SAMEORIGIN. Another indicator that the admin could look into. Maybe it's also good to show the current one and the expected one. I would appreciate a PR doing this more that this fuzzy check for the header, because it would also mean that "abcSAMEORIGINdef" would succeed. |
If a webserver or reverse proxy itself also sets the required headers,
the check will yield a false negative since the header will be set twice
(once from nextcloud, once from the webserver).
From
https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/getResponseHeader:
If there are multiple response headers with the same name, then their values are returned as a single concatenated string, where each value is separated from the previous one by a pair of comma and space.So in case the header is set twice,
getResponseHeaderwill returnsomething like
SAMEORIGIN, SAMEORIGINand the equals check will failand therefore result in a false negative. Using String.indexOf() to
search for a substring will prevent this.