WAF Bypass for SQL Injection
Techniques that let a SQLi payload reach the database despite a Web Application Firewall, by exploiting the gap between what the WAF parses and what the database parses.
How it works
A WAF inspects the request; the database executes it. Every bypass lives in a parser differential — any construct the WAF normalizes, decodes, or tokenizes differently from the backend (OWASP WAF bypass). Signature-based WAFs match known-bad patterns, so mutation that preserves SQL semantics while breaking the signature gets through; parsing-based WAFs (e.g. libinjection) can be defeated with grammar the tokenizer mis-classifies. A WAF is a backstop, not a fix — the 2026 record is full of “WAF was present” criticals.
Techniques / payloads (categories)
- Case / whitespace / comment mutation —
SeLeCT, inline comments as whitespace (SELECT/**/FROM), and MySQL versioned comments (/*!SELECT*/, which MySQL executes but a naive filter skips) (PortSwigger cheat sheet). - Encoding — URL/double-URL encoding, hex literals,
CHAR()/CHR()string construction, dollar-quoting on PostgreSQL to avoid quotes (Postgres dollar-quoting). - JSON-based SQLi — PostgreSQL/MySQL JSON operators let a payload hide inside JSON syntax that Palo Alto, AWS, Cloudflare, F5 and Imperva WAFs failed to inspect (JSON-based bypass).
- HTTP parameter pollution / fragmentation (HPP/HPF) — split a payload across duplicate params or request parts the WAF evaluates separately but the app recombines (OWASP).
- Case sensitivity in app-level blocklists — a filter matching exact
UNION SELECTspellings missesUnion Select, since SQL keywords are case-insensitive (TryHackMe Light). - Comment bans — instead of truncating with
--//*, end the payload with a lone quote so the app’s own closing quote forms an empty literal (TryHackMe Light). - Channel switching — when the WAF blocks a keyword (
UNION), move to boolean or time inference that needs none of it (SQLi at NASA). - Normalization abuse — exploit a WAF decoding step the backend doesn’t apply (or vice-versa).
- Boolean-blind string functions —
INSERT,REPEAT,REPLACE,RIGHT,WEIGHT_STRING,RLIKE, assignment:=to defeat libinjection specifically (libinjection bypass). - Automated / adversarial generation — tamper frameworks apply context-aware SQL transforms (keyword wrapping, space replacement, homoglyphs, numeric obfuscation) while preserving validity (tamper collection); AutoSpear-style adversarial mutation evades signature and ML WAFs alike (AutoSpear vs ML WAF). Academic “BWAFSQLi” formalizes adversarial-SQL generation against WAFs.
Practical workflow
Confirm the injection manually (Burp Repeater), identify which construct the WAF blocks, then select the minimal evasion for that construct; feed the working transform into automated extraction. Vaadata’s case confirms a boolean-blind SQLi manually, then runs extraction tuned to dodge the WAF (SQLi with WAF bypass).
Notable cases
- Futurum Software CVE-2026-14571 — a misconfigured WAF plus weak validation let unauth blind SQLi exfiltrate PII.
- NASA subdomain — WAF returned 403 on
UNION, boolean blind withASCII(SUBSTR())extracted data anyway (SQLi at NASA). - Major-WAF JSON blind spot — the Claroty/Team82 class of JSON SQLi bypassed five leading commercial WAFs (Picus).
Defenses
Treat the WAF as defense-in-depth only; fix the sink with parameterization and identifier allow-listing. Harden the WAF: canonicalize/normalize input the same way the backend does, inspect JSON and alternate content types, and validate with adversarial payloads via breach-and-attack simulation rather than assuming coverage (WAF testing guide). ML-based detection raises the bar on novel evasions but is still bypassable (open-appsec).
Related
Sources
- SQLi at NASA: how I got my Letter of Recognition · original
- TryHackMe Light: SQLite injection past a keyword filter · original
- SQLMap Tamper Collection: Modern WAF Bypass Scripts · original
- Pentesting PostgreSQL with SQL Injections · original
- ML WAF vs AutoSpear evasion · original
- SQL Injection Bypassing WAF (OWASP) · original
- WAF Bypass Using JSON-Based SQL Injection · original
- WAF Testing Guide · original
- SQL injection cheat sheet - Web Security Academy · original
- Advanced Boolean-Based SQLi Filter Bypass Techniques · original
- Exploiting an SQL Injection with WAF Bypass · original