ModSecurity icon indicating copy to clipboard operation
ModSecurity copied to clipboard

high cpu usage with modsecurity 2.8.0 and nginx 1.6.2

Open tstack opened this issue 12 years ago • 4 comments

Hello,

We're seeing high CPU usage when downloading large files with modsecurity enabled. Our setup has an nginx frontend with modsecurity backed by another nginx that is serving static files and fowarding requests to uwsgi. When I request a large file (100+MB), there is a several-second pause and the nginx with modsec starts chewing CPU and allocating a bunch of memory. When it is in this state and I attach with gdb, it is always in the apr_brigade_cleanup call of the move_brigade_to_chain function. If I let it run, it will eventually start sending data and processing can continue, but the pause blocks all other transfers.

This behavior makes modsec unusable for us. I tried setting 'SecResponseBodyAccess off' but that didn't seem to have any effect. I took a quick look at the code, but it didn't look like anything in the nginx-specific code was looking for that flag (I was searching for calls to modsecIsResponseBodyAccessEnabled).

tstack avatar Oct 23 '14 00:10 tstack

Hi. We have got the same problem on production environment. We experienced it with modsecurity 2.8.0, 2.9.0 and nginx 1.6.2. User started download report file with size about 800MG. Nginx ate 100% of CPU and did not work anymore, so only restart of nginx helped. SecResponseBodyAccess off flag didn't help either.

vzarubin avatar Apr 02 '15 09:04 vzarubin

Hi... Same here! SecResponseBodyAccess off or even SecRuleEngine Off won't make any difference as soon as ModSecurityEnabled is On!!!

Roger-Man avatar Oct 23 '16 07:10 Roger-Man

Hi @Roger-Man,

try the ModSecurity-nginx connector: http://www.github.com/SpiderLabs/ModSecurity-nginx

zimmerle avatar Dec 16 '16 22:12 zimmerle

No longer a concern in libModSecurity. Marking it as won't fix for 2.x. Further information about libModSecurity available here: https://github.com/SpiderLabs/ModSecurity/tree/v3/master

zimmerle avatar May 09 '17 21:05 zimmerle