-
Notifications
You must be signed in to change notification settings - Fork 1.6k
nginx crash observed on nginx 1.4.5 and ModSecurity 2.7.7 #681
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
A brief note on why I think the issue is in move_brigade_to_chain(): |
akamatgi, I was having a very similar issue and have been troubleshooting this (on and off) for several months. 'cl->next = NULL;' does indeed seem to have resolved my segfault issue (I had also experienced on debian based systems). I'll be testing this over the next few days and will update this after testing the full CRS spectrum, but this seems promising! Let me know when I can send you a beer! ;) |
Robert, glad to know it fixed your issue( atleast for now ). On Wed, Apr 16, 2014 at 5:22 AM, Robert notifications@github.com wrote:
|
Hi @akamatgi, Did you managed to run the regression tests with your patch applied? Do you want to share it in a format of a pull request? Thanks, |
As I can see - it fixed the problem for me. |
Hi @kyprizel thank you for the patch. We already have 'cl->next = NULL' in the branch: https://github.com/SpiderLabs/ModSecurity/tree/nginx_refactoring nginx_refactoring branch is currently under testing. I will merge the b3db7d3 under this testing branch by the end of the day. Thanks, |
Thanks, please, do not merge b3db7d3 - it's not a good solution and can crash process in some cases. |
Hi Felipe, On Wed, Apr 16, 2014 at 7:14 PM, Felipe Zimmerle
|
Ok, this fix is a "must have", without it, POST requests seems to have random problems including SEGV's and out of memory errors. (seems to fix things for me also) |
Marking as won't fix in 2.x as it is no longer a concern in libModSecurity: |
CentOS release 6.5 (Final) 2.6.32-431.el6.x86_64 #1 SMP
I have ModSecurity turned on with "SecRuleEngine DetectionOnly" set in modsecurity.conf
I also have enabled Caching in nginx.conf
When I am sending a request with a sql injection pattern in the URL, I am seeing that nginx crashes with Segmentation Violation with the following backtrace:
(gdb) bt
#0 ngx_http_write_filter (r=0x1f467c0, in=0x1f4a778) at src/http/ngx_http_write_filter_module.c:121
#1 0x0000000000464b8d in ngx_http_chunked_body_filter (r=0x1f467c0, in=)
#2 0x0000000000476067 in ngx_http_spdy_body_filter (r=0x1f467c0, in=0x1f4a778) at src/http/ngx_http_spdy_filter_module.c:618
#3 0x000000000046a4a5 in ngx_http_gzip_body_filter (r=0x1f467c0, in=0x1f4a778) at src/http/modules/ngx_http_gzip_filter_module.c:325
#4 0x000000000046b3ea in ngx_http_postpone_filter (r=0x1f467c0, in=0x1f4a778) at src/http/ngx_http_postpone_filter_module.c:83
#5 0x000000000046bb49 in ngx_http_ssi_body_filter (r=0x1f467c0, in=)
#6 0x000000000046ffbf in ngx_http_charset_body_filter (r=0x1f467c0, in=)
#7 0x00000000004914cb in ngx_http_modsecurity_body_filter (r=, in=)
#8 0x000000000041de58 in ngx_output_chain (ctx=0x1f4a5c0, in=0x7fffa65158e0) at src/core/ngx_output_chain.c:66
#9 0x000000000045327f in ngx_http_copy_filter (r=0x1f467c0, in=0x7fffa65158e0) at src/http/ngx_http_copy_filter_module.c:143
#10 0x0000000000464f1c in ngx_http_range_body_filter (r=0x1f467c0, in=0x7fffa65158e0)
#11 0x00000000004479e2 in ngx_http_output_filter (r=0x1f467c0, in=0x7fffa65158e0) at src/http/ngx_http_core_module.c:1956
#12 0x0000000000468fe4 in ngx_http_cache_send (r=0x1f467c0) at src/http/ngx_http_file_cache.c:1022
#13 0x000000000045de17 in ngx_http_upstream_cache_send (r=0x1f467c0, u=0x1f49978) at src/http/ngx_http_upstream.c:868
#14 0x00000000004607ae in ngx_http_upstream_cache (r=0x1f467c0) at src/http/ngx_http_upstream.c:774
#15 ngx_http_upstream_init_request (r=0x1f467c0) at src/http/ngx_http_upstream.c:493
#16 0x0000000000460ecf in ngx_http_upstream_init (r=0x1f467c0) at src/http/ngx_http_upstream.c:466
#17 0x00000000004567de in ngx_http_read_client_request_body (r=0x1f467c0, post_handler=0x460dba <ngx_http_upstream_init>)
#18 0x0000000000482bf0 in ngx_http_proxy_handler (r=0x1f467c0) at src/http/modules/ngx_http_proxy_module.c:725
#19 0x0000000000448e5c in ngx_http_core_content_phase (r=0x1f467c0, ph=0x27daf98) at src/http/ngx_http_core_module.c:1408
#20 0x0000000000443723 in ngx_http_core_run_phases (r=0x1f467c0) at src/http/ngx_http_core_module.c:888
#21 0x0000000000443833 in ngx_http_handler (r=) at src/http/ngx_http_core_module.c:871
#22 0x000000000044e841 in ngx_http_process_request (r=0x1f467c0) at src/http/ngx_http_request.c:1828
After digging around the code, I found a potential issue in the function move_brigade_to_chain() in the following piece of code:
if (APR_BUCKET_IS_EOS(e)) {
if (cl == NULL) {
cl = ngx_alloc_chain_link(pool);
if (cl == NULL) {
break;
}
Adding 'cl->next = NULL;' between the lines 'cl->buf->last_buf = 1;' and '*ll = cl;' fixed the issue for me.
Is this a valid fix?
The text was updated successfully, but these errors were encountered: