Skip to main content
XsiSec.com
HomeReposBlogProjectsPortfolio
© 2026 XsiSec.com
Security rules |security.txt
Updated 2026-08-15 · v1.0.0+2026-08-14.82f92cb · 82f92cb
← Back to overview
Security article

Learn about Sinks

Learn about Sinks: This article demonstrates how different DOM sinks (Document, Location, and Execution) can introduce DOM-based XSS vulnerabilities. • Knowledge • sinks

2022-11-301 tag
Tags

🎯 Objective

This article demonstrates how different DOM sinks (Document, Location, and Execution) can introduce DOM-based XSS vulnerabilities.


🧭 Source Code Example

The page has only one HTML element (p1) which is dynamically updated by the script block.
No external libraries are included.


🔎 1. Document Sink

The Document Sink inserts attacker-controlled data into the DOM.

  • The value of the name parameter is written to the DOM via innerHTML.
  • This allows injection of arbitrary HTML or event handlers.

Example attack:

text
https://baddomain.xyz/tests/sinks.html?name=<img src=x onerror=alert(1)>

Other Document Sinks

  • innerHTML
  • outerHTML
  • document.write() / document.writeln()

🔎 2. Location Sink

The Location Sink uses attacker input to set the document location.

This allows redirection or execution of JavaScript via the pseudo-protocol:

text
https://baddomain.xyz/tests/sinks.html?redir=javascript:alert(1)

Notes

  • Modern browsers may block javascript: URLs or execute them in a blank context.
  • Historically, attackers used data: URIs as a bypass.

🔎 3. Execution Sink

The Execution Sink passes attacker input directly to eval.

Payload:

text
https://baddomain.xyz/tests/sinks.html?index=alert(1)
  • The attacker-supplied index parameter is injected directly into eval.
  • This results in arbitrary JavaScript execution.

Other Execution Sinks

  • eval()
  • setTimeout(string)
  • setInterval(string)
  • new Function()
  • Template literals

✅ Summary

  • Document Sinks → Dangerous DOM modifications (innerHTML, document.write)
  • Location Sinks → Redirection and possible javascript: execution
  • Execution Sinks → Direct code execution via eval, setTimeout, etc.

⚠️ These are the three main categories of sinks where DOM-based XSS vulnerabilities occur.

Navigate

In this post

  1. 01🎯 Objective
  2. 02🧭 Source Code Example
  3. 03🔎 1. Document Sink
  4. 04Other Document Sinks
  5. 05🔎 2. Location Sink
  6. 06Notes
  7. 07🔎 3. Execution Sink
  8. 08Other Execution Sinks
  9. 09✅ Summary
Search
Explore

Popular tags

Browse all 30 tags

Comments

0 comments

No comments yet — be the first to comment.