Atomic ModSecurity Rules

About the Rules

The gotroot.com rules are written by us - we are the gotroot guys. Same great rules, same team, ten years of writing modsecurity rules and still going strong! GotRoot is our Information Assurance lab and Atomicorp is the product arm of Prometheus Global (the parent company for both). So when you get the gotroot.com rules from atomicorp.com or gotroot.com - you’re getting the same rules from the same people that created, write and maintain them. In the future we will be merging the gotroot.com, atomicrocketturtle and atomicorp websites into the atomicorp.com website.

We offer two types of the rules:

  1. RealTime Rules: The latest and greatest version of the rules, with all the performance enhancements, new security features and bug fixes released by us on a daily basis. These rules are fully supported and are recommended for production use.
  2. Free/Delayed Rules: A delayed subset of the Advanced rules.

Note

Installation of the rules assumes a certain level of comfort with configuring apache. If you are not comfortable with configuring apache, you should contact someone that is, or use our Atomic Secured Linux product which does this automatically for you, and does not require you to configure apache.


Need Atomic ModSecurity Rules?

Click here to get the Atomic ModSecurity rules!


What does each rule family do?

Please see the WAF Rule Families for more information about rules.


Before you begin installing ModSecurity Rules

Note

At a minimum, you must be using ModSecurity version 2.9.1 to use ModSecurity rules.

We recommend customers use our modsecurity builds, as they are tested to ensure all features work correctly. Third party builds may not include the correct libraries, or may disable or incorrectly enable features in modsecurity that can cause unpredictable behavior or failure of rules to process correctly.

If you need a solution to keep the rules and modsecurity up to date and in sync with your version of modsecurity automatically, please use aum or ASL which will do this for you automatically.


Easy Installation of Rules

Install ASL. When you install ASL, you get everything- ModSecurity, all of the rules, the GUI, rule manager, and all ASL components, plus a subscription to the RealTime rules.

ASL will automatically download and keep your rules up to date, and will ensure that modsecurity stays up to date so your system can support the latest rules. ASL also provides you with a full security management suite, which will allow you to manage, edit and configure your rules through a web console. It will also protect you from uploaded malware, brute force attacks, DOS attacks, rootkits and many other threats that a WAF can not protect you from.

Please see the Easy Process below:

Step 1) Install aum by running the following command as root:

wget -q -O - https://updates.atomicorp.com/installers/aum |sh

Step 2) Configure aum by running the following command as root:

/var/asl/lib/modules/configuration_setup.sh

Step 3) Tell aum to install the rules by running the following command as root:

aum -u

Note

This capability is already included with ASL. Therefore, ASL users do not need to install aum.


Do It Youself Installation of Rules

Note

A manual installation is not necessary if you have ASL installed. ASL will configure and install modsecurity, and the rules, automatically. This is also not necessary if you are using our new AUM software to handle rule download and installation.

Linux:

Step 1: Download ModSecurity

Step 2: Setup and Configure Directories

  • If you are using a standard Apache installation you can skip this step. If you are NOT using a standard Apache installation, such as Cpanel, you will need to run the following commands as root:

    mkdir /etc/httpd/modsecurity.d
    mkdir /var/asl
    mkdir /var/asl/tmp
    mkdir /var/asl/data
    mkdir /var/asl/data/msa
    mkdir /var/asl/data/audit
    mkdir /var/asl/data/suspicious
    

Step 3: Set Permissions for Directories

  • Set the following permissions on the directories you just created. In this example these directories are set to be owned by “apache” and the group “apache”, which is standard on a normal Centos or RHEL system. However some control panels configure apache to run as a different user, such as nobody, or http.

    To determine what directories use this, run the following command:

    ps auxwww | grep httpd
    

    The output whould look similar to the following:

    root     26755  0.0  4.3 430752 86432 ?        Ss   04:30   0:01 /usr/sbin/httpd
    apache   26908  0.0  3.7 300564 75076 ?        S    04:30   0:00 /usr/sbin/httpd
    apache   26909  0.1  5.5 495812 112084 ?       S    04:30   0:37 /usr/sbin/httpd
    apache   26910  0.0  5.3 495424 106672 ?       S    04:30   0:23 /usr/sbin/httpd
    apache   26911  0.1  5.7 495892 114368 ?       S    04:30   0:57 /usr/sbin/httpd
    apache   26912  0.1  5.7 496056 114440 ?       S    04:30   0:52 /usr/sbin/httpd
    apache   26913  0.1  5.5 496604 110692 ?       S    04:30   0:57 /usr/sbin/httpd
    apache   26914  0.0  5.7 499324 116236 ?       S    04:30   0:16 /usr/sbin/httpd
    apache   26915  0.2  5.5 493600 112192 ?       S    04:30   1:09 /usr/sbin/httpd
    apache   26916  0.1  6.4 513760 129992 ?       S    04:30   0:30 /usr/sbin/httpd
    

    In this example the user in bold is “apache” (this may be different for your system). This is the user you will want to set the directory permissions to (as in the example below):

    chown apache.apache /var/asl/data/msa
    chown apache.apache /var/asl/data/audit
    chown apache.apache /var/asl/data/suspicious
    chmod o-rx -R /var/asl/data/*
    chmod ug+rwx -R /var/asl/data/*
    

Step 4 (Optional): Create Rule Updater Directories

  • These directories must as be created if you use optional rules updater. Create these directories as root and they only need to be accessed by root:

    mkdir /var/asl/updates
    mkdir /var/asl/rules/
    mkdir /var/asl/rules/clamav
    

Step 5: Create the Whitelist File

  • Create the whitelist file by running the following command as root:

    touch /etc/asl/whitelist
    

    This file contains a list of IPs you want to exclude from ALL rules. That means those IPs can do anything to your system - so be very very careful about what IPs you add to this list. This is a dangerous thing to do. The format of the file is a single IP, per line.

    Note

    Cpanel users should skip to the notes at the bottom of this page for special additional actions for cpanel systems. All other users should continue with these instructions.

Step 6A: Configure your WebServer (Nginx)

  • Configure Nginx to load ModSecurity. If you are using nginx as a frontend to another webserver, then add the following directives to your nginx.conf file.

    location / {
               ModSecurityEnabled on;
               ModSecurityConfig modsecurity.conf;
               proxy_pass http://localhost:8080;
               proxy_read_timeout 180s;
    }
    

    Change “localhost:8011” to the server you are proxying nginx to, and change 8080 to the portnumber for that server. For example, if you are running apache on port 8088 on localhost the line would be:

    proxy_pass http://localhost:8088;
    

  • If you are only using Nginx, and not using it as a frontend to another webserver then you want to use the following configuration:

    location / {
               ModSecurityEnabled on;
               ModSecurityConfig modsecurity.conf;
    }
    

Step 6B: Configure your WebServer (Apache)

  • Configure Apache to load ModSecurity.Depending on your apache configuration, apache should be configured to include configuration files. If you have a setting like this in your apache config:

    Include conf.d/*.conf
    

    Then you are setup to load external configuration files. If you do not have this setup, its highly recommend you add this. This installation guide is written for this type of configuration. Loading mod_security occurs by including a modsecurity configuration file in that directory. We recommend you name the name 00_modsecurity.conf to ensure it runs first. Its vitally important that modsecurity load before other modules, otherwise attacks can occur before modsecurity scans them and some attacks can be missed.

    An example 00_modsecurity.conf file that works with our files is included here:

    <IfModule>
       LoadModule security2_module modules/mod_security2.so
       LoadModule unique_id_module modules/mod_unique_id.so
       <IfModule mod_security2.c>
       Include modsecurity.d/tortix_waf.conf
    </IfModule>
    

    Install this file in your conf.d directory. On a standard RHEL or Centos system taht directory is located here:

    /etc/httpd/conf.d/
    

Step 7: Configure ModSecurity

  • You then need to configure modsecurity. This is done via the an apache configuration file. In this example, we will create the file “tortix_waf.conf”. Here is an example file that works with our rules:

    SecRuleEngine On
    SecRequestBodyAccess On
    SecResponseBodyAccess On
    SecResponseBodyMimeType (null) text/html text/plain text/xml
    SecResponseBodyLimit 2621440
    SecServerSignature Apache
    SecComponentSignature 200911012341
    SecUploadDir /var/asl/data/suspicious
    SecUploadKeepFiles Off
    SecAuditEngine RelevantOnly
    SecAuditLogRelevantStatus "^(?:5|4(?!04))"
    SecAuditLogType Concurrent
    SecAuditLog logs/audit_log
    SecAuditLogParts ABIFHZ
    SecArgumentSeparator "&"
    SecCookieFormat 0
    SecRequestBodyInMemoryLimit 131072
    SecDataDir /var/asl/data/msa
    SecTmpDir /tmp
    SecAuditLogStorageDir /var/asl/data/audit
    SecResponseBodyLimitAction ProcessPartial
    SecAuditLogDirMode 0770
    SecPcreMatchLimit 250000
    SecPcreMatchLimitRecursion 250000
    

    You will want to install this file in your modsecurity.d diectory, which is located here if you followed the instuctions above:

    /etc/httpd/modsecurity.d/
    

Step 8: Download the ModSecurity Rules

Step 9: Remove any previous ModSecurity Rules

  • Remove any previous installations of rules.

    If you have installed our delayed rules, you will need to make sure you have deleted them. You will not want to have any older versions of the rules installed.

    Also, if you have installed any third party modsecurity rules, you will want to make sure they are using rule id’s that are assigned to them. The modsecurity project assigns ranges to the rule id’s modsecurity uses. Modsecurity requires a unique id for each rule, otherwise you will get an error like this:

    ModSecurity: Found another rule with the same id
    

    This means either that someone else is using the same rule id’s assigned to our ruleset by the modsecurity project (our official range is 300000-399999), or you have loaded our rules twice.

Step 10: Install ModSecurity Rules

  • Download the rules to a temporary directory using your favorite download too. Extract the rules:

    tar zxvf /var/asl/updates/modsec-200911012341.tar.gz
    

    Then copy each of the ASL rule files you wish to use into /etc/httpd/modsecurity.d. Do not copy all of the rule files, you will need to select rule files that are appropriate for your system. Or simply use aum or ASL to do this for you automatically.

    If you are using cpanel, please see the notes at the bottom of this page, cpanel does not use the standard locations for apache configuration files.

    Finally, load the rules. Make sure you specify only those rule files that are appropriate for your system. For example:

    Include /full/path/to/your/rules/modsecurity.d/10_asl_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/99_asl_jitp.conf
    

    Note

    You should not include all rules. There are rulesets, tha replace others are are incompatible with each other.

  • Minimum Rulesets for Apache:

    Include /full/path/to/your/rules/modsecurity.d/00_asl_0_global.conf
    Include /full/path/to/your/rules/modsecurity.d/10_asl_antimalware.conf
    Include /full/path/to/your/rules/modsecurity.d/10_asl_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/11_asl_adv_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/20_asl_useragents.conf
    Include /full/path/to/your/rules/modsecurity.d/30_asl_antispam.conf
    Include /full/path/to/your/rules/modsecurity.d/50_asl_rootkits.conf
    Include /full/path/to/your/rules/modsecurity.d/60_asl_recons.conf
    Include /full/path/to/your/rules/modsecurity.d/61_asl_recons_dlp.conf
    Include /full/path/to/your/rules/modsecurity.d/99_asl_jitp.conf
    

    If you are using ModSecurity 2.9.0, you can use this additional ruleset:

    Include /full/path/to/your/rules/modsecurity.d/000_asl_threat_intelligence.conf
    Include /full/path/to/your/rules/modsecurity.d/00_asl_zz_strict.conf
    Include /full/path/to/your/rules/modsecurity.d/00_asl_0_global.conf
    Include /full/path/to/your/rules/modsecurity.d/00_asl_z_antievasion.conf
    Include /full/path/to/your/rules/modsecurity.d/01_asl_content.conf
    Include /full/path/to/your/rules/modsecurity.d/03_asl_dos.conf
    Include /full/path/to/your/rules/modsecurity.d/09_asl_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/10_asl_antimalware.conf
    Include /full/path/to/your/rules/modsecurity.d/10_asl_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/11_asl_adv_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/11_asl_data_loss.conf
    Include /full/path/to/your/rules/modsecurity.d/12_asl_adv_xss_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/20_asl_useragents.conf
    Include /full/path/to/your/rules/modsecurity.d/30_asl_antispam.conf
    Include /full/path/to/your/rules/modsecurity.d/50_asl_rootkits.conf
    Include /full/path/to/your/rules/modsecurity.d/51_asl_rootkits.conf
    Include /full/path/to/your/rules/modsecurity.d/60_asl_recons.conf
    Include /full/path/to/your/rules/modsecurity.d/61_asl_recons_dlp.conf
    Include /full/path/to/your/rules/modsecurity.d/99_asl_jitp.conf
    Include /full/path/to/your/rules/modsecurity.d/98_asl_adv_redactor.conf
    

    If you have a Local DNS resolver setup and configured properly, and are using ModSecurity 2.9.0 we also recommend the following rulesets:

    Include /full/path/to/your/rules/modsecurity.d/00_asl_z_searchengines.conf
    Include /full/path/to/your/rules/modsecurity.d/00_asl_z_aa_threat_intelligence.conf
    Include /full/path/to/your/rules/modsecurity.d/99_asl_zzzz_threat_intelligence.conf
    
  • Minimum Ruleset for Nginx: Use the Apache ruleset above.

  • Minimum Ruleset for Litespeed:

    Include /full/path/to/your/rules/modsecurity.d/00_asl_0_global.conf
    Include /full/path/to/your/rules/modsecurity.d/10_asl_antimalware.conf
    Include /full/path/to/your/rules/modsecurity.d/10_asl_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/11_asl_adv_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/20_asl_useragents.conf
    Include /full/path/to/your/rules/modsecurity.d/30_asl_antispam.conf
    Include /full/path/to/your/rules/modsecurity.d/50_asl_rootkits.conf
    Include /full/path/to/your/rules/modsecurity.d/60_asl_recons.conf
    Include /full/path/to/your/rules/modsecurity.d/61_asl_recons_dlp.conf
    Include /full/path/to/your/rules/modsecurity.d/99_asl_jitp.conf
    

    If you require advanced protection, you should also load the following rulesets:

    Include /full/path/to/your/rules/modsecurity.d/00_asl_zz_strict.conf
    Include /full/path/to/your/rules/modsecurity.d/00_asl_x_searchengines.conf
    Include /full/path/to/your/rules/modsecurity.d/00_asl_y_searchengines.conf
    Include /full/path/to/your/rules/modsecurity.d/00_asl_0_global.conf
    Include /full/path/to/your/rules/modsecurity.d/00_asl_z_antievasion.conf
    Include /full/path/to/your/rules/modsecurity.d/01_asl_content.conf
    Include /full/path/to/your/rules/modsecurity.d/00_asl_zz_strict.conf
    Include /full/path/to/your/rules/modsecurity.d/03_asl_dos.conf
    Include /full/path/to/your/rules/modsecurity.d/09_asl_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/10_asl_antimalware.conf
    Include /full/path/to/your/rules/modsecurity.d/10_asl_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/11_asl_adv_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/11_asl_data_loss.conf
    Include /full/path/to/your/rules/modsecurity.d/12_asl_adv_xss_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/20_asl_useragents.conf
    Include /full/path/to/your/rules/modsecurity.d/30_asl_antispam.conf
    Include /full/path/to/your/rules/modsecurity.d/50_asl_rootkits.conf
    Include /full/path/to/your/rules/modsecurity.d/51_asl_rootkits.conf
    Include /full/path/to/your/rules/modsecurity.d/60_asl_recons.conf
    Include /full/path/to/your/rules/modsecurity.d/61_asl_recons_dlp.conf
    Include /full/path/to/your/rules/modsecurity.d/99_asl_jitp.conf
    

Step 10A: Test your WebServer (Nginx)

  • For non ASL Systems:

    Step 1) Make sure you have the rules installed exactly as described on this page. This test may not work if you have not followed these instructions. (If you used ASL to setup your WAF, and you have not installed any third party tools that configure, install or manage modsecurity then your rules are installed correctly and you do not need to review the instructions on this page. If you have manually altered your modsecurity configuration then you will need to review this entire article. Manual modifications of ASL modsecurity configurations are not supported.)

    Step 2) Make sure all rules are enabled

    Step 3) Test from a non-whitelisted system

    Step 4) Run the following test from the system:

    wget http://localhost/foo.php?foo=http://www.example.com
    

    If the test worked, you will see output similar to the following:

    --2010-05-27 20:12:25--  http://localhost/foo.php?foo=http://www.example.com
    Resolving localhost... 127.0.0.1
    Connecting to localhost|127.0.0.1|:80... connected.
    HTTP request sent, awaiting response... 403 Forbidden
    2010-05-27 20:12:25 ERROR 403: Forbidden.
    

    If you did not get a 403 error, then the test did not work.

  • What to do if you do not get a 403 error:

    • You may have rules disabled, make sure your rules are enabled.

    • Your IP is whitelisted. There is a rule whitelisting the system you are conducting this test from. Whitelisting tells the WAF to ignore everything from that source.

      For example, cpanels default modsecurity configuration will configure modsecurity to ignore everything from 127.0.0.1, or from the system itself. So if you perform the test above from the server itself, and you have not removed this cpanel whitelist, then you will not get a 403 error. More than likely you will get a 404 error. The solution is to remove any whitelists from your system.

      Note

      Whitelisting the server itself can open a hole in your security. You should not whitelist localhost or the servers own IP address, particularly if you have multi users on the system. This is both unnecessary, and doing so will allow any users on the system to carry out attacks on other domains on the system unimpeded. Make sure you do not have any rules like that, this opens a very large hole in your system.

    • Local error message is different. You or someone else may have configured your system to use a different error message. Check your configuration, and make sure it exactly matches the ones on this wiki. IF you are using kind of plugin that does not return a 403 when a connection is rejected, and you must use this, then you will need to manually check your mod_security logs to see if your test is being rejected by modsecurity. If it is, then your rules are working correctly and you can ignore the error code.

    • Third-Party addons. You have third party rules or addons installed with your modsecurity configuration that are changing the responses. Remove all third party addons, and make sure your configuration exactly matches the instructions on this page

    • Insecurely Configured Apache. Some control panels are known to disable modsecurity on localhost, and on the systems IP addresses. These highly insecure control panels essentially disable modsecurity if an attacker connects to the systems IP address. This of course leaves your system wide open to attack, and if you are unlucky enough to be using one of these control panels we recommend you report this to your control panel vendor as a serious vulnerability. If they are unwilling to fix it, then we recommend you find a more security concious control panel vendor.

      Example: We have seen some control panels that configure modsecurity to be disabled in the /etc/httpd/conf/httpd.conf file for all the local IPs on the system.

      <VirtualHost <LOCAL IP ADDRESS>:80 127.0.0.1:80 *>
        <IfModule mod_security2.c>
          SecRuleEngine Off
        </IfModule>
      

      If your control panel has this vulnerability, you can remove this, but its very possible the control panel will simply open this hole in your system again. We highly recommend you report this vulnerability to your control panel vendor, and if they are unwilling to fix this vulnerability that you find a more security concious control panel vendor.

    • You aren’t loading the rules. This is common with custom configurations. Check to make sure your webserver is configured to load the rules. Keep mind that modsecurity will still generate generic messages even though the rules are not loaded. For example, if all you see are events like this:

      --70c19f31-A--
      [01/Jan/2013:11:19:13 --0300] roiKIi6Ni3EKFZSKpSUs2iEb 1.2.3.4 34978 5.6.7.8 80
      
      --70c19f31-B--
      HEAD / HTTP/1.1
      User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64)
      
      Accept: */*
      
      --70c19f31-F--
      HTTP/1.1 403 Forbidden
      X-Powered-By: PHP/5.4.20
      Expires: Thu, 19 Jan 2001 02:12:00 GMT
      Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
      Pragma: no-cache
      Connection: close
      Content-Type: text/html
      
      --70c19f31-H--
      Stopwatch: 1383338363503919 358184 (- - -)
      Stopwatch2: 1383338363503919 358184; combined=2144, p1=37, p2=2053, p3=0, p4=0, p5=53, sr=0, sw=1, l=0, gc=0
      Producer: ModSecurity for Apache/2.7.5 ( http://www.modsecurity.org/).
      Server: Apache
      Engine-Mode: "ENABLED"
      
      --70c19f31-Z--
      

      In this example, no rule is being triggered, but modsecurity is logging a basic 403 error. It will do this if the modsecurity configuration is loaded, but not the rules. So if you see this happening on your system, and you have ruled out all other issues in this list, it means your custom configuration isnt loading the rules.

      ASL will automatically configure modsecurity correctly. So if you are having problems configuring modsecurity yourself, then we recommend you use ASL to setup modsecurity for you.


ModSecurity for Windows

Please see the ModSecurity IIS page.


Troubleshooting ModSecurity Rules

Please see the Atomicorp WAF Rules Troubleshooting page.


Tuning Atomic ModSecurity Rules

Please see the Mod Security Page for more information.


Frequently Asked Questions

Please see the Atomic ModSecurity Frequently Asked Questions page.

Special Notes for Cpanel Users Not Using ASL

The Atomicorp Modsecurity rules work great with Cpanel, right out of the box. To use them with Cpanel either install ASL, or manually install modsecurity and make a few changes to the mod_security configuration that comes with cpanel and then you are all set!

Installing ModSecurity in CPanel:

  • Install ASL. This will install ModSecurity, configure it, and install the rule and event management GUI.

Manually Configuring ModSecurity with Cpanel:

These are additional considerations for installing modsecurity with cpanel. Please read this entire page, as well as this section if you are installing modsecurity with cpanel (even if you already have modsecurity install with cpanel).

We recommend if you are using cPanel that you follow this advice, as cpanel includes a very minimal configuration for modsecurity that does not include all of the required and optimal settings documented here. Our settings will make your server faster, and more importantly more secure. If you use mod_security with Cpanel you must add these additional settings to experience the full feature set of mod_security.

Follow the process below:

  • Make sure you have read this entire document and have setup all the require directories details above.

  • Configure directory permissions. Cpanel also does not run apache as a standard user (such as apache) but as the older non-privileged user “nobody”. You will need to ensure then that the work directories that mod_security uses are owned by the user that Cpanel runs apache as. To find this out you can run this command as root:

    ps auxwww | grep httpd
    

    You should see output similar to the following:

    root     20594 86.8  3.1 255148 181232 ?       Ss   11:39   0:04 /usr/local/apache/bin/httpd -k restart
    root     20611  0.0  3.1 255060 179596 ?       S    11:39   0:00 /usr/local/apache/bin/httpd -k restart
    nobody   20612  0.0  3.1 255148 180224 ?       S    11:39   0:00 /usr/local/apache/bin/httpd -k restart
    nobody   20613  0.0  3.1 255148 180224 ?       S    11:39   0:00 /usr/local/apache/bin/httpd -k restart
    nobody   20614  0.0  3.1 255148 180224 ?       S    11:39   0:00 /usr/local/apache/bin/httpd -k restart
    nobody   20615  0.0  3.1 255148 180224 ?       S    11:39   0:00 /usr/local/apache/bin/httpd -k restart
    nobody   20616  0.0  3.1 255148 180224 ?       S    11:39   0:00 /usr/local/apache/bin/httpd -k restart
    

    In this example from a Centos system running Cpanel the user is “nobody”, so you would want to use these commands to configure the modsecurity work directories for a system where apache is running as “nobody”:

    mkdir /var/asl
    mkdir /var/asl/data/
    mkdir /var/asl/data/msa
    mkdir /var/asl/data/audit
    mkdir /var/asl/data/suspicious
    chown nobody.nobody /var/asl/data/msa
    chown nobody.nobody /var/asl/data/audit
    chown nobody.nobody /var/asl/data/suspicious
    chmod o-rx -R /var/asl/data/*
    chmod ug+rwx -R /var/asl/data/*
    

  • Install ModSecurity

  • Configure CPanel. Make a small change to the cpanel modsecurity configuration. A typical cpanel modsec2.conf configuration file looks like this:

    LoadFile /opt/xml2/lib/libxml2.so
    LoadFile /opt/lua/lib/liblua.so
    LoadModule security2_module  modules/mod_security2.so
    <IfModule mod_security2.c>
    SecRuleEngine On
    # See http://www.modsecurity.org/documentation/ModSecurity-Migration-Matrix.pdf
    #  "Add the rules that will do exactly the same as the directives"
    # SecFilterCheckURLEncoding On
    # SecFilterForceByteRange 0 255
    SecAuditEngine RelevantOnly
    SecAuditLog logs/modsec_audit.log
    SecDebugLog logs/modsec_debug_log
    SecDebugLogLevel 0
    SecDefaultAction "phase:2,deny,log,status:403"
    Include "/usr/local/apache/conf/modsec2.user.conf"
    </IfModule>
    

    Because cpanel will overwrite this configuration, you need to modify your user configuration file. You will want to setup your user configuration file (/usr/local/apache/conf/modsec2.user.conf) as in the example below. This is the recommended configuration and the minimum recommended rule sets that are designed to work with cpanel without ASL installed. Please be sure to read this entire page for information about additional rules that you may also want to use with cpanel.

    SecRequestBodyAccess On
    SecAuditLogType Concurrent
    SecResponseBodyAccess On
    SecResponseBodyMimeType (null) text/html text/plain text/xml
    SecResponseBodyLimit 2621440
    SecAuditLogRelevantStatus "^(?:5|4(?!04))"
    SecServerSignature Apache
    SecUploadDir /var/asl/data/suspicious
    SecUploadKeepFiles Off
    SecAuditLogParts ABIFHZ
    SecArgumentSeparator "&"
    SecCookieFormat 0
    SecRequestBodyInMemoryLimit 131072
    SecDataDir /var/asl/data/msa
    SecTmpDir /tmp
    SecAuditLogStorageDir /var/asl/data/audit
    SecResponseBodyLimitAction ProcessPartial
    
    Include /full/path/to/your/rules/modsecurity.d/00_asl_z_antievasion.conf
    Include /full/path/to/your/rules/modsecurity.d/00_asl_zz_strict.conf
    Include /full/path/to/your/rules/modsecurity.d/09_asl_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/10_asl_antimalware.conf
    Include /full/path/to/your/rules/modsecurity.d/10_asl_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/11_asl_adv_rules.conf
    Include /full/path/to/your/rules/modsecurity.d/20_asl_useragents.conf
    Include /full/path/to/your/rules/modsecurity.d/30_asl_antispam.conf
    Include /full/path/to/your/rules/modsecurity.d/50_asl_rootkits.conf
    Include /full/path/to/your/rules/modsecurity.d/60_asl_recons.conf
    Include /full/path/to/your/rules/modsecurity.d/61_asl_recons_dlp.conf
    Include /full/path/to/your/rules/modsecurity.d/99_asl_jitp.conf
    

    If you want to load just some of the rules, make sure you specify only those rule files. The default list above is the recommended and supported rulesets with cpanel. Do not use the other asl rulesets with cpanel, those other rules either use other apache modules (such as mod_sed) or ASL specific features that require ASL.

    Make sure you have all of the settings on this page to use modsecurity with cpanel correctly, failing to do that will make it impossible for us to support you and modsecurity will not as quickly or correctly exposing your system to attack and slowing it down.

  • Install mod_uniqueid: Cpanel users will need to manually verify that the mod_unique_id module is loaded by cpanel’s apache. It should be loaded by default, but check your cpanel configuration to be sure.

  • Restart Apache by running the following command:

    service httpd restart
    

CPanel Errors

modsecparse.pl

  • This is a third party tool not provided by, or supported by Atomicorp. If you use this tool, it apparently does not work with the new fast concurrent logging system in modsecurity. The concurrent logging system is much faster, will speed up apache and is less resource intensive that the older serial method.

    However, if you use this tool you must use the slower serial logging method, as it does not support the faster concurrent method. To use this tool, change the SecAuditLogType setting from “Concurrent” to “Serial”:

    SecAuditLogType Serial
    

    Keep in mind that this logging method is much slower, may slow down apache and is not supported. This performance impact is not caused by the rules. Serial logging is much slower than concurrent logging. Therefore we do not recommend you use this logging method or any tools that require it. There are lots of modsecurity log readers that can use the concurrent logging method, such as ASL and we encourage you to explore using one of those modern tools instead.


Serial Logging

  • Serial logging is the older slower depreacted logging method modsecurity original used many years ago. This logging method would log the entire event in a single file. As a result, it would slow apache down because each event needed to wait for the previous event to finish writing before it could write to the log file. Events stack up and slow apache down. This incurs a significant performance penalty on apache, and of course a better method was devised for modsecurity to address this performance issue. The solution is the concurrent logging method. This generates a unique event file for each log event, logging the events data to that file instead of trying to jam tons of data into a single file, and thereby slowing down apache. All modern modsecurity log viewing tools support the concurrent method.

    The concurrent logging system is much faster, will speed up apache and is less resource intensive that the older serial method. This method is highly recommended over the slow serial logging method.

  • Configuring Serial Logging using AUM:

    If you want to use older, slower serial logging methond, and you are using aum, change this setting in /etc/asl/config

    MODSEC_LOGTYPE="Serial"
    

    Run the following command to update the ASL security policy:

    aum -uf
    

  • Configuring Serial Logging without using AUM:

    If you want to use the old slower serial logging method change the SecAuditLogType setting from “Concurrent” to “Serial”:

    SecAuditLogType Serial
    

    Serial logging is much slower than concurrent logging and will slow down apache. Any performance impact is not caused by the rules.

    Therefore we do not recommend you use this logging method or any tools that require it. There are lots of modsecurity log readers that can use the fast concurrent logging method, such as ASL and we encourage you to explore using one of those modern tools instead of a tool that requires the slower and performance degrading serial logging method.

    If you change your system to the slower Serial method, you may also want to change the logfile name you are using for your modsecurity logs. You can do that by changing this option in your configuration:

    SecAuditLog logs/audit_log
    

Support

If you have a subscription of Real Time rules, you can request email support by sending an email to support@atomicorp.com

The Customer Forums are located here

Additionally, you can login to the Customer Portal to submit bug reports and open cases.


Licensing

The Real Time Atomic ModSecurity Rules are licensed by the server. You can order license from the online store

If you require additional licenses please log into the License Manager .

License Terms and Conditions

Purchase of an Atomicorp ModSecurity rule license entitles the purchaser to access and download from the Atomicorp Repository to a single IP address within the time period of the license. A separate license is required for each dedicated server/host or VPS that the rule set is installed upon or is protecting.

Atomicorp ModSecurity rules installed upon a Reverse Proxy WAF appliance/server requires a separate license. Please contact Atomicorp support for details.

The rule set cannot be copied, mirrored, or reproduced under protection of US and International copyright laws.

Use of the rule set is limited to the time period of the license. If the license period of a rule set expires, it must must removed from its installed server and no longer used. Atomicorp reserves the right to track and enforce license compliance of the Atomicorp Modsecurity rule sets.

Agreement to these terms and conditions and the Atomicorp End User License Agreement is required to download and use the Atomicorp ModSecurity rules.