
Introduction
Deploying a WAF in front of an app is easy; getting web application firewall rules right without blocking legitimate users—or quietly turning the rules off when false alarms hit—is the hard part. If you already know the basics from our complete guide to web application firewalls, this article focuses on the rule layer itself: how ModSecurity and the OWASP Core Rule Set (CRS) evaluate HTTP requests, how to run a safe nginx WAF, how anomaly scoring and paranoia levels work, how to tune false positives cleanly, and where WAF rules stop helping.
As of November 25, 2026, the OWASP Core Rule Set project maintains the CRS 4.x branch—with v4.31.0 released on November 23, 2026 and v4.25.2 serving as the current LTS release—while CRS 3.3.x has reached end of life. On the engine side, ModSecurity v3.0.17 (and the ModSecurity-nginx connector) remains a widely used open-source SecRules engine for nginx, alongside Apache mod_security2 and the Go-based OWASP Coraza engine (v3.8.1). Understanding how these rules score traffic lets you keep protection high without breaking forms, CMS editors, or APIs.
Key Facts: Web Application Firewall Rules at a Glance
- Core open-source ruleset: OWASP CRS (
v4.31.0latest;v4.25.2LTS as of November 25, 2026; CRS3.3.xis EOL) provides generic detection for SQLi, XSS, RCE, path traversal, and protocol anomalies. - Anomaly scoring beats single-rule blocking: CRS rules add points (
CRITICAL +5,ERROR +4,WARNING +3,NOTICE +2) and block only when the transaction total meets the threshold (default5). - Four Paranoia Levels (PL1–PL4): PL1 aims for baseline protection with minimal false positives; PL2–PL4 catch sneakier payloads but require active rule exclusions.
- Nginx WAF setup: Uses
libmodsecurity(ModSecurity v3) with theModSecurity-nginxconnector—or compatible alternatives like Coraza—and should start inDetectionOnlymode. - CRS 4.31.0 migration caveat:
tx.allowed_methodsandtx.allowed_http_versionsnow require pipe-delimited tokens (such as|GET| |POST|and|HTTP/1.1| |HTTP/2|) instead of space-separated strings. - Virtual patching limit: OWASP warns that WAF rules only inspect traffic they see and payloads their rules match—they reduce exposure temporarily, never replacing code fixes.
Types of Web Application Firewall Rules
Not all web application firewall rules serve the same purpose. Most production deployments combine four categories:
- Managed generic rulesets (negative security model): Rules like OWASP CRS look for known attack patterns—SQL keywords in parameters,
<script>handlers, shell command separators, or malformed HTTP headers. Because they use a blocklist approach, they work out of the box across many frameworks. - Protocol enforcement and positive allowlists: Rules that enforce valid HTTP methods, allowed
Content-Typecharsets, maximum argument counts, and strict schema validation on JSON APIs. Positive rules reject anything outside expected structure. - Rate-limiting and bot rules: Rules throttling repeated
POST /wp-login.phpor credential-stuffing requests by IP, session, or endpoint—often handled jointly by nginxlimit_reqand WAF rules. - Virtual patches (custom targeted rules): Short-term rules written for a specific CVE or zero-day endpoint while developers test and ship the real source code fix.
How OWASP CRS Anomaly Scoring Works
Older WAF setups used self-contained mode, where the first matching rule immediately dropped the request with HTTP 403. That made tuning painful because one noisy rule hid other matches and forced risky all-or-nothing overrides.
OWASP CRS solves this with anomaly scoring (collaborative detection). Individual detection rules do not block on their own. Instead, they inspect the request (or response), log a match, and increment a transaction variable:
CRITICALmatch:+5pointsERRORmatch:+4pointsWARNINGmatch:+3pointsNOTICEmatch:+2points
By default, CRS sets the inbound anomaly threshold to 5. A single CRITICAL SQL-injection rule triggers an immediate block at evaluation time, whereas two WARNING anomalies (3 + 3 = 6) combine to block a suspicious request even if neither rule alone looked conclusive. Separate inbound and outbound scores let you block leaked database error strings in responses (RESPONSE_BODY) independently of inbound checks.
One subtle CRS detail: unless early blocking (tx.early_blocking=1, rule 900120 in crs-setup.conf) is enabled, blocking evaluation runs after Phase 2 rules finish. If your web server issues a redirect in Phase 1 before Phase 2 evaluation, a malicious Phase 1 request could slip through with a redirect instead of a 403.

Choosing and Upgrading Paranoia Levels Safely
OWASP CRS organizes rules into four Paranoia Levels (PL):
| Paranoia Level | Intended Environment | False Positive Risk | Recommended Approach |
|---|---|---|---|
| PL 1 | Any internet-facing web app or API | Very low (baseline) | Default starting point for all sites |
| PL 2 | Apps handling user accounts or personal data | Moderate | Expect exclusions for rich-text/HTML forms |
| PL 3 | Financial portals, high-value enterprise apps | High without tuning | Require dedicated staging and audit log review |
| PL 4 | Maximum-sensitivity gateways | Very high | Only with sustained security engineering time |
Instead of raising the anomaly threshold to 10 when moving from PL1 to PL2—which OWASP CRS explicitly discourages because single low-scoring attack classes would stop blocking—use Executing Paranoia Level (tx.executing_paranoia_level). Keep your blocking paranoia level at 1, set tx.executing_paranoia_level=2, and CRS will log PL2 matches without counting them toward the blocking score. Once you have written exclusions for legitimate traffic, raise the blocking paranoia level to 2.
Setting Up an Nginx WAF with ModSecurity and OWASP CRS
Unlike Apache (mod_security2), nginx uses ModSecurity v3 (libmodsecurity) compiled as a dynamic module via the ModSecurity-nginx connector. A minimal nginx server block looks like this:
server {
listen 443 ssl;
server_name example.com;
modsecurity on;
modsecurity_rules_file /etc/nginx/modsec/main.conf;
location / {
proxy_pass http://app_backend;
}
}Inside /etc/nginx/modsec/main.conf, include the core ModSecurity configuration (SecRuleEngine DetectionOnly initially), crs-setup.conf, and the CRS .conf rules directory.
If you are deploying or upgrading to OWASP CRS v4.31.0 (released November 23, 2026), watch out for its breaking syntax change in crs-setup.conf: tx.allowed_methods (rule 900200) and tx.allowed_http_versions (rule 900230) now require pipe-delimited entries rather than space-separated strings:
SecAction \
"id:900200,\
phase:1,\
pass,\
t:none,\
nolog,\
setvar:'tx.allowed_methods=|GET| |HEAD| |POST| |OPTIONS|'"Leaving old space-separated values in a custom crs-setup.conf causes rules 911100 and 920430 to flag every request. Also keep nginx itself patched alongside your WAF—see our nginx security update guide.
Tuning False Positives Without Gutting Security
Every real-world app eventually hits a false positive—for example, a CMS admin saving <script> or <h1> markup in a post editor triggers CRS XSS rule 941320 on ARGS:wp_post. Never turn off the entire WAF or delete core .conf files, because your edits will be wiped on the next CRS upgrade.
Instead, CRS provides two dedicated exclusion files:
REQUEST-900-EXCLUSION-RULES-BEFORE-CRS.conffor runtime exclusions (ctl:ruleRemoveById/ctl:ruleRemoveTargetById), which inspect the URI or host first and modify CRS behavior per request.RESPONSE-999-EXCLUSION-RULES-AFTER-CRS.conffor configure-time exclusions (SecRuleRemoveById/SecRuleUpdateTargetById), which execute after CRS rules are loaded.
Prefer the narrowest scope possible: exclude a single parameter on a single URI path, not an entire rule globally:
# Runtime exclusion placed BEFORE CRS rules:
# Allow HTML tags inside the 'content' field only on /wp-admin/post.php
SecRule REQUEST_URI "@beginsWith /wp-admin/post.php" \
"id:10010,\
phase:1,\
pass,\
t:none,\
nolog,\
ctl:ruleRemoveTargetById=941320;ARGS:content"CRS also ships official exclusion plugins for common applications such as WordPress, Drupal, Nextcloud, and phpMyAdmin. Scope those plugins to the exact path or hostname where the app lives rather than enabling them site-wide.
Virtual Patching and Where WAF Rules Fall Short
When a critical vulnerability drops—like Drupal core CVE-2026-132165, where attackers target /core/install.php—a targeted WAF rule or web-server deny rule buys crucial time before maintenance windows open. Following the OWASP Virtual Patching Cheat Sheet, treat a virtual patch as a formal six-step process: prepare, identify, analyze the exact vulnerable parameter or route, write a targeted rule, test in log-only mode against evasion encodings (URL encoding, case variations, path normalization), and track its removal once the source patch ships.
Even well-tuned web application firewall rules cannot catch everything. WAFs inspect HTTP syntax, not business logic:
- Broken object-level authorization (IDOR) and flawed access control from the OWASP Top 10 look like normal requests on the wire.
- Weak browser protections require HTTP security headers, not just request filtering.
- Encrypted TLS termination issues or server process bugs (such as HTTP/2 or early-data flaws) happen before or outside WAF payload inspection.
FAQ
Should I run ModSecurity and OWASP CRS in DetectionOnly mode first?
Yes. Always launch new WAF deployments or higher paranoia levels in SecRuleEngine DetectionOnly (or use tx.executing_paranoia_level) for at least several days of representative production traffic, review the audit logs, write targeted exclusions, and only then switch to SecRuleEngine On.
What is the difference between ModSecurity v2, ModSecurity v3, and Coraza?
ModSecurity v2 runs tightly integrated as an Apache module (mod_security2). ModSecurity v3 (libmodsecurity) is a standalone C++ library designed to work with connectors like ModSecurity-nginx. OWASP Coraza is a modern Go-based WAF engine compatible with SecRules and OWASP CRS.
Why did upgrading to OWASP CRS 4.31.0 block normal GET and POST requests?
CRS 4.31.0 changed tx.allowed_methods (rule 900200) and tx.allowed_http_versions (rule 900230) to require pipe-delimited values such as |GET| |POST|. If you carried over an older space-separated crs-setup.conf, rules 911100 and 920430 will reject valid traffic until updated.
How do I fix a WAF false positive safely?
Check the audit log for the exact rule ID, URI, and matched variable (such as ARGS:comment), then use ctl:ruleRemoveTargetById in BEFORE-CRS or SecRuleUpdateTargetById in AFTER-CRS so the rule still protects every other parameter and endpoint.
Can WAF rules replace updating WordPress, Drupal, or nginx?
No. OWASP’s Virtual Patching Cheat Sheet explicitly warns that WAF rules reduce exposure only for inspected traffic and known payload patterns; alternate encodings or uninspected paths can bypass signatures. Always apply vendor security updates.
Conclusion
Effective web application firewall rules balance broad attack coverage with surgical tuning. Start with OWASP CRS 4 at Paranoia Level 1 in DetectionOnly mode, understand how anomaly scoring combines warnings, use Executing Paranoia Level and parameter-scoped exclusions to eliminate false alarms, and pair your WAF with timely patching and strong HTTP security headers.
References
All references below were verified on November 25, 2026.
- OWASP Core Rule Set (CRS) Documentation
- OWASP CRS: Anomaly Scoring
- OWASP CRS: Paranoia Levels
- OWASP CRS: False Positives and Tuning
- OWASP CRS v4.31.0 Release Notes (GitHub)
- OWASP ModSecurity (GitHub)
- ModSecurity-nginx Connector (GitHub)
- OWASP Virtual Patching Cheat Sheet
Related Articles
- Complete Guide to Web Application Firewall WAF
- OWASP Top 10 Explained: A Practical Guide to Website Security
- HTTP Security Headers: What to Set, How to Configure Them and How to Test
- Drupal Security Update: Patch the Installer RCE (CVE-2026-132165) Now
- Nginx Security Update: 1.30.7 and 1.31.9 Fix 10 CVEs
Last Verified: November 25, 2026. Prepared by SafeWebAcademy from OWASP CRS, ModSecurity, and OWASP Cheat Sheet documentation linked above. Ruleset releases and syntax evolve; verify crs-setup.conf breaking changes before upgrading.