hub icon indicating copy to clipboard operation
hub copied to clipboard

Extend ModSecurity CRS coverage

Open 0xbbuddha opened this issue 4 months ago • 6 comments

Summary

This PR improves ModSecurity CRS integration by introducing multiple dedicated scenarios for different attack types. Previously, only a single generic scenario existed, making it harder to distinguish between SQLi, XSS, brute force, and other patterns.

Changes introduced:

  • Added separate scenarios for different categories of attacks.
  • Improved visibility and granularity in detection.
  • Updated the CrowdSec ModSecurity collection accordingly.
  • Scenarios have been implemented in line with the latest ModSecurity CRS ruleset (v4.17.1).
  • WordPress and Nextcloud ModSecurity rules have been implemented in accordance with ModSecurity CRS ruleset (v3.3.4).

Why

By splitting the detection logic into multiple scenarios, we gain better insights into the nature of incoming attacks. This allows for clearer alerts, more accurate remediation, and enhanced observability.

0xbbuddha avatar Aug 21 '25 12:08 0xbbuddha

Nice one, give us a bit of time to have a proper look.

thx :)

buixor avatar Aug 27 '25 08:08 buixor

no problem

0xbbuddha avatar Aug 27 '25 13:08 0xbbuddha

Just adding a small note, we should have a look at supporting Coraza caddy logs with the same scenarios as we have access to the same data points.

I believe at the moment there a seperate scenario for caddy coraza which only checks for the scoring ID.

LaurenceJJones avatar Aug 29 '25 09:08 LaurenceJJones

Do you want me to find out?

0xbbuddha avatar Aug 29 '25 14:08 0xbbuddha

I just looked at the scenario for the Coraza-Caddy collection. It is based on this rule. Would you like me to apply it to this collection? I can also create even more specific scenarios if needed. But by default, we only want to trigger an alert if the level is 'CRITICAL'.

SecRule TX:BLOCKING_INBOUND_ANOMALY_SCORE "@ge %{tx.inbound_anomaly_score_threshold}" \
    "id:949110,\
    phase:2,\
    deny,\
    t:none,\
    msg:'Inbound Anomaly Score Exceeded (Total Score: %{TX.BLOCKING_INBOUND_ANOMALY_SCORE})',\
    tag:'anomaly-evaluation',\
    tag:'OWASP_CRS',\
    ver:'OWASP_CRS/4.18.0-dev'"

0xbbuddha avatar Sep 02 '25 09:09 0xbbuddha

I'm going to readjust some rules.

0xbbuddha avatar Sep 02 '25 10:09 0xbbuddha