Skip to content

Tuning vendor ModSecurity rules on cPanel without forking the rule set

A discipline for adjusting ModSecurity vendor rules on cPanel servers — exclusions, severity changes, paranoia level shifts — that survives the next vendor update.

Every tuned ModSecurity deployment ends up with a stack of local overrides. The mistake we see most often is editing the vendor rule files directly. The next vendor update erases the edits and the false positives return — sometimes with a few hours of customer downtime in between.

What’s happening

cPanel keeps vendor rules under /etc/apache2/conf.d/modsec_vendor_configs/<vendor>/. These files are owned by the vendor package and rewritten on update. WHM exposes a “disabled rules” interface and a “custom rules” interface that survive vendor refreshes. Both write to separate files (whm_modsec_*.conf) that are loaded after vendor rules and override them.

How to verify

whmapi1 modsec_get_settings
whmapi1 modsec_get_rules vendor_id=OWASP3 enabled=0 | head
ls -lt /etc/apache2/conf.d/modsec_vendor_configs/OWASP3/ | head
grep -l "SecRuleRemoveById" /etc/apache2/conf.d/whm_modsec_*.conf

If your customizations live anywhere other than the whm_modsec_*.conf files, they will not survive the next update.

The fix

  1. Never edit vendor files. Treat /etc/apache2/conf.d/modsec_vendor_configs/ as read-only.
  2. Use WHM > ModSecurity Tools > Rules List > Disable for a clean toggle that survives updates and shows up in the UI.
  3. Use Custom Rules in WHM for scoped exclusions: SecRuleUpdateTargetById 942100 "!ARGS:wp_nonce" inside a <LocationMatch "/wp-admin/admin-ajax.php"> block.
  4. For paranoia level shifts in CRS, write a single configuration override file under /etc/apache2/conf.d/modsec2.user.conf that sets tx.crs_setup_version and the paranoia variables. Comment the rationale inline.
  5. Quarterly, diff whm_modsec_*.conf against an archived copy. If your local overrides outnumber 30 lines, the rule set choice itself probably needs revisiting.

Stack Harbor reviews these override files at takeover and on each major cPanel update under WHM server management.