- Download the rule set(version 2.2.5 because the latest version requires ModSecurity 2.7.0+):
wget https://github.com/SpiderLabs/owasp-modsecurity-crs/tarball/v2.2.5 -O /tmp/owasp.tar.gz
- Extract the package:
cd /tmp; tar -zxvf owasp.tar.gz; rm owasp.tar.gz
- Copy the directory to /etc/modsecurity, and set the permissions:
sudo mv SpiderLabs-owasp-modsecurity-crs-5c28b52/ /etc/modsecurity/owasp-crs
sudo chmod -R 644 /etc/modsecurity/owasp-crs
- Link the rules to /etc/modsecruity/owasp-crs/activated_rules directory:
sudo mv /etc/modsecurity/owasp-crs/modsecurity_crs_10_setup.conf.example /etc/modsecurity/owasp-crs/modsecurity_crs_10_setup.conf
cd /etc/modsecurity/owasp-crs/activated_rules/
sudo ln -s ../modsecurity_crs_10_setup.conf
for f in $(ls ../base_rules/); do sudo ln -s ../base_rules/$f; done
for f in $(ls ../optional_rules/); do sudo ln -s ../optional_rules/$f; done
- Modify /etc/apache2/mods-available/mod-security.conf to include the rules:
sudo vi /etc/apache2/mods-available/mod-security.conf
Add the following line:
Include "/etc/modsecurity/owasp-crs/activated_rules/*.conf"
- Enable headers module:
sudo a2enmod headers
This to fix the following error:Syntax error on line 29 of /etc/apache2/conf.d/modsecurity/optional_rules/modsecurity_crs_49_header_tagging.conf:
Invalid command 'RequestHeader', perhaps misspelled or defined by a module not included in the server configuration
Action 'configtest' failed.
The Apache error log may have more information.
...fail!
when restarting apache2.
Very Neat! Thanks Dude!
ReplyDeleteThank you very much. This is a great tutorial. You listed just the things that I needed to get this up and running. I think there is one issue with the first command in 4C. In order to move the contents of the folder instead of the folder itself, the command needs a trailing asterisk as here:
ReplyDeletesudo mv SpiderLabs-owasp-modsecurity-crs-5c28b52/* /etc/modsecurity/owasp-crs
thank you very much for your tutorial..
ReplyDeleteGreat tutorial, many thanks for taking the time to put it together. After installing and configuring exactly as recommended, Apache won't serve up any pages without kicking out a "403 Forbidden" error for every single request. I realize the ruleset is likely restrictive, but that's a bit much! :)
ReplyDeleteAny quick suggestions to get Apache serving files properly again?
Hello Kevin,
Deletefor bypassing your error "404" you must modify /etc/modsecurity/modsecurity.conf --> SecRuleEngine on to DetectionOnly
good luck
HM
Very good. Tank you.
ReplyDeleteHi,
ReplyDeleteI followed your tutorial step by step but get the following error:
Syntax error on line 53 of /etc/modsecurity/base_rules/modsecurity_crs_20_protocol_violations.conf:
Error parsing actions: Unknown action: ver
Action 'configtest' failed.
The Apache error log may have more information.
...fail!
Any ideas on how to fix it?
Thanks in advance!
follow the above tutor will fix the error dude!
ReplyDelete