So you your boss asked you to secure his new strategic web application which is part of his plan to conquer the world. But that damn developers are used to think that their work is finish when it just works, and debugging their whole code is simply not an option. Here’s the solution: use a web application firewall like ModSecurity2.
ModSecurity can be embedded as a module on your webserver, or you can set up an Apache based reverse web proxy with ModSecurity protecting multiple web sites, without wondering which kind of server they are running.
It can be used in different ways: either to intercept know exploits or suspicious activities, or to simply only allow access to your application web page, parameters, and the kind of characters the value’s parameters are supposed to be… But the last step might require a lot of work, so you may want to combine generic rules with a few rules dedicated to forbid the use of the holes you’ve just found on your brand new web site.
A set of “generic rules” is provided with ModSecurity: the Core Rules. For optimization reasons, the regular expressions (rules are based on regexp) are mixed in a small number of rules and are almost not understandable for most of them. The script used for this task is not yet released, but should be in a “near feature” according to Breach. Update: Yes, it was released here !
You might also pick rules from alternative sources, like gotroot.com.
If you install rules from the tarball found on the website, be sure to remove write permissions on them for everybody (yes, default permissions are -rw-rw-rw- !!!).
Now, let’s try to make a few rules:
You might first want to whitelist an IP address. The following rule can be added to your own file on your core rules directory, or better (especially if you have multiple virtual host), on the virtual host config file:
<IfModule mod_security2.c>SecRule REMOTE_ADDR "^192.168.1.100$" phase:1,nolog,allow,ctl:ruleEngine=DetectionOnly</IfModule>
Read the complete article »