XSS: Cross-Site Scripting

Difficulty: Intermediate

Question

What is XSS and how do you prevent it?

Answer

XSS occurs when scripts are injected into web content. Prevent by sanitizing input (DOMPurify), escaping output (standard in React), and using Content Security Policy (CSP) headers.

Concepts covered

XSS, Reflected, Stored, DOM-based, Sanitization