What It Actually Means
Someone submits content containing instructions rather than text: a comment, a profile field, a support ticket, a form. Your site stores it and later displays it to another user. Their browser cannot tell the difference between code you intended and code somebody else supplied, so it runs both.
The uncomfortable part is who it happens to. SQL injection attacks your database. XSS attacks your customers, using your site as the delivery mechanism, which makes it both a security problem and a reputational one.
What An Attacker Gets
Code running in a logged-in user’s browser can generally do whatever that user can do.
It can read what is on the page, including anything the user is permitted to see. It can take the session and act as them. It can modify what the page displays, which is how convincing fake login prompts appear on genuine sites at the genuine address. It can send data elsewhere while everything looks normal.
The variant that matters most is stored XSS, where the payload is saved and served to everyone who views the page. One submission can reach every user and every administrator who opens it, which is how a single support ticket ends up compromising an admin account.
The Fix
Escaping on output. When the system displays anything that came from a user, it encodes it so the browser treats it as text to show rather than instructions to run.
The important detail is on output, not on input. The same stored value is safe in one context and dangerous in another, so the encoding depends on where it is being placed: inside HTML, inside an attribute, inside JavaScript, inside a URL. Sanitising once on the way in and then trusting it everywhere afterwards is the mistake that produces most surviving cases.
Current frameworks escape by default, which has made XSS much rarer than it was. It reappears where a developer deliberately bypasses that default to render stored HTML, usually to support a rich text editor. That is the specific place worth asking about, because it is where the exception lives.
What To Ask
- Where do we render user-supplied HTML? Rich text fields, email templates and imported content are the usual answers, and each needs proper sanitising.
- Do we have a Content Security Policy? It limits what injected code can do even if something slips through, and it is a real second line of defence rather than a box to tick.
- Are session cookies marked HttpOnly? That prevents scripts reading them and is a one-line setting frequently left off.
- Has anything tested for this? Automated tools find the common patterns cheaply.
Why It Persists
Every part of this has been well understood for many years, and it remains among the most frequently found flaws in web applications.
The reason is that the dangerous path exists for a legitimate reason. Products need to display formatted text that users wrote, and doing that safely requires care that doing it unsafely does not. The feature request is reasonable, the shortcut works perfectly in testing, and the gap only becomes visible when somebody goes looking.
That is worth knowing when a supplier proposes a rich content feature. Ask how the content will be sanitised before it goes live, rather than refusing the feature.
More terms are in the glossary.