---
title: "Cross-Site Scripting (XSS)"
description: "Reflected/stored/DOM XSS discovery, payloads, filter bypass and blind-XSS callbacks."
category: web
tags: [web, xss, injection]
tools: [Burp Suite]
difficulty: intermediate
updated: "2026-08-09"
source: "vault:Web/Cross-Site Scripting (XSS) - HTB Cheat Sheet.md"
---
# Cross-Site Scripting (XSS)
## Summary
Cross-site scripting occurs when attacker-controlled data reaches a browser parsing context without the correct validation, encoding, or sanitisation. The reliable workflow is to locate every input, insert a unique inert marker, identify where and how it is rendered, and only then select a context-matched execution proof. Start with `console.log()` or a visible DOM marker, escalate only as far as the lab objective requires, and capture the exact request, response, execution context, and affected user role.
> **Danger — Authorization Boundary**
> 1. Use these procedures only in Hack The Box, intentionally vulnerable training applications, or systems you own and are explicitly authorised to test.
> 2. Blind-XSS callbacks may collect page data or cookies. Use unique lab-only infrastructure and delete captured data when the exercise ends.
> 3. The page-control demonstration below is temporary and browser-side. Do not use XSS to damage content, persist changes, or disrupt real users.
> 4. XSS executes in a browser. It does not inherently provide an operating-system reverse shell.
---
## Conceptual Information
### XSS Types
| Type | Data path | When execution occurs | First place to inspect |
|---|---|---|---|
| **Reflected XSS** | Current request → immediate response | A crafted request or link is rendered | Query parameters, POST fields, headers, error messages |
| **Stored XSS** | Input → database/log/cache → later response | Another page or user renders the stored value | Comments, profiles, tickets, filenames, audit logs |
| **DOM-based XSS** | Browser-controlled source → unsafe JavaScript sink | Client-side code processes the source | URL fragment, query string, `postMessage`, storage, DOM |
| **Blind XSS** | Stored input → unseen privileged interface | A support agent, administrator, or background browser renders it | Support forms, admin tables, logs, exports, moderation queues |
> **Info — Source, Transform and Sink**
> 1. **Source**: Where attacker-controlled data enters, such as `location.search`, `location.hash`, `document.referrer`, form fields, headers, or stored records.
> 2. **Transform**: Decoding, filtering, template rendering, concatenation, or sanitisation applied before use.
> 3. **Sink**: Where the value is interpreted, such as `innerHTML`, `outerHTML`, `document.write`, `insertAdjacentHTML`, `eval`, string-based `setTimeout`, or a dynamic script URL.
> 4. A payload is useful only when it matches the parser and sink that ultimately consume the data.
### Fast Attack Flow
1. **Map inputs** across URL parameters, paths, form fields, JSON, headers, cookies, file metadata, and WebSocket messages.
2. **Insert a unique marker**, such as `xss7q9`, without punctuation.
3. **Find every reflection or stored rendering** in the raw response and the live DOM.
4. **Identify the context** and the characters that are encoded, removed, normalised, or blocked.
5. **Prove execution harmlessly** with `console.log('xss7q9')` or a lab alert.
6. **Validate the affected role and persistence**, especially for stored or blind XSS.
7. **Demonstrate only the minimum required impact** for the objective.
8. **Record evidence and remediation** before removing the test value.
---
## Tools Overview
> **Info — Burp Suite**
> 1. Intercepts browser requests and exposes every parameter, header, and body value.
> 2. Repeater supports controlled, one-change-at-a-time payload testing.
> 3. DOM Invader helps trace browser sources and sinks in client-side code.
> **Info — Browser Developer Tools**
> 1. Elements shows the parsed DOM, which can differ from raw response HTML.
> 2. Sources and breakpoints reveal client-side transforms and dangerous sinks.
> 3. Console provides a low-impact execution proof and displays CSP or syntax errors.
> **Info — XSS Hunter Express**
> 1. Purpose-built blind-XSS collector with page context, screenshots, and callback metadata.
> 2. Best when an unseen administrator or support panel renders stored input.
> **Info — ezXSS**
> 1. Self-hosted blind-XSS platform with payload, notification, and report controls.
> 2. Useful when you want strict lab allowlisting and flexible report handling.
> **Info — Interactsh**
> 1. Lightweight out-of-band interaction service for DNS, HTTP, SMTP, and other callbacks.
> 2. Confirms that an injected resource was resolved or requested, but does not provide a full browser screenshot or DOM report.
---
## Commands and Implementation
### 1. Establish the Reflection Context
Send a unique marker through each input and search both the response and the live DOM.
```http
GET /search?q=xss7q9 HTTP/1.1
Host: target.htb
User-Agent: Mozilla/5.0
Accept: text/html
Connection: close
```
> **Info — Request Breakdown**
> 1. `xss7q9`: A unique inert marker that is easy to search and unlikely to collide with page content.
> 2. Raw response: Reveals server-side placement and encoding.
> 3. Live DOM: Reveals browser repair, client-side rendering, and DOM-only reflections.
> 4. Repeat the test in headers such as `User-Agent`, `Referer`, `X-Forwarded-For`, and application-specific metadata when the target contains an admin log viewer.
### 2. Context Identification Matrix
| Observed rendering | Context | Characters to test individually | Harmless execution proof |
|---|---|---|---|
| `