build a single cloudflare firewall expression using only 4 fields that will block 90% of…
- User
build a single cloudflare firewall expression using only 4 fields that will block 90% of malicious traffic
- Assistant
Here's a Cloudflare Firewall expression using 4 fields to block ~90% of malicious traffic by targeting common attack vectors:
( (http.user_agent eq "-") or // Block empty User-Agent (common in bots) (http.request.method not in { "GET", "POST" }) or // Block non-GET/POST methods (e.g., TRACE for XSSI) (cf.request.uri.path matches "(?i).*\/(admin|login|wp-login\\.php|phpmyadmin).*") or // Block paths targeting admin interfaces (cf.request.uri.query matches "(?i)(UNION|SELECT|DROP|INSERT|UPDATE|DELETE).*") // Block SQLi-like patterns in query strings )How it works:
-
Empty User-Agent (
http.user_agent eq "-")
Bots and scrapers often omit or fake User-Agent headers. Blocking requests with no User-Agent reduces automated attacks. -
Non-GET/POST Methods (
http.request.method not in { "GET", "POST" })
Most legitimate traffic usesGETorPOST. Blocking methods likeTRACE,OPTIONS, orPUTstops exploits like Cross-Site Tracing (XSSI) or file uploads. -
Sensitive Paths (
cf.request.uri.path)
Matches common attack targets like:/admin,/login,/wp-login.php(brute-force attacks)/phpmyadmin(database exploitation attempts)
-
SQLi Keywords in Query Strings (
cf.request.uri.query)
Blocks requests with SQL injection patterns likeUNION SELECTorDROP TABLEin the URL query string.
Why these fields?
- High Signal-to-Noise Ratio: These fields are commonly abused in attacks but rarely legitimate.
- Scalability: The rules are simple and efficient for Cloudflare's edge network.
- Coverage: Combines prevention of brute-force, SQLi, and protocol abuse attacks.
Note:
- Adjust regex patterns (e.g.,
wp-login.phporphpmyadmin) to match your site’s structure. - Add exemptions for legitimate traffic if needed (e.g., specific User-Agents for monitoring bots).
- Test in "Challenge" mode first to avoid false positives.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.