---
name: xss-hunter
description: Complete XSS testing methodology reflected, stored, DOM-based, blind, and mutation XSS, CSP bypass, DOM clobbering, filter/WAF evasion, and impact escalation. Trigger when the user asks to test for XSS or cross-site scripting (reflected, stored, DOM-based, blind, mutation), wants to bypass XSS filters/WAF rules/CSP, identifies a reflection point and needs the right payload, pastes HTML/JS that reflects user input, asks if they can steal cookies or test inputs for injection, needs to demonstrate XSS impact, or is writing a pentest finding needing evidence or remediation.
license: MIT
metadata:
version: "0.0.1"
author: Rifteo
tags: ["pentest", "xss", "web", "csp-bypass", "dom-clobbering", "waf-evasion", "bug-bounty"]
---
# XSS Attack Methodology
XSS occurs when user-controlled input is rendered in a browser without proper sanitization or encoding, allowing arbitrary JavaScript execution in the victim's context.
**Before testing anything — understand the injection context:**
The payload you need depends entirely on *where* your input lands in the page source. Always view source or open DevTools after injecting a canary string (`xsstest123`) to locate where it appears.
```
HTML body:
xsstest123
→
User-Agent:
X-Forwarded-For:
X-Original-URL: /">
```
### 1.4 JSON / API Responses rendered in UI
- API response fields that get injected into the DOM via `innerHTML`
- Username, display name, bio, address fields stored in API and rendered later
### 1.5 File Uploads
- Upload an SVG with embedded JS: ``
- Upload HTML file if allowed
- Filename itself: `">.png`
### 1.6 DOM Sources (for DOM XSS)
```javascript
// Sources — user-controlled entry points into JS
location.href / location.search / location.hash
document.referrer
document.URL
window.name
postMessage data
localStorage / sessionStorage (if populated from URL)
```
---
## Attack 1 — Reflected XSS
**What:** Input is reflected in the HTTP response immediately without being stored.
**Step 1 — Inject a canary to locate reflection:**
```
GET /search?q=xsstest123
```
View source → find `xsstest123` → note the surrounding context.
**Step 2 — Choose payload for context:**
```html