Lab-tested: Local lab server (Python 3.13.5, nginx-style log format) · 2 Dec 2026 · Reproduced and fixed in our lab
Fix Box — Try this first (10 seconds)
Never switch a new WAF rule straight to Block. Run it in Log mode first and read what it would have blocked. If a legitimate visitor or monitor appears in that log, narrow the rule before it ever blocks anyone.
Our 403 pillar guide shows where the WAF sits in the stack.
Why WAF rules cause false 403s
A WAF rule matches request patterns, not intentions. A broad rule like “block User-Agents containing bot” cannot tell a scraper from your uptime monitor.
Both contain the word bot. Both get the same 403.
False positives are the normal cost of broad rules. Tuning is how you pay that cost in a log file instead of in lost visitors.
The tuning loop: log, narrow, block
Every new rule should pass three stages. First, Log mode: the rule records matches but blocks nobody. Second, narrow: add path, header, or IP conditions until only bad traffic matches.
Third, Block mode, with the log still watched for a week.
Skipping stage one is how monitors, payment callbacks, and search crawlers end up blocked on launch day.
Our lab test
We reproduced the full loop on a local lab server on 2 Dec 2026. A broad rule blocked any User-Agent containing “bot”, “curl”, or “scraper”.
The bad scraper got 403 as intended.
So did our legitimate uptime monitor, UptimeBot/2.0 — a textbook false positive:
2026/12/02 [error] WAF block rule 2001 (broad UA), client: 127.0.0.1, server: lab403b, request: "GET /shop"
We switched the same rule to Log mode. The monitor received 200, and the log recorded the would-be block. Then we narrowed the rule to one bad User-Agent on one path.
The monitor stayed 200 and the scraper stayed 403.
Step-by-step tuning
Start from the log, not from a template. In Cloudflare, open Security Events and filter by the rule that fired.
Note which legitimate clients appear: monitors, crawlers, your own office IP.
Narrow by adding conditions. Combine User-Agent with a specific path, or exclude known-good IPs and verified bots.
A rule with two conditions almost always beats a rule with one.
Keep the tuned rule in Log mode for at least a day of real traffic. Read the matches again.
Only when the log shows only bad traffic should the action become Block.
After switching to Block, watch Security Events daily for the first week. A false positive caught in the log costs nothing.
The same false positive in Block mode costs a customer.
The Cloudflare 403 guide covers reading Security Events and Ray IDs. The 403 Checker confirms what a normal visitor sees after each change.
What Did Not Work
Blocking first and reading complaints later failed in our test. The monitor’s 403 looked exactly like the scraper’s 403 in the log.
Without Log mode data, there was no way to tell good matches from bad ones.
Whitelisting the monitor by User-Agent alone also failed as a design. Any scraper can copy that User-Agent string.
The narrow rule plus an IP condition is the safer shape.
Prevention habits
Name every rule with its purpose and date. Review rules quarterly and delete ones whose threat is gone.
Keep one staging rule slot in Log mode so experiments never touch production traffic directly.
FAQ
Frequently Asked Questions
How long should a rule stay in Log mode?
At least one full day of normal traffic, longer for weekly patterns like payment callbacks. Weekend traffic differs from weekday traffic.
My monitor is blocked but visitors are fine. What now?
That is a false positive on a broad rule. Narrow the rule or exclude the monitor’s IP range. Do not disable the rule entirely if it also stops real attacks.
Should I block all bots?
No. Search crawlers and uptime monitors are bots you want. Block by behavior and path, not by the word bot alone.
Where do I see what my WAF blocked?
In Cloudflare Security Events, or your host’s ModSecurity audit log. Both name the rule ID that fired.
Sources and date
Lab test: 2 Dec 2026, local lab server on our SI machine (Python 3.13.5 emitting nginx-style log lines; client IP is localhost).
The broad rule, Log mode, and narrowed rule below are the exact forms measured.
Tested rule forms:
# Broad (caused the false positive — do not ship like this)
block if User-Agent contains "bot" OR "curl" OR "scraper"
# Log mode (same match, no block)
log if User-Agent contains "bot" OR "curl" OR "scraper"
# Narrow (final form)
block if path == "/shop" AND User-Agent contains "BadScraper"
References
- RFC 9110 §15.5.3 — 403 Forbidden: https://www.rfc-editor.org/rfc/rfc9110.html
- MDN Web Docs — 403 Forbidden: https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Status/403
- Cloudflare WAF — Overview: https://developers.cloudflare.com/waf/
- OWASP Core Rule Set — Documentation: https://coreruleset.org/docs/




Leave a Reply