Sovra Recon·Glossary · XSS

XSS (Cross-Site Scripting) Vulnerability: Definition, Types, and Protection

By Solan Barlet, co-founder of Sovra Recon
Updated October 29, 2026

In short

An XSS (cross-site scripting) vulnerability allows an attacker to inject JavaScript code into a web page viewed by other users. This code runs in their browser with their permissions: it can steal a session, modify the page, or act on their behalf. It is part of the “Injection” category of the OWASP Top 10.

The Three Types of XSS

TypeHow It WorksExample
StoredThe code is stored by the application and served to everyone who views the pageA comment or profile name containing a script
ThoughtsThe code is embedded in a malicious link and is immediately returned by the serverA search parameter re-displayed without escaping
DOMThe code is inserted via the page’s own JavaScript, on the browser side.A URL fragment injected into the page via innerHTML

What an attacker can do

  • Stealing session tokens or acting on behalf of the victim using their session.
  • Displaying a fake login form on the real website.
  • Performing actions on behalf of an administrator who visits the compromised page.

How to Protect Against It

  • Escape all data based on the display context (HTML, attributes, JavaScript, URLs); modern frameworks do this by default, unless their protections are bypassed.
  • Avoid using raw HTML insertions (innerHTML, dangerouslySetInnerHTML) with user data, or sanitize them using a dedicated library.
  • Implement a Content Security Policy (CSP) that restricts authorized scripts.
  • Mark session cookies as "HttpOnly" so that a script cannot read them.

Frequently asked questions

Is an XSS vulnerability serious?

Yes, when it is stored or affects administrators: it can lead to account takeover. Its severity depends on what the victim can do within the application.

Sources

Find out where an attacker would get in.

Our AI agents actually attack your scope, fully automated, and hand you the proof of every vulnerability.