🔒 Academy Room 4 · Medium

Cross-Site Scripting (XSS)

Learn XSS the way it's actually found — hands-on, against a live target. Work through reflected and stored Cross-Site Scripting, identify the injection context, and get past basic input filters.

⚡ Start the XSS Lab How it works →
// Overview

What Is Cross-Site Scripting?

Cross-Site Scripting is a vulnerability where an application takes untrusted input and places it into a page without properly encoding it for the context it lands in. The browser can no longer tell the difference between the site's own markup and the attacker's, so the injected content executes with the full privileges of that origin.

The distinction that matters most in practice is where the payload lives. Reflected XSS is echoed straight back in the response to a crafted request. Stored XSS is saved by the application and served to every user who later views the affected page — which is what turns a single injection into a persistent threat against the whole user base.

// Why It Matters

Real-World Impact

Session & Account Takeover

Act as the victim

Script running in a victim's origin can reach their session state, issue authenticated requests on their behalf, and drive the application as if it were the user — without ever needing their password.

Persistent Reach

One payload, many victims

Stored XSS is served to everyone who visits the affected page. A single successful injection into shared content can reach every user who loads it, including administrators with far more privilege than the attacker.

// OWASP

Where XSS Sits in the OWASP Top 10

Since the 2021 revision, Cross-Site Scripting is folded into A03:2021 – Injection in the OWASP Top 10, alongside SQL injection. The reasoning is that both share a root cause: untrusted input crossing into an interpreter — a SQL engine in one case, the browser's HTML and JavaScript parsers in the other. The impact classes below drive its severity.

Impact What the attacker gains Severity
Session hijacking Act within the victim's authenticated session High
Stored payload delivery Serve the injection to every viewer of a page High
Credential harvesting Render convincing fake prompts in a trusted origin High
UI manipulation Rewrite page content to mislead the user Medium
// The Workflow

How PhantomRed Fits Into an XSS Assessment

Cross-Site Scripting sits in an interesting middle ground for automation. A scanner can flag places where input is reflected into a response, but confirming a working XSS means understanding the exact context the payload lands in — HTML body, an attribute, a JavaScript block — because each one needs a different approach, and each one is encoded differently by any filter in the way.

Room 4 is deliberately hands-on for that reason. You find the reflection yourself, determine the context, get execution, then repeat the exercise for the stored case and work past a simple keyword filter:

Injection is a family, not a single bug. The SQL injection lab covers the other half of A03:2021 — same root cause, different interpreter.

// What You'll Learn

Learning Objectives

Concepts

  • Why output encoding depends on the surrounding context
  • The difference between reflected and stored XSS
  • How XSS maps onto the OWASP Top 10

Hands-On Skills

  • Finding a parameter that reflects input unsanitized
  • Determining which context a payload lands in
  • Getting past a naive keyword blacklist
// FAQ

Frequently Asked Questions

What is Cross-Site Scripting (XSS)?
XSS is a vulnerability where an application inserts untrusted input into a page without encoding it for the context it lands in, allowing attacker-supplied content to be interpreted as markup or script by the victim's browser. Because it executes within the site's own origin, it inherits that origin's trust and access.
Is XSS in the OWASP Top 10?
Yes. Since the 2021 revision, XSS is grouped under A03:2021 — Injection rather than holding a separate slot. OWASP consolidated it because XSS and SQL injection share the same root cause: untrusted input reaching an interpreter without proper separation between code and data.
What is the difference between reflected and stored XSS?
Reflected XSS is echoed back in the immediate response to a crafted request, so it requires getting a victim to trigger that specific request. Stored XSS is saved by the application and rendered to anyone who later views the affected page, making it persistent and typically higher impact because it needs no per-victim delivery.
What can an attacker do with XSS?
Script executing in the victim's origin can read accessible session state, issue authenticated requests as that user, rewrite page content to mislead them, and harvest credentials through convincing in-page prompts. Against an administrator, that can escalate well beyond the original account.
Can an automated scanner detect XSS?
Scanners are good at flagging where input is reflected into a response, but confirming a working XSS usually requires human judgment about the injection context and any filtering in place. PhantomRed maps the input surface; the human determines the context and proves execution. Room 4 is built around that division of labor.
How do you prevent XSS?
Encode output for the specific context it enters - HTML body, attribute, URL, or JavaScript each need different handling. Prefer frameworks that escape by default, validate input on the server, and add a Content Security Policy as defense in depth. Keyword blacklists are not a reliable control and are routinely bypassed.
// Related

Related Rooms & Guides

// Get Started

Practice XSS Against a Live Target

The XSS lab is live and free to play. Find the reflection, identify the context, confirm execution, then move on to the stored case and the filter bypass.

⚡ Open the XSS Lab Start a Free Scan →