-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Nginx with Modsecurity: POST request gives 500 error #582
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
Comments
Hi @pijnack, I am reopening this issue, I'm investigating it. |
Wordpress set multiple cookies in the very same request, which is a issue in our Nginx implementation as report at #154. It is not directly related to this issue, but it is somehow related in the sense that it does affect the behavior of Wordpress. |
I also had two issues regarding "POST request 500 error" and only one set-cookie. |
Same issue here , no upstream or proxy setting used. just nginx php-fpm. Even more weird is this only triggers when 'Host: ' header is set - using browser or curl etc |
I've got the same issue, any ideas? |
Same issue for me with IPB. Latest NGINX and ModSecurity version and ASL rules. If SecRequestBodyAccess is enabled, it will give a 500 error with POST requests while writing nothing useful on the ModSecurity logs, even with debug level 9 and in the NGINX logs it only produces the lines mention in OP. This issue was reported in #115 10 months ago and nobody took care of it? I can provide server access to one of the devs if no one is able to reproduce it - it's a non-production environment. |
Hi @infinitnet, there are some problems with the way that ModSecurity is handling the post requests on nginx. If you look at #142 you will be able to see that contents over 8k are causing problems as well. Our version 2.8.0-RC1 contain a fix related to the issue #645. But we still have problems while the request body is bigger than a certain amount of data. The main reason for the problem is that ModSecrurity is not assembling Nginx chunks right, the function is here: In certain cases (e.g. when the request body content is not complete) this function should return NGX_AGAIN, so that nginx will call it again with the rest of the body data. |
@zimmerle I'm actually using 2.8.0-RC1 already. I didn't check the POST data size, but the issue appears even with simple login forms, rendering ModSecurity pretty much unusable with NGINX. [10/Apr/2014:16:19:03 +0200] "POST /index.php?app=core&module=global§ion=login&do=process HTTP/1.1" 500 [alert] 19480#0: *4 no upstream configuration, client: 1.2.3.4, server: domain.com, request: "POST /index.php?app=core&module=global§ion=login&do=process HTTP/1.1" And nothing useful in the audit or debug log. |
@zimmerle I should have checked dmesg earlier, actually, it's indeed somehow related to APR (my version of libapr1(-dev) is 1.4.6-3+deb7u1), as I'm getting segfaults for each NGINX worker when starting NGINX: Apr 10 17:01:13 a143 kernel: [787456.369365] nginx[19482]: segfault at 7fe879c61098 ip 00007fe88484792d sp 00007fff04fc4b90 error 4 in libapr-1.so.0.4.6[7fe88482d000+30000] |
@infinitnet This happens when you start nginx or whenever you receive a new request? |
@zimmerle Updated my comment, it happens for each NGINX worker process when starting NGINX, not with each request and also not when I get the 500 error, only when starting it. |
it just happens if SecRequestBodyAccess is marked as on ? Can you run into inside gdb and share a stack trace? Thanks. |
@zimmerle Actually it happens also with SecRequestBodyAccess Off, so I'm not sure if the segfault issue is even related. Even though I compiled NGINX --with-debug and CFlags -g -O0 for both NGINX and mod_sec and both daemon and master_process off in my NGINX config, I can't get any useful info (stack trace) with GDB. If you could add me on Skype (infinitnet) or let me know an IRC channel, I can provide you access. Here's a normal strace if that helps: http://pastebin.com/3DcEni6h |
helpful |
Is there any ETA on the error 500 issue when processing POST requests yet (NGX_AGAIN)? |
This was reported 6 months ago and makes a huge part of ModSecurity useless with NGINX and yet it doesn't have anyone assigned to fix it or anything. I'd very much like to know about the progress on this. |
Hi @pijnack large POSTs with SecRequestBodyAccess On, should be functional in the following branch: https://github.com/SpiderLabs/ModSecurity/tree/nginx_refactoring Can you test and confirm it? Thanks, |
Hello, I'm having this problem too, my scenario:
I've tried the nginx_refactoring tree (I just switched the "nginx" folder within modsecurity) with nginx 1.7.0 and it doesn't even give error 500, it core dumped, here is a gdb run of a core: |
Hi again, I'm trying a clean, hand-compiled (i was using ports before) version of nginx 1.7.1 against nginx_refactoring and I'm still getting "no upstream configuration".
And I've compiled ModSecurity with:
I get the error with and without an Upstream configured:
|
Same for me, issue still exists in nginx_refactoring branch. |
@zimmerle |
@arianf I have updated the website as both @zimmerle and I thought that your complaint was valid. Please see the updated site, we apologize for the confusion: http://modsecurity.org/download.html |
@ton31337, since it isn't clear when this whole issue will be properly resolved, would it be possible for you to rebase your branch on the latest nginx_refactoring so that we can benefit from other fixes that have been added in the meantime? This would include the other >8K fix. Thanks. |
@chewi did you tested the latest version of the nginx_refactoring branch ? |
Hmmm. I don't think I went wrong anywhere but I'll double check. |
Hi, I'm running into the same issue.Used latest nginx_refactoring and nginx 1.9.14 Thanks! 2016/04/25 12:46:19 [alert] 25240#0: *1 no upstream configuration, client: xx.xx.xx.xx, server: xxxx.xxx, request: "POST /owncloud/index.php HTTP/1.1", host: "xxx.xx.xx" |
I never got around to double checking though I am due to look at this again soon. I'm now quite confident that I didn't mess up if you're still seeing it. |
Okay & Thanks! |
Okay, I have now verified this in a different environment. The nginx_refactoring branch as of 207c85d does not fix the issue. I did not want to use @ton31337's branch as it stands because it's very old now. I rebased nginx_refactoring on v2.9.1 but skipped d135f88 so that I could apply 9abda55 instead. This fixed the issue. In short, @zimmerle's version of the fix does not work. You can see the result of my merge at yakara-ltd/ModSecurity@f067515. If it helps, we are seeing this triggered by Apache commons-httpclient 3.0.1 against nginx 1.9.10. I know the former is really ancient but this still shouldn't happen. |
Unfortunately we had to disable ModSec again after deploying this because requests were randomly having their headers mangled. I don't know the details yet but Rails was occasionally picking up the requested domain as localhost instead of the one that was really requested. |
Hi, According to: http://lxr.nginx.org/source/src/http/ngx_http_request.c#1611 We can easily set server and host properties in header_in because they're already checked by the core module. I've tested it with OWASP rules and the current stable version of Nginx and it works properly. Thanks for your consideration, |
Hi @LoadLow, This fix is somewhat implemented in the nginx_refactoring branch, however we advice to use the ModSecurity-nginx connector instead of this implementation. For further information on the ModSecurity-nginx connector, check here: |
@ton31337 l use this branch: ton31337_x-headers but get 404 .. nginx version: nginx/1.8.1 |
@jinri Did you ever tried the ModSecurity v3 with nginx? - |
@zimmerle |
No longer a concern in libModSecurity. Marking it as won't fix for 2.x. Further information about libModSecurity available here: |
Nginx with Modsecurity gives 500 errors after a POST request.
In error.log:
2013/10/23 13:21:07 [alert] 29432#0: *4 no upstream configuration, client: 88.159.16.136, server: test.huygenscollege.nl, request: "POST /proefwerk/prog/index.php?day=28&month=10&year=2013&klas=2 HTTP/1.1", host: "test.huygenscollege.nl", referrer: "http://test.huygenscollege.nl/proefwerk/prog/index.php?day=4&month=11&year=2013&klas=2"
In nginx.conf:
upstream smoothrac {
server 88.159.13.153;
}
server {
listen 80;
server_name test.huygenscollege.nl;
location / {
ModSecurityEnabled on;
ModSecurityConfig modsecurity.conf;
proxy_pass http://smoothrac/;
proxy_set_header Host test.huygenscollege.nl;
proxy_read_timeout 150s;
}
}
After changing ModSecurityEnabled on to off, the problem is gone.
I guess something is missing in my upstream configuration?
Piet Pijnacker,
Eindhoven, Netherlands
The text was updated successfully, but these errors were encountered: