Security

ModSecurity with the OWASP Core Rule Set in WHM: setup and false positives

Enable the OWASP CRS vendor for ModSecurity in WHM, find the rule ID behind a 403 error in the audit log, and disable that rule for one site or server-wide.

AdvancedWHM (root)2 min read

ModSecurity is a web application firewall built into Apache and LiteSpeed. With the OWASP Core Rule Set (CRS) it blocks SQL injection, cross-site scripting and other attacks before they reach PHP. The trade-off is occasional false positives: a legitimate form post or page builder save gets a 403 Forbidden. This guide covers both sides.

Before you start

Enable the OWASP CRS vendor

  1. Go to WHM → Security Center → ModSecurity Vendors.
  2. Find OWASP ModSecurity Core Rule Set and click Install. Vendors in general are covered in WHM ModSecurity vendors.
  3. Leave Enabled and Updates switched on so rules stay current.
  4. In WHM → Security Center → ModSecurity Configuration, set Audit Log Level to Only log noteworthy transactions and Rules Engine to Process the rules. Save.

Tip: On a busy server, first set the engine to Process the rules in verbose logging mode and do not execute disruptive actions for a day. You will see what would be blocked without breaking any sites.

Find the rule behind a 403

  1. Reproduce the error and note the time, domain and your IP.
  2. Open WHM → Security Center → ModSecurity Tools → Hits List, or search the log from SSH:
    grep 203.0.113.10 /usr/local/apache/logs/modsec_audit.log | tail -n 20
  3. Look for the [id "942100"] value and the message, such as SQL Injection Attack Detected via libinjection. Note the URI that was hit.

Fix the false positive

Disable one rule for one domain (preferred)

  1. In ModSecurity Tools → Rules List you can disable a rule server-wide. To limit it to one site, add an include for that virtual host instead:
    mkdir -p /etc/apache2/conf.d/userdata/ssl/2_4/username/example.com
  2. Create modsec.conf in that folder:
    <IfModule mod_security2.c>
    SecRuleRemoveById 942100
    </IfModule>
  3. Repeat under userdata/std/2_4/... for plain HTTP, then rebuild and restart:
    /scripts/rebuildhttpdconf && /scripts/restartsrv_httpd

Disable one rule for one URL

<LocationMatch "/wp-admin/admin-ajax.php">
SecRuleRemoveById 942100
</LocationMatch>

Disable server-wide

In ModSecurity Tools → Rules List, find the rule ID and click Disable. Use this only for rules that misfire on many sites.

Warning: Never switch ModSecurity off for a whole account just to fix one form. Remove the single rule ID that misfires.

Check afterwards

  • Repeat the action that failed and confirm it no longer returns 403.
  • Watch the hits list for a day. Repeated hits from one IP on LF_MODSEC can also make CSF block that IP; see unblock an IP in WHM CSF.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.