How I Bypassed Bad WAF Rules

August 11, 2026 Melalew Mengistu

I used to think a WAF was like a dedicated bodyguard for a single web app — you install it, point it at your site, and suddenly you're bulletproof. That illusion lasted until I ran into one during a routine penetration test. I spent maybe ten minutes poking at a login form, tried a few encoded payloads, and watched the WAF sit there completely silent. The application behind it? Not so silent. The database error that came back told me everything I needed to know: the WAF wasn't protecting the app. It was just making the attack slightly more annoying.

That moment forced me to stop asking "Is there a WAF?" and start asking "What is the WAF actually doing, and can I get around it?" I realized I didn't understand WAFs at all. I didn't know where they lived in the stack, why they were invented, who actually needs one, or how much control I had over the rules. I had to rebuild my mental model from scratch.

What This Guide Actually Covers

This isn't a WAF sales pitch. I'm walking through how I learned to bypass poorly configured WAF rules — what a WAF actually is at the OSI layer level, why it was invented, who should use one, how much control you have over the rules, and why AI-driven WAFs are promising but not magic. Most importantly, I'll show you why a WAF is a filter, not a force field.

What a WAF Actually Is (And Where It Lives)

My first mistake was thinking a WAF was network-level security, like a firewall blocking ports. It's not. A Web Application Firewall operates at Layer 7 — the Application layer. It inspects HTTP traffic: the request method, headers, query strings, cookies, and body content. It doesn't care that your server is listening on port 443. It cares that someone sent UNION SELECT inside a search parameter.

WAFs exist because traditional firewalls can't read HTTP. A port-based firewall sees traffic hitting port 80 or 443 and assumes it's legitimate web traffic. It has no idea whether that traffic contains SQL injection, cross-site scripting, or a path traversal payload. The WAF was invented to fill that gap — to inspect what is being sent, not just where it's going.

Most WAFs sit in one of three places: as a reverse proxy in front of your application, as a module inside your web server (like ModSecurity for Nginx or Apache), or as a cloud service (Cloudflare, AWS WAF, Azure Front Door). In all three cases, the WAF sees the request before your application does, makes a decision, and either forwards it, blocks it, or sanitizes it.

How I Bypassed the Rules

The WAF I encountered was running a default rule set with zero customization. The administrator had turned it on, checked the "block SQL injection" box, and moved on. That confidence was the vulnerability.

Here is what a naive WAF rule looks like in practice. It scans for the literal string union select:

HTTP
GET /api/search?q=union+select+password+from+users

The WAF blocked that immediately. But security isn't about whether the obvious attack works. It's about whether the slightly modified attack works. I tried URL encoding:

HTTP
GET /api/search?q=%75%6E%69%6F%6E+%73%65%6C%65%63%74+password+from+users

Blocked again — the WAF was decoding the URL before inspection. So I tried mixed case and inline comments, a classic evasion technique that breaks simple string matching:

HTTP
GET /api/search?q=UnI/**/oN+SeL/**/eCt+password+from+users

That sailed straight through. The rule was looking for the exact contiguous string union select. It had no concept of SQL syntax, just regex. I spent the next hour mapping out which payloads were caught and which weren't. Within two hours, I had a working blind SQL injection that the WAF never noticed.

The problem wasn't that WAFs are useless. The problem was that bad rules are worse than no rules because they create a false sense of security. The developer thought the app was protected, so they didn't prioritize input validation. The WAF became an excuse for lazy code.

Who Actually Needs a WAF?

This experience also answered another question I had: who is a WAF actually for? The honest answer is public-facing applications that accept user input, especially legacy applications where you can't fix the source code immediately. If you're running a static marketing site with no forms, a WAF is mostly giving you rate limiting and bot protection. If you're running a complex web app with user accounts, file uploads, and search boxes, the WAF gives you time — time to patch vulnerabilities while the WAF blocks known attack patterns.

But if your application is an internal API behind mutual TLS and strict authentication, a WAF adds limited value. The threat model matters.

Can AI Replace Traditional WAFs?

I also wondered whether AI would make this whole cat-and-mouse game obsolete. Modern WAFs from Cloudflare and AWS already use machine learning to establish baselines of normal traffic and flag anomalies. The idea is attractive: instead of writing regex for every possible SQL injection variant, the AI learns what legitimate requests look like and blocks deviations.

It helps, but it's not a replacement for understanding your own rules. AI WAFs still operate at Layer 7. They still inspect HTTP. They can still be bypassed by attackers who study the baseline and craft requests that look "normal" but carry malicious payloads. AI is a better pattern matcher, not a mind reader. It doesn't understand your business logic. It doesn't know that a user requesting every account ID in sequence is an enumeration attack if the intervals look regular. Context still matters, and context requires human judgment.

What I Do Instead

After that engagement, I stopped treating WAFs as a security guarantee and started treating them as virtual patching — a temporary filter that buys me time to fix the real problem in the code. Here's what that looks like in practice.

Layer Your Defenses

The WAF is the outer layer. Inside it, your application should still validate every input. Parameterized queries should be mandatory. Output encoding should be automatic. If an attacker bypasses the WAF, they should hit a wall of properly written code that gives them nothing.

PHP
// Bad: trusting the WAF to catch SQLi
$query = "SELECT * FROM users WHERE id = " . $_GET['id'];

// Good: the WAF is a bonus, not the plan
$stmt = $pdo->prepare("SELECT * FROM users WHERE id = ?");
$stmt->execute([$_GET['id']]);

Tune the Rules, Don't Install and Forget

Default rule sets catch low-effort attacks. They miss targeted ones. If you run a WAF, you need to review the logs, adjust false positives, and write custom rules for your specific application behavior. A WAF you don't control is just decoration.

Log Everything the WAF Sees

Every blocked request is a signal. Every request that almost got blocked is a louder signal. I analyze WAF logs the same way I analyze database logs — looking for patterns, probing behavior, and repeated encoding attempts that suggest someone is testing your filters.

A WAF you never review is a liability. If an attacker spends three days fuzzing your rules and you never look at the logs, you won't know they found a bypass until the database is already gone.

Production Checklist

WAF bypass techniques evolve, but these four rules keep me grounded:

  • Never treat a WAF as a replacement for secure code; use it as virtual patching while you fix vulnerabilities at the application layer
  • Tune your rules beyond the default configuration — generic signatures stop script kiddies, but custom signatures stop determined attackers
  • Review WAF logs regularly for probing behavior; repeated encoding attempts and mixed-case payloads are early warning signs
  • Remember that AI and ML improve detection but still operate at Layer 7; they augment your defenses, they don't replace your judgment

A WAF is a filter. A good filter catches the obvious stuff and slows down the clever stuff. But if your application behind it is brittle, the filter just determines how creative the attacker needs to be. I learned that the hard way — from both sides of the request.

Melalew Mengistu

Melalew Mengistu

Web engineer and web security specialist. Helps teams build and ship secure applications.