How to write Custom WAF rule to block new attacks on web application?
- At first, try to identify the security issue i.e payload or process which normally WAF failed to detect.
- Based on that develope regex pattern to match that payload.
- Follow the modsecurity syntax to write a new rule.
- Save the rule as .conf and include in the default rules directory.
- Restart the Apache server and start testing the WAF rules.
Security Issue Overview:
- Start testing the WAF rule i.e Comodo free WAF rules or OWASP crs rules with vulnerable web application and identifying the security issue in their rules.
-
While testing the Free comodo WAF rules, I find some loop hole which allow user to bypass sql injection rules.
- These are the following payload which free comodo WAF rules failed to detected
**' /\*!or\*/1=1# <br /> ' /\*!order\*/ By 1# <br /> ' || 1=1# <br /> ' && 1=1# <br /> ' /\*!||\*/ 1=1# <br /> ' /\*!&&\*/ 1=1#**
- Fixing the identified security issue by writing custom WAF rule.