labs / xss

XSS Playground

Post a payload into a sandboxed guestbook and steal the victim's secret.

Cross-Site Scripting Beginner Server lab
leaderboard →
    Objective Post a guestbook message that runs JavaScript and exfiltrates window.LOOT to /api/labs/xss/steal?t=<loot>.

    The guestbook below shows every message without escaping it — and renders inside a victim's browser. Your message becomes part of their page. A classic starter: <img src=x onerror="...">. Read window.LOOT and send it to the steal endpoint (e.g. new Image().src='/api/labs/xss/steal?t='+window.LOOT).

    Victim's browser (sandboxed)

    How the fix works & why this is safe

    The fix is output encoding: render user text as text, so < becomes &lt; and never starts a tag. A Content-Security-Policy without 'unsafe-inline' is strong defense-in-depth. This lab is safe because the payload runs in a sandbox="allow-scripts" iframe with no same-origin access — it can't touch the real page, your cookies, or other users.

    $ patch ./xss

    You broke it — now fix it. How do you render the message without enabling XSS?

    comment.innerHTML = userMessage;