CDN WAF: Edge Security Rules

· Priya Sharma · 4 min read

WAF at the CDN Edge

A Web Application Firewall inspects HTTP requests for malicious patterns and blocks attacks before they reach your origin. Running the WAF at the CDN edge means attacks are stopped at the nearest PoP — your origin never sees the malicious traffic. For foundational context, read CDN DDoS Protection: How CDNs Absorb Volumetric Attacks — FlyFish NWA.

How CDN WAFs Work

  1. HTTP request arrives at the CDN edge
  2. WAF engine evaluates the request against a rule set
  3. Each rule produces a score or match result
  4. If the aggregate score exceeds a threshold, or a critical rule matches, the request is blocked
  5. Clean requests are passed to cache lookup or origin

Processing time: typically 0.1-2ms per request — negligible added latency.

Performance Comparison: Edge vs Origin Processing
Metric Edge Processing Origin Processing Improvement
Latency (p50)8–15 ms120–300 ms15–20x faster
Cache Hit Ratio85–95%N/AReduces origin load
TLS Handshake1–5 ms (nearby PoP)50–150 ms10–30x faster
Bandwidth Cost$0.01–0.04/GB$0.05–0.12/GB3–5x cheaper
Availability99.99% (multi-PoP)99.9% (single DC)10x fewer outages
CDN Security Architecture — Defense-in-depth protection layersCDN Security Architecture — Defense-in-depth protection layers CDN Security Layers — Defense in Depth DDoS Mitigation Web Application Firewall Bot Detection & Rate Limiting SSL/TLS Encryption Origin Server DDoS ✕ Attack ✕ SQLi ✕ PROTECTED
Figure 1: CDN Security Architecture — Defense-in-depth protection layers

Rule Types

Managed Rulesets

Pre-built rule sets maintained by the CDN provider or security vendors:

Custom Rules

Rules you write for your specific application:

# Block requests to admin paths from outside company IP range
IF path matches "/admin/*"
AND source_ip NOT IN 203.0.113.0/24
THEN block

# Rate limit login attempts
IF path = "/api/login"
AND method = "POST"
THEN rate_limit(10 requests/minute per IP)

# Block known bad user agents
IF user_agent contains "sqlmap" OR "nikto" OR "nessus"
THEN block

Rate-Based Rules

Trigger when request volume from a single source exceeds a threshold. More flexible than static rate limiting because they can combine rate with request attributes.

WAF Modes

ModeBehaviorUse When
Detection (log only)Log matches but don't blockInitial deployment, tuning rules
Prevention (block)Block matching requestsProduction after tuning
ChallengeServe CAPTCHA or JS challengeSuspicious but not definitively malicious

Best practice: deploy new rules in detection mode first. Review logs for false positives. Move to prevention after confirming rules match only actual attacks.

Secure Request Flow — How requests pass through security layersSecure Request Flow — How requests pass through security layers CDN Request Flow — From Browser to Edge CDN Request Lifecycle Step 1 DNS Lookup Step 2 TCP Connect Step 3 TLS Handshake Step 4 Edge Server Step 5 Cache Check Step 6 Response Cache HIT → 5ms response Cache MISS → Fetch origin 0ms ~50ms (cache hit) ~200ms (cache miss)
Figure 2: Secure Request Flow — How requests pass through security layers

False Positives

The biggest WAF challenge is false positives — blocking legitimate requests. Common causes:

Mitigation: Create allowlist rules for known-good patterns, tune sensitivity per URL path, use anomaly scoring instead of hard blocks.

CDN WAF Comparison

WAF and Performance

CDN WAFs are designed for minimal latency impact. Processing happens in the same edge server that handles caching and TLS — no separate appliance or network hop. The WAF evaluates requests in parallel with other edge processing. Monitor WAF latency via performance metrics.

External References

References & Standards: HTTP/2 specification · OWASP CDN Security