XSS Reference

XSS Attack Types

Stored XSS
Malicious script stored in database, affects all users who view the content.
Reflected XSS
Script in URL parameter, reflected in response without sanitization.
DOM-based XSS
Vulnerability in client-side JS that processes URL/DOM data unsafely.

Prevention Techniques

TechniqueExample
Output Encodinghtmlspecialchars($var, ENT_QUOTES)
CSP HeaderContent-Security-Policy: default-src 'self'
Safe APIselement.textContent = data // not innerHTML
Input ValidationWhitelist allowed characters/patterns
HttpOnly CookieSet-Cookie: session=...; HttpOnly; Secure