Skip to main content
Cross-Site Scripting (XSS) allows attackers to inject and execute arbitrary JavaScript in a victim’s browser. Understanding the context where your input is reflected is key to crafting effective payloads.

Methodology

1

Find Reflected Values

Check if any value you control (parameters, path, headers, cookies) is being reflected in the HTML or used by JS code.
2

Identify the Context

Determine where the input is reflected: raw HTML, inside an HTML tag attribute, inside JavaScript code, or inside a JavaScript function call.
3

Craft the Payload

Depending on the context, prepare a payload that breaks out and executes JS. Test which symbols are available.
4

Test for DOM XSS

Check if your controlled input is used by any JavaScript sink like location.href, document.write, or innerHTML.

Types of XSS

Reflected XSS

The payload is immediately reflected in the HTTP response. The server echoes user input directly into the page.

Stored XSS

The payload is stored server-side and reflected to all users who view the page.

DOM XSS

The vulnerability exists in client-side code that processes attacker-controlled data (e.g., location.hash).

Injecting Inside Raw HTML

When your input is reflected in the raw HTML page, use HTML tags to execute JS:
If tags are blacklisted, brute-force which tags are allowed. Use PortSwigger’s XSS cheat sheet to copy all tags and test via Burp Intruder.

Blacklist Bypasses

Injecting Inside HTML Tag Attributes

If your input is reflected inside an attribute value:

Bypass Inside Event Using Encoding

Special Protocols

Injecting Inside JavaScript Code

When your input lands inside <script> tags or a .js file:

Template Literals

JS-in-JS String Break Pattern

JavaScript Without Parentheses

Blacklist Bypass Techniques

DOM XSS Sinks

Common dangerous sinks that lead to DOM XSS:

WAF Bypass with Encoding

Combining URLencode + HTMLencode in any order to encode the full payload won’t work, but you can mix them inside the payload.

XSS in Hidden Inputs & Meta Tags

Upgrading Self-XSS

  • Cookie XSS: If you can set cookies on a subdomain, use cookie tossing to trigger XSS on the main domain.
  • Sending to Admin: If a user can share a profile with an admin, store the XSS in the profile.
  • Session Mirroring: Exploit session mirroring features to make an admin trigger your self-XSS.

Universal XSS

Universal XSS can be found anywhere — they don’t depend solely on a single web application. Examples include:
  • Server-Side XSS in dynamic PDFs
  • XSS in Electron desktop apps (can lead to RCE)
  • XSS through WASM linear-memory template overwrite

Tools