# 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 ([[raw/owasp.org/sql-injection-bypassing-waf-owasp-2838|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) ([[raw/portswigger.net/sql-injection-cheat-sheet-web-security-academy-484|PortSwigger cheat sheet]]).
- **Encoding** — URL/double-URL encoding, hex literals, `CHAR()`/`CHR()` string construction, dollar-quoting on PostgreSQL to avoid quotes ([[raw/onsecurity.io/pentesting-postgresql-with-sql-injections-4792|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 ([[raw/picussecurity.com/waf-bypass-using-json-based-sql-injection-attacks-3350|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 ([[raw/owasp.org/sql-injection-bypassing-waf-owasp-2838|OWASP]]).
- **Case sensitivity in app-level blocklists** — a filter matching exact `UNION SELECT` spellings misses `Union Select`, since SQL keywords are case-insensitive ([[raw/classroom.anir0y.in/tryhackme-light-sqlite-injection-past-a-keyword-filter-15840|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 ([[raw/classroom.anir0y.in/tryhackme-light-sqlite-injection-past-a-keyword-filter-15840|TryHackMe Light]]).
- **Channel switching** — when the WAF blocks a keyword (`UNION`), move to boolean or time inference that needs none of it ([[raw/blog.martindios.com/sqli-at-nasa-how-i-got-my-letter-of-recognition-15836|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 ([[raw/secjuice.com/advanced-boolean-based-sqli-filter-bypass-techniques-4215|libinjection bypass]]).
- **Automated / adversarial generation** — tamper frameworks apply context-aware SQL transforms (keyword wrapping, space replacement, homoglyphs, numeric obfuscation) while preserving validity ([[raw/github.com/sqlmap-tamper-collection-modern-waf-bypass-scripts-cloudflare-aws-azur-4790|tamper collection]]); AutoSpear-style adversarial mutation evades signature and ML WAFs alike ([[raw/openappsec.io/open-appsec-ml-based-waf-protects-against-modern-sqli-autospear-evasio-5155|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 ([[raw/vaadata.com/exploiting-an-sql-injection-with-waf-bypass-2837|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 with `ASCII(SUBSTR())` extracted data anyway ([[raw/blog.martindios.com/sqli-at-nasa-how-i-got-my-letter-of-recognition-15836|SQLi at NASA]]).
- **Major-WAF JSON blind spot** — the Claroty/Team82 class of JSON SQLi bypassed five leading commercial WAFs ([[raw/picussecurity.com/waf-bypass-using-json-based-sql-injection-attacks-3350|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 ([[raw/picussecurity.com/waf-testing-guide-how-to-validate-web-application-firewalls-2971|WAF testing guide]]). ML-based detection raises the bar on novel evasions but is still bypassable ([[raw/openappsec.io/open-appsec-ml-based-waf-protects-against-modern-sqli-autospear-evasio-5155|open-appsec]]).
## Related
- [[SQL Injection]]
- [[Blind SQL Injection]]
- [[sqlmap]]
## Sources
- [[raw/blog.martindios.com/sqli-at-nasa-how-i-got-my-letter-of-recognition-15836|SQLi at NASA: how I got my Letter of Recognition]]
- [[raw/classroom.anir0y.in/tryhackme-light-sqlite-injection-past-a-keyword-filter-15840|TryHackMe Light: SQLite injection past a keyword filter]]
- [[raw/github.com/sqlmap-tamper-collection-modern-waf-bypass-scripts-cloudflare-aws-azur-4790|SQLMap Tamper Collection: Modern WAF Bypass Scripts]]
- [[raw/onsecurity.io/pentesting-postgresql-with-sql-injections-4792|Pentesting PostgreSQL with SQL Injections]]
- [[raw/openappsec.io/open-appsec-ml-based-waf-protects-against-modern-sqli-autospear-evasio-5155|ML WAF vs AutoSpear evasion]]
- [[raw/owasp.org/sql-injection-bypassing-waf-owasp-2838|SQL Injection Bypassing WAF (OWASP)]]
- [[raw/picussecurity.com/waf-bypass-using-json-based-sql-injection-attacks-3350|WAF Bypass Using JSON-Based SQL Injection]]
- [[raw/picussecurity.com/waf-testing-guide-how-to-validate-web-application-firewalls-2971|WAF Testing Guide]]
- [[raw/portswigger.net/sql-injection-cheat-sheet-web-security-academy-484|SQL injection cheat sheet - Web Security Academy]]
- [[raw/secjuice.com/advanced-boolean-based-sqli-filter-bypass-techniques-4215|Advanced Boolean-Based SQLi Filter Bypass Techniques]]
- [[raw/vaadata.com/exploiting-an-sql-injection-with-waf-bypass-2837|Exploiting an SQL Injection with WAF Bypass]]