Can't publish new custom mod_sec rule

jndawson

Well-Known Member
Aug 27, 2014
303
32
78
Western US
cPanel Access Level
DataCenter Provider
We have added mod_sec rules in the past using whm > modsecurity tools > add rule with no issues.

We want to add the following, but got an error when trying to publish:

rule
Code:
# Block POST requests by bots accessing wpad
# Whitelist file too just in case.
SecRule REQUEST_URI "wpad" "chain,id:1704,log,t:normalisePath,deny,status:403,msg:'Bot detected - Access denied'"
SecRule REQUEST_METHOD "POST" "chain"
SecRule REMOTE_ADDR "[email protected] /etc/csf/csf.ignore" "chain"
error after trying to publish rule
Code:
Error: The system could not deploy the configuration file “modsec/modsec2.user.conf”. Review the WHM error_log file for more details about the error.
/usr/local/apache/logs/error_log
Code:
AH00526: Syntax error on line 614 of /etc/apache2/conf.d/modsec_vendor_configs/OWASP3/crs-setup.conf:
ModSecurity: Disruptive actions can only be specified by chain starter rules.
We tried using CMC but that just corrupted everything, httpd wouldn't start, errors everywhere, so we deleted the rule from modsec2.user.conf and were able to start httpd.

Can't seem to find anything that explains this anywhere. We're obviously missing something.

specs:
whm/cpanel v.70.0.12
Apache/2.4.29 (cPanel) OpenSSL/1.0.2n mod_bwlimited/1.4
EasyApache 4
OWASP ModSecurity Core Rule Set V3.0

This happens on all cPanel servers we have, btw.
 
Last edited:

fuzzylogic

Well-Known Member
Nov 8, 2014
154
93
78
cPanel Access Level
Root Administrator
I think your chained rule is not saving due to syntax error.
The error is the "chain" in the last clause. It should not be there.

Modsec assumes you want to chain the next rule that it reads after your rule.
The next rule after yours has a disruptive action (as you would expect), so this explains the error you are receiving...
Code:
Disruptive actions can only be specified by chain starter rules.
 
  • Like
Reactions: cPanelMichael

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,224
463
Hello,

The information in the previous post should help. Let us know if you have any additional questions.

Thank you.
 

jndawson

Well-Known Member
Aug 27, 2014
303
32
78
Western US
cPanel Access Level
DataCenter Provider
I think your chained rule is not saving due to syntax error.
The error is the "chain" in the last clause. It should not be there.

Modsec assumes you want to chain the next rule that it reads after your rule.
The next rule after yours has a disruptive action (as you would expect), so this explains the error you are receiving...
Code:
Disruptive actions can only be specified by chain starter rules.
We got the error and explanation, just having problems fixing it. Having said that, removing the last "chain" did the trick - thanks!