Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Can't publish new custom mod_sec rule

Discussion in 'Security' started by jndawson, Feb 20, 2018.

Tags:
  1. jndawson

    jndawson Well-Known Member

    Joined:
    Aug 27, 2014
    Messages:
    182
    Likes Received:
    18
    Trophy Points:
    18
    Location:
    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 "!@ipMatchFromFile /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.
     
    #1 jndawson, Feb 20, 2018
    Last edited: Feb 20, 2018
  2. fuzzylogic

    fuzzylogic Well-Known Member

    Joined:
    Nov 8, 2014
    Messages:
    74
    Likes Received:
    36
    Trophy Points:
    18
    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.
     
    cPanelMichael likes this.
  3. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    43,245
    Likes Received:
    1,759
    Trophy Points:
    363
    cPanel Access Level:
    Root Administrator
    Hello,

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

    Thank you.
     
  4. jndawson

    jndawson Well-Known Member

    Joined:
    Aug 27, 2014
    Messages:
    182
    Likes Received:
    18
    Trophy Points:
    18
    Location:
    Western US
    cPanel Access Level:
    DataCenter Provider
    We got the error and explanation, just having problems fixing it. Having said that, removing the last "chain" did the trick - thanks!
     
Loading...

Share This Page