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 withwindow.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 viaautofocus onfocus,tabindex+#id. - Tags blocked except custom ones:
<xss id=x onfocus=alert(1) tabindex=1></xss>+#xto 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.prepareStackTraceabuse,throw onerror=eval,‘=alert\x281\x29’`; whole corpora exist (RenwaX23 Without-Parentheses). - Encoding/obfuscation: HTML-entity (
jforjinjavascript:), decimal vs hex entities to dodge&#-number signatures, URL/double-URL encoding,data:;base64script 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 acrossp=a&p=bso 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) (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
xssFilterreplaced&-diagramtype:HTML comments with__CHESS_DIAGRAM_PLACEHOLDER_n__, ran DOMPurify, then restored the raw comments by regex. Supplying the same token inside adata-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 (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.namesmuggling + 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’sexecuteScriptcouldn’t parse method-shorthand syntax. - Chess.com placeholder-restore bypass — see above; delivered via an unauthenticated
postMessagehandler (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
Sources
- XSS Filter Evasion · original
- The Brute Art of Bypass · original
- Bypassing WAFs with Parameter Pollution · original
- Bypassing XSS filters by enumerating permitted tags/attributes · original
- Bypassing Signature-Based XSS Filters · original
- Invoking JavaScript without parentheses · original
- Unleashing an Ultimate XSS Polyglot · original
- DOM XSS + WAF bypass + window.name → ATO · original
- Reflected XSS, all tags blocked except custom · original
- SRLabs: three ways around NoScript's JavaScript protections · original
- The Last Writer Wins: Chess.com account takeover via postMessage XSS · original