# XSS Filter Bypasses
> Getting a payload past a blocklist, signature WAF, or allowlist filter by exploiting parser disagreements, encoding, obfuscation, and syntax the filter didn't model — distinct from beating a *sanitizer*, which is [[Mutation XSS]].
## How it works
A filter and the browser rarely agree on what is "a script." Bypasses live in that gap: the WAF matches on a signature the browser doesn't require, or the browser executes syntax the WAF didn't normalize. Modern WAFs (Akamai, ModSecurity, Cloudflare) are signature/regex engines, so the reliable approach is to characterize the exact rule, then step just outside it.
## Techniques / payloads
- **Characterize, then step out.** Probe systematically (brutelogic's backwards/onwards mapping): send many variants, note what's blocked vs. passed, isolate the triggering token. Example from an Akamai bypass: every blocked `javascript:` payload had a JS keyword *adjacent to* `(` (`alert(`, `eval(`, `setTimeout(`); property-access syntax broke the adjacency: `javascript:top["setTimeout"](name)` → 200. Paired with `window.name` (survives cross-origin nav) it became one-click ATO.
- **No `<script>`:** event handlers on other tags — `<img/src/onerror=prompt(8)>`, `<svg onload=…>`, `<video/source onerror=…>`, `<body onload>`; auto-trigger via `autofocus onfocus`, `tabindex`+`#id`.
- **Tags blocked except custom ones:** `<xss id=x onfocus=alert(1) tabindex=1></xss>` + `#x` to auto-focus (PortSwigger "custom tags" lab).
- **Permitted-tag/attribute enumeration:** brute the allowlist with Burp Intruder to discover which tag+handler the filter forgot.
- **Parentheses-free invocation:** `onerror=alert\`1\`` (tagged template), `Error.prepareStackTrace` abuse, `throw onerror=eval,'=alert\x281\x29'`; whole corpora exist (RenwaX23 Without-Parentheses).
- **Encoding/obfuscation:** HTML-entity (`j` for `j` in `javascript:`), decimal vs hex entities to dodge `&#`-number signatures, URL/double-URL encoding, `data:;base64` script src, casing + NULL bytes + whitespace tricks, unicode/overlong UTF-8 and zero-width chars (note: WAFs increasingly block these — see the Akamai probe list).
- **HTTP Parameter Pollution:** ASP.NET concatenates duplicate params with commas (`HttpUtility.ParseQueryString`); split a payload across `p=a&p=b` so each half is benign and JS's comma operator reassembles it in a JS-string context — most WAFs don't model framework param-merging.
- **Signature mutation:** reorder/insert syntax the signature anchors on (extra attributes, comment interleaving `</scrip</script>t>`), or change *what the WAF reads* vs. what the app reads.
- **Denylist gaps in client-side filters.** NoScript's XSS filter regex-matched outgoing requests for dangerous tags and event handlers, but missed handlers that fire on a `div`; anything not listed passed (fixed by adding the events) ([[raw/srlabs.de/srlabs-three-ways-around-noscript-s-javascript-protections-15817|SRLabs]]).
- **Post-sanitization rewriting ("last writer wins").** If code edits the string *after* the sanitizer returns, the sanitizer's verdict is void. Chess.com's `xssFilter` replaced `&-diagramtype:` HTML comments with `__CHESS_DIAGRAM_PLACEHOLDER_n__`, ran DOMPurify, then restored the raw comments by regex. Supplying the same token inside a `data-` attribute made the restore write unsanitized markup into an attribute value, where a `"` in the comment closed it. Not a DOMPurify bug: any extract/sanitize/restore pipeline where restored text can land in a different context is exploitable ([[raw/xenops.ae/the-last-writer-wins-chess-com-account-takeover-via-postmessage-xss-15815|XENOPS]]). Related to the serialize/re-parse problem in [[Mutation XSS]].
- **Polyglots:** one payload that executes across double/single-quoted attr, unquoted attr, HTML comment, and script contexts (0xSobky ultimate polyglot); research now synthesizes them automatically via Monte-Carlo tree search.
## Notable cases
- **DOM-XSS + Akamai WAF + `window.name` smuggling + SDK abuse → one-click ATO** (the property-access bypass above), retrieving signed JWTs and live AWS STS creds.
- **Viewer → admin pentest chain** via an XSS that cleared a WAF (whiteshield), four steps, no auth bypass or phishing.
- **ASP.NET HPP** JS-injection past a strict WAF (Ethiack autonomous pentest).
- **NoScript review (SRLabs, for OTF)** — three high-severity issues, fixed in NoScript 13.6.18.901 / Tor Browser 15.0.13: event-handler denylist gap; on Chromium, NoScript's injected `<meta>` CSP (content script that freezes the DOM until the policy is in place) skipped SVG documents, so script in SVG ran unrestricted (see [[SVG and File Upload XSS]], [[Content Security Policy]]); TabGuard silently never worked because Firefox's `executeScript` couldn't parse method-shorthand syntax.
- **Chess.com placeholder-restore bypass** — see above; delivered via an unauthenticated `postMessage` handler ([[DOM-Based XSS]]).
## Defenses
- A WAF is compensating control, not the fix: do contextual output encoding and sanitize at the sink. Don't rely on blocklists.
- Normalize/canonicalize input (decode once, consistently) before any security decision; reject on the server using an allowlist of expected values, not a denylist of bad strings.
- Model framework quirks (duplicate-param handling) in input validation; prefer a single-value parse.
- [[Content Security Policy]] + Trusted Types so a payload that slips the filter still can't execute.
- Make the sanitizer the **last** transformation before the sink. If content must survive sanitization (comments, embeds), use sanitizer hooks/config rather than extract-and-restore string surgery.
- Defense layers need end-to-end tests in a real browser for every document type (HTML, XHTML, SVG); NoScript's SVG gap and dead TabGuard were invisible without them.
## Related
- [[Cross-Site Scripting]] · [[Reflected XSS]] · [[Mutation XSS]] · [[DOM-Based XSS]] · [[Content Security Policy]]
## Sources
- [[raw/acunetix.com/xss-filter-evasion-how-attackers-bypass-xss-filters-3099|XSS Filter Evasion]]
- [[raw/brutelogic.net/the-brute-art-of-bypass-unfiltered-edition-master-xss-filter-evasion-4999|The Brute Art of Bypass]]
- [[raw/blog.ethiack.com/bypassing-wafs-for-fun-and-js-injection-with-parameter-pollution-3097|Bypassing WAFs with Parameter Pollution]]
- [[raw/portswigger.net/bypassing-xss-filters-by-enumerating-permitted-tags-and-attributes-2539|Bypassing XSS filters by enumerating permitted tags/attributes]]
- [[raw/portswigger.net/bypassing-signature-based-xss-filters-modifying-html-4612|Bypassing Signature-Based XSS Filters]]
- [[raw/blog.ikaes.de/i-found-yet-another-way-to-invoke-javascript-functions-without-parenth-12225|Invoking JavaScript without parentheses]]
- [[raw/github.com/unleashing-an-ultimate-xss-polyglot-0xsobky-hackvault-wiki-345|Unleashing an Ultimate XSS Polyglot]]
- [[raw/infosecwriteups.com/chaining-a-dom-xss-sink-waf-bypass-cross-origin-smuggling-and-sdk-abus-10213|DOM XSS + WAF bypass + window.name → ATO]]
- [[raw/medium.com/reflected-xss-into-html-context-with-all-tags-blocked-except-custom-on-13882|Reflected XSS, all tags blocked except custom]]
- [[raw/srlabs.de/srlabs-three-ways-around-noscript-s-javascript-protections-15817|SRLabs: three ways around NoScript's JavaScript protections]]
- [[raw/xenops.ae/the-last-writer-wins-chess-com-account-takeover-via-postmessage-xss-15815|The Last Writer Wins: Chess.com account takeover via postMessage XSS]]