Lion Cipher Lab

Understand cross-site scripting (XSS) — and how to stop it

Why it matters

Cross-site scripting is one of the most common and consequential web vulnerabilities: it lets an attacker run their JavaScript in another user's browser, in the context of a site the victim trusts — which can steal session cookies, capture keystrokes, or act as the user. It sits in the OWASP Top 10 under Injection for good reason. But XSS is also very preventable once you understand its single root cause (untrusted data ending up in a page where the browser treats it as code) and the fixes that address that cause (encoding output, a good Content-Security-Policy, and modern frameworks that…

What you'll learn

Steps in this lab

  1. What XSS is, in one idea
  2. The three kinds, briefly
  3. See it once, safely, on your own app
  4. The primary fix: encode output for its context
  5. Let your framework do the escaping — and don't defeat it
  6. Add Content-Security-Policy as a safety net
  7. Why defenders should know the attack

Open the full interactive lab →