Closed void-in closed 4 years ago
Hi @void-in
Thanks for the observation.
I think in this case the current behaviour is probably what we want. The 'pass' action is widely used for rules of a more routine nature like: rules that remove other rules or targets, or rules that set variables, or simply enable certain body parsers. Universally logging all of that rule activity to nginx's error.log under the 'error' setting would probably result in excessive noise to that log for most users (not to mention being counter-intuitive when they are not 'errors' in any real sense).
I agree that the terminology is potentially a little confusing. The 'pass' action is formally classed as a 'disruptive action' ... but of course its effect is explicitly to not 'disrupt' transaction processing. In other words, 'disruptive action' may mean slightly different things depending on the context.
Thank you very much for the explanation @martinhsv
So just one thing more: what is the recommendation in the above case where the SecRule is used primarily for parsing the HTTP request and logging? Should a separate file be used for disruptive actions and logs at info level? The current behavior is to log it at info level but the info level produces a lot of unnecessary noise in the nginx error log such as client terminating sessions etc. In production, it produces a lot of I/O which we can avoid by moving towards a high log level.
There was a discussion a while back to make the log level configurable at the ModSecurity level. Is there any motivation to move towards that at the moment?
Hi @void-in ,
I believe that currently the most common thing to do is to have nginx's error log set to a more restrictive level like 'warn' (rather than, say, 'info') for exactly the reason you point out -- it's less noisy for a file that is typically more useful if it contains only more infrequent and more notable events. The audit log can then contain a larger set of messages.
Whether we move towards supporting user-configurability of the server-log-level at which ModSecurity logs ... that could be worth exploring. Likelihood and priority would depend at least in part on the level of interest in the community for such a feature. Thanks for raising it.
Thank you @martinhsv
Just for anyone who face the same issue, for the time being you can change the audit log level at https://github.com/SpiderLabs/ModSecurity-nginx/blob/b55a5778c539529ae1aa10ca49413771d52bb62e/src/ngx_http_modsecurity_log.c#L33 by changing the line from:
ngx_log_error(NGX_LOG_INFO, (ngx_log_t *)log, 0, "%s", msg);
to
ngx_log_error(NGX_LOG_WARN, (ngx_log_t *)log, 0, "%s", msg);
to log at warn level. I will study the code some more and see if I can make the option user configurable.
Hi, again it is a pleasure to work with ModSecurity day in and out. So the patch in https://github.com/SpiderLabs/ModSecurity-nginx/pull/116 is working as intended as far as deny is concerned. The code mentions that any disruptive action should be able to log with the log level error but the "pass" action which is classified at disruptive at https://github.com/SpiderLabs/ModSecurity/wiki/Reference-Manual-(v2.x)#pass is not logging when the log level is set to error. It only gets logged to the nginx error log when the log level is info.
An example rule:
This rule will only gets logged to the nginx error log when the log level is info. With the log level set to error, only deny rules are logged while the above rule isn't.
Following are the version info:
Modsecurity-nginx version: