modsecurity blocking but not logging a violation

520 views Asked by At

So it's not that there are no logs, there are actually many violations logged, its just an issue I'm having with a few people; 10s of violations out of millions of requests. To make it easy to differentiate between modsecurity and backend violations I changed SecDefaultAction to a status of 406, works like a charm.

It's not a performance issue, the modsecurity servers are in an auto-scaling group and hardly taxed. I can see in our Kinesis logs the return code of 406 being sent to the user, as well as actually seeing the 406 in their browser. There is no corresponding modsecurity violation though.

The modsecurity servers are all behind load balancers and dont see the users IPs, I dont have any DOS or IP Reputation on anyway.

The only thing I really have to go on is, while we were in DetectionOnly these particular users would trigger a 930120 when they logged in.

"request": "GET /a/environment_settings.js HTTP/2.0", "id": "930120"
"Matched Data: <omitted> found within REQUEST_COOKIES:access_token: <omitted>

We turned the rule on and I wrote the following in crs-after:

SecRuleUpdateTargetByTag "attack-lfi" "!REQUEST_COOKIES:access_token"

Everybody was fine logging in except for this one user. Unfortunately I have nothing to go on because while they get a 406, nothing is logged for it. At one time 941150 would silently increment the anomaly counter but that rule isn't in play here. I was wondering if there are any other rules that may silently increment. Or any thoughts on how to debug this.

1

There are 1 answers

0
franbuehler On

OWASP ModSecurity Core Rule Set dev-on-duty here. To resolve the false positive with the CRS rule 930120 you can do the following: Put the following tuning rule into crs-after (you're right here).

SecRuleUpdateTargetById 930120 !REQUEST_COOKIES:access_token

I highly recommend the tuning tutorials of CRS co-lead Christian that can be found here: https://www.netnea.com/cms/apache-tutorials/. There you'll also find a tuning cheat sheet.

In the logs you should see the rules that increment the anomaly score. There shouldn't be a rule that increments silently.