I am using mod_security 2.6.3, and I would like to be able to execute a shell script based on a rule-severity level. I am using the core rule set (CRS), which sets the severity level to 2 (for 'critical') when an attack is detected.
I would like to execute my script whenever the severity is high enough.
I tried to use the SecDefaultAction
setting, such as:
SecDefaultAction "phase:2,log,deny,status:403,exec:/path/to/my/script"
But since the 'exec' action is a "non-disruptive" one, it always get executed, whether a critical rule or a non-critical rule is trigerred.
I could go through each critical SecRule
and add "exec" next to it, but that would be tedious (and repetitive, and ugly).
I thought I could do something like:
SecRule ENV:SEVERITY "@lt 4" "exec:/path/to/my/script"
But somehow it never gets executed, probably because the critical rules have a block or deny statement which stops rule processing (since considered disruptive).
I also tried using the CRS anomaly score feature, like this:
SecRule TX:ANOMALY_SCORE "@ge 4" "exec:/path/to/my/script"
But it still does not get processed. Any idea on how I could do this?