Back to Blog
Application Security

XSS Detection Guide: Reflected, Stored, and DOM-Based Cross-Site Scripting

5 min read
XSSCross-Site ScriptingCSP

What is Cross-Site Scripting (XSS)?

Cross-Site Scripting (XSS) allows attackers to inject malicious scripts into web pages viewed by other users. These scripts can steal session cookies, redirect users, or perform actions on their behalf.

Types of XSS

Reflected XSS

Script is reflected from the server in the response.
https://example.com/search?q=<script>alert('XSS')</script>

Stored XSS

Script is permanently stored on the server (in database, comments, etc.).

DOM-Based XSS

Script executes through client-side JavaScript manipulation.
document.innerHTML = location.hash.substr(1);

Prevention

Output Encoding

Encode output based on context:
  • HTML context: HTML entity encoding
  • JavaScript context: JavaScript escaping
  • URL context: URL encoding

Content Security Policy

Content-Security-Policy: default-src 'self'; script-src 'self'

Input Validation

Validate and sanitize all user input.

Testing with SuperClue

SuperClue tests for reflected and DOM-based XSS with context-aware and polyglot payloads, and checks your Content Security Policy header.

Ready to Test Your Applications?

Start your comprehensive security scan with SuperClue's security modules.

Request access