Security Blog

XSS Filter and WAF Bypass Techniques: The Payloads Pentesters Actually Use

Published 05 Oct 2026

Most production web applications today have some form of XSS defense in place — a Web Application Firewall (WAF), a server-side input filter, or both. Finding an XSS sink is only half the job; the other half, in any real-world assessment or bug bounty, is getting a working payload past whatever filtering sits in front of it. This post walks through the actual bypass logic pentesters rely on, categorized by what the filter is trying to block and why each bypass works.

Step 1: Work Out What the Filter Actually Blocks

Never guess blindly. Send a series of small, isolated probes and observe exactly what gets stripped, encoded, rejected, or passed through untouched:

  • Does it block the literal string <script> but allow other tags?
  • Does it strip the word "script" case-sensitively (so <ScRiPt> survives)?
  • Does it block on event handler attributes, or only specific ones like onerror?
  • Does it block javascript: as a URI scheme, or only in specific attributes?
  • Is the filter applied once, or recursively (does it catch a payload that only becomes dangerous after the filter's own transformation)?

Every bypass below exists because a filter answered one of these questions incorrectly.

Case and Encoding Variation

Many naive filters do a case-sensitive string match on dangerous keywords. Simply varying case defeats them:

<ScRiPt>alert(1)</sCriPt>
<IMG SRC=x onERROR=alert(1)>

HTML entity and URL encoding tricks also catch filters that only check the raw, un-decoded string:

<img src=x onerror=&#97;lert(1)>
%3Cscript%3Ealert(1)%3C%2Fscript%3E
<a href="j&#97vascript:alert(1)">click</a>

The lesson behind all of these: a filter that decodes input once and checks it is vulnerable to anything the browser will decode again (double encoding) or decode differently (mixed entity/literal characters) than the filter expects.

Breaking Out of the Expected Context

If a filter blocks <script> tags specifically, you do not need a <script> tag at all — any HTML element with a JavaScript-executing attribute works just as well:

<svg onload=alert(1)>
<img src=x onerror=alert(1)>
<body onpageshow=alert(1)>
<details open ontoggle=alert(1)>
<iframe src="javascript:alert(1)">

<svg onload=> and <details ontoggle=> in particular are popular precisely because they are easy to miss in a blocklist that was written with only <script> and <img> in mind.

Attribute-Context Breakouts

When your input lands inside an existing HTML attribute (for example, a search term reflected into a hidden input's value), you do not need a new tag — you need to close the attribute and open a new one:

" autofocus onfocus=alert(1) x="
" onmouseover=alert(1) "

autofocus combined with an onfocus handler is a favorite here because it fires automatically on page load with zero user interaction required, unlike onmouseover or onclick which need the victim to actually move their mouse or click.

Polyglot Payloads

A polyglot is a single payload engineered to execute correctly across several different injection contexts at once — useful when you are not 100% sure which context your input lands in, or you are fuzzing many inputs quickly. A commonly used example:

jaVasCript:/*-/*`/*\`/*'/*"/**/(/* */onerror=alert(1) )//%0D%0A%0d%0a//</stYle/</titLe/</teXtarEa/</scRipt/--!>\x3csVg/<sVg/oNloAd=alert(1)//>\x3e

It looks intimidating, but it is just several bypass techniques stacked together — case variation, comment-based obfuscation, and a closing tag chain — so that whichever context it lands in, something in the chain survives and fires.

Why These Bypasses Work Against WAFs Specifically

Web Application Firewalls generally rely on signature/pattern matching, not a real HTML/JS parser. That mismatch is the entire reason bypasses exist:

  • Normalization gaps — the WAF checks the raw request, but the browser normalizes encoding, whitespace, and case differently than the WAF's regex expects.
  • Incomplete tag/attribute lists — blocklists age quickly; new HTML5 elements and attributes (like ontoggle on <details>) are routinely missing.
  • Single-pass decoding — a WAF that decodes a payload once and checks it misses anything that only becomes dangerous after a second decode step the browser will still perform.

In a real, authorized assessment, the correct workflow is: identify the sink and context first, fingerprint the filter's exact blocklist with small probes, then pick (or build) the narrowest bypass that defeats that specific gap — not throw a giant polyglot at everything and hope.

Learn This Hands-On, Not Just in Theory

Reading about a vulnerability class is step one. Reproducing it yourself, in a safe lab environment, under guidance, is what actually turns it into a skill employers and bug bounty programs pay for. Rudra Tech Services runs hands-on ethical hacking and VAPT training out of Aurangabad (Chhatrapati Sambhajinagar), with real lab exercises covering exactly the vulnerability classes covered in this post.

If you want to practice this safely and legally, check out our Ethical Hacking course or try our recon-based CTF platform to test these techniques in a built-for-practice environment.

Explore RudraSec's Courses

Real hands-on training, with transparent pricing and no hidden placement claims.