unsafe nginx config #5117
Copy link
Copy link
Closed
Labels
0. Needs triagePending check for reproducibility or if it fits our roadmapPending check for reproducibility or if it fits our roadmap
Description
It is easy.
Your error:
root@server:~/server-scripts# gixy
[nginx_parser] WARNING File not found: /etc/nginx/conf.d/*.conf
==================== Results ===================
Problem: [http_splitting] Possible HTTP-Splitting vulnerability.
Description: Using variables that can contain "\n" may lead to http injection.
Additional info: https://github.com/yandex/gixy/blob/master/docs/en/plugins/httpsplitting.md
Reason: At least variable "$uri" can contain "\n"
Pseudo config:
include /etc/nginx/sites-enabled/sync.patrikx3.tk;
server {
server_name sync.patrikx3.tk;
location / {
rewrite ^ /index.php$uri;
}
}
==================== Summary ===================
Total issues:
Unspecified: 0
Low: 0
Medium: 0
High: 1
Just do not use $uri for NGINX, use $request_uri;
For use like this:
location / {
rewrite ^ /index.php$request_uri;
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
0. Needs triagePending check for reproducibility or if it fits our roadmapPending check for reproducibility or if it fits our roadmap
Activity
LukasReschke commentedon May 28, 2017
@josh4trunks Any input? :)
josh4trunks commentedon May 29, 2017
Hmm, never heard of this before but I can see the issue.
Here is an explanation that helped me understand http://blog.volema.com/nginx-insecurities.html
I agree we should change this. There are 3 lines where this should be changed for both...
"https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/nginx.rst#nextcloud-in-the-webroot-of-nginx"
and...
"https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/nginx.rst#nextcloud-in-a-subdir-of-nginx".
I suggest we do some testing to make sure this does not break anythingThe above change seems to work just browsing around my production site.
patschi commentedon May 31, 2017
I've done the suggested configuration change on my setup now aswell. No negative behavior so far. Additionally I would suggest adding:
josh4trunks commentedon May 31, 2017
I do not believe
autoindexhas ever been enabled by default in NGINX.I do not think we need to give general configuration tips, only things specific to nextcloud.
dominic-p commentedon Jun 12, 2017
I noticed that gzip is enabled in the sample config files. Should we disable it for HTTPS to mitigate attacks like BREACH?
josh4trunks commentedon Jun 12, 2017
I don't know enough about BREACH to know if our recommendation of SSL and gzip is vulnerable.
Maybe someone can research/comment.
MorrisJobke commentedon Jun 12, 2017
@LukasReschke regarding HTTPS and gzip and the potential BREACH attack.
cc @benediktg for the gzip part.
benediktg commentedon Jun 12, 2017
Sure, disabling gzip is the most effective way of preventing the BREACH attack. http://breachattack.com says
I think having gzip enabled is still nice to have, hence it'd be great to know what e.g. @LukasReschke can say about the other mitigation options and their applicability in Nextcloud. (5–7 sound like security by obscurity to me).
p3x-robot commentedon Jun 12, 2017
i just use gzip for static data like js, css, png, jpg, the rest is disabled. thats all. then it is secure. the nexcloud user data should not be compressed.
LukasReschke commentedon Jun 12, 2017
Secrets such as the CSRF token are XOR'ed in Nextcloud with a random secret per request, but I'd still recommend disabling GZIP for dynamic pages to be honest :)
josh4trunks commentedon Jun 12, 2017
maybe we should take a look at our recommended gzip_types?
gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;p3x-robot commentedon Jun 12, 2017
user data disabled all. generated can be json or js as well.
gzip only for static nextcloud , but you don't really need gzip.
i need gzip because for angular 4 i got like 3MB js files and now they are 500mb.
gzip is unsafe. just disable. easier disable gzip.
p3x-robot commentedon Jun 12, 2017
i use like this for nginx the http, the main directive:
secure location
/api could be the secrue locations. the rest is gzipped.
dominic-p commentedon Aug 21, 2017
It looks like this issue has been closed. Was there any resolution on the gzip discussion? I haven't noticed any changes to the gzip settings in the recommended nginx config
p3x-robot commentedon Aug 21, 2017
dont use gzip on ssl, otherwise it is unsafe...
dominic-p commentedon Aug 21, 2017
Ok, thanks. Should the documentation be updated then? Right now, it does use gzip for SSL.
benediktg commentedon Aug 22, 2017
Not necessarily – I simply let gzip activated because it means a measurable performance gain.
MeiRos commentedon Jun 21, 2018
@josh4trunks
Should we use $request_uri instead of $uri?
At least documents linked above have $uri.
josh4trunks commentedon Jun 21, 2018
@MeiRos, yes it looks like my comment #5117 (comment) was not fully implemented.
These two lines in https://github.com/nextcloud/documentation/blob/master/admin_manual/installation/nginx.rst...
Should be changed to...
If someone wants to submit a PR and mention me we can review it there.
rugk commentedon Aug 17, 2018
BTW:
It's not and these are actually best practices and/or good suggestions. Of course use CSRF tokens. And even adding random data (often as a random padding) to prevent size information leak is actually a thing, which is done in proper modern security protocols. AFAIK TLS 1.3 uses it.
As such, TLS 1.3 may also mitigate it, at least. (note they ordered their suggestions by effectiveness.)
rugk commentedon Aug 17, 2018
Generally I am also not sure how BREACH may work with HTTP/2, which again does yet different binary data transmission etc. I assume, they only tested with HTTP 1.