-
Notifications
You must be signed in to change notification settings - Fork 1.7k
ModSecurity 3.0 Memory Leak ? #1318
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 @MEN18, Do you happens to have you summary for the ./configure ? I am interested to know if you are using LMDB or not. Also, what is the last commit in your tree? |
Yes i am using LMDB configure:5925: LMDB library found at: /usr/lib/x86_64-linux-gnu//liblmdb.so The last commit i used => 3a41308 |
Do you mind to compile without LMDB ?
|
no sorry, i have juste use this command alone
|
Can you re-compile it using the --without-lmdb parameter? |
The only time when my memory is going down it's with a segfault (who send a signal 11 on the worker) Feb 7 14:29:42 ip-10-65-2-86 kernel: [87308.027588] nginx[445]: segfault at 7fc270936000 ip 00007ff7f1b76c3a sp 00007ffc878da808 error 4 in libc-2.19.so[7ff7f1af5000+1a1000] |
Any change to capture the stack for this segfault? |
It's in an other environment (prod without the debug) without the "--without-lmdb" parameter (but with same version of Nginx/ModSecurity/Rules) |
An idea of when an upcoming update will be available to correct it ? |
In precision the machine contains 27 vhosts |
Hi @MEN18, It will be great if you can give further details on the segfault. Here you can find more details on how to get those core dumps: |
Hi @zimmerle Here is the detail of segfault
|
I now encounter this error when i restart... 2017/02/11 17:37:32 [alert] 24612#0: worker process 27952 exited on signal 6 |
And the different's segfault
|
This is the same issue as with: owasp-modsecurity/ModSecurity-nginx#29 Currently the nginx Version is not usable :( |
Better on Apache ? |
I've built a small test environment of nginx (1.11.10 + modsecurity-nginx + libmodsecurity + owasp-modsecurity-crs 3.0) all from master as of today, and I also experience the memory leak. |
Hi @zimmerle, I was going to check memory leaks reported here, and tried to build latest libmodsecurity from v3/dev/parser, but it couldn't load CRS v3.0.0 ruleset with the following message:
Then I cherry-picked 55d28af to v3/master and immediately got a segfault in modsecurity::utils::SharedFiles::write -> fwrite(), backtrace is below:
SecAuditLog* directives:
I can provide any additional information if it helps. Also, which branch should be currently used for tests - v3/master or v3/dev/parser? Appreciate any insights on those. Thanks! |
Hi @masterzen, The only optimization that i found about the slowness, is to deactivate all .jpg|.gif|.png with modsecurity, and also same problem with nginx 1.11.10 about memory leak. For now, with Apache (2.4.10), ModSecurity 2.9 & CRS Rule in 3.0 i don't have the memory leak problem but ModSecurity don't trigger the same number of rule that in Nginx (less rules are found on Apache). |
Hi @MEN18, My test on Apache 2.4.10 with the Modsecurity-apache connector and same version of libmodsecurity (v3/master) & CRS Rules 3.0 as I used with, is not very conclusive. I couldn't get it to work getting only segfaults. So I reverted back to the current Modsecurity version (version 2) with apache 2.4.10 :
That's around 3.7 slowdown, which I can find acceptable. With nginx and the modsecurity-nginx connector:
So with nginx and modsecurity nginx enabled, I get a 10x slowdown between nginx and apache. That's way too much slowdown for me. |
Thanks for your feedback @masterzen With what are you testing your number of request per second (ab ?) and on which type of machine ? |
@MEN18 yes with: ab -n 10000 -c 20 -k http://127.0.0.1:8080/ on my development machine. Note that I don't care about the absolute performance by itself, just the relative performance between with/without modsecurity and between nginx and apache version of modsecurity. |
Hi @MEN18, The segfault should be gone in the branch v3/dev/parser - https://github.com/SpiderLabs/ModSecurity/tree/v3/dev/parser Thank you for the report and detailed information. |
Hi @masterzen, Thank you for the performance tests. I will look into this memory leak problem, I am sure that we are going to get very different results without the memory leak. |
Hi @defanator, Regarding the OWASP rules, normally we use the tagged version for test: v3.0.0. But thanks for the report. I already fixed. You should be able to load today's `trunk' without a problem. |
Sorry for writing in a closed issue, have recompiled with the parser branch and here a my results with ab: root@nginx:~# ab -n 10000 -c 20 -k http://127.0.0.1:80/ Benchmarking 127.0.0.1 (be patient) Server Software: nginx/1.11.9 Document Path: / Concurrency Level: 20 Connection Times (ms) Percentage of the requests served within a certain time (ms) When I disable modsec I got 50000/s (just static page on localhost). Switched back to modsec and again only 136/s. |
Hi @mimugmail, Do you want to create a issue on the ModSecurit-nginx project to keep track of this performance measurements? That is something that will be good to have. |
Hi, I seem to be getting this error........ Please let me know if I should raise this as an issue. sending a
Basically using: https://hub.docker.com/r/elisiano/owasp-modsecurity-crs/~/dockerfile/ (but I update the alpine and nginx versions). CRS config found here:
/var/log/modsec_audit.log also has:
|
hi @Menahem1 |
@maopaolinux try applying these patches to both libModSecurity and nginx-connector: |
Hello
I am currently experiencing a problem with Nginx/ModSecurity (with CRS rule in v3.0) about increasing memory in Nginx.
For now i can't be sure that the increasing memory (or memory leak) is on ModSecurity or other part of Nginx, how to be sure ?
My conf :
nginx version: nginx/1.11.9
built by gcc 4.9.2 (Debian 4.9.2-10)
built with OpenSSL 1.0.1t 3 May 2016
TLS SNI support enabled
configure arguments: --add-module=../ModSecurity-nginx --with-debug --with-cc-opt='-O0 -g -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --with-pcre-jit --with-http_ssl_module --with-http_realip_module
Usage of Memory
The text was updated successfully, but these errors were encountered: