Skip to content
Finic
Fraud and risk

What is XSS (cross-site scripting)?

Cross-site scripting (XSS) is a web attack that injects untrusted script into a page, so it runs in other users' browsers and can steal sessions or act as them.

Also called: cross-site scripting

How it works

A site is open to XSS when it puts user input into a page without the right encoding. The browser then treats that input as code. In stored XSS, the script is saved, for example in a comment or profile field, and runs for every visitor. In reflected XSS, it comes from a crafted link. In DOM-based XSS, the page's own JavaScript writes the input into the page in an unsafe way.

The script runs with the same rights as the real site. It can read data on the page, send requests as the user and change what the user sees.

Why it matters for fraud and trust

XSS is a direct route to account takeover. A script can steal session tokens, change the account email, or show a fake login form on a real domain, which is more convincing than normal phishing. On financial and crypto sites, it can change payment details or a destination address just before the user confirms.

Warning signs

  • Many sessions that change contact details or payout settings soon after they view the same page.
  • Reports of strange pop-ups or login prompts on your own domain.
  • Content Security Policy violation reports that show scripts from unknown sources.

How teams defend against it

Encode all output for the context where it appears, such as HTML, attributes or JavaScript, and use frameworks that do this by default. Clean any rich text with a well-tested sanitizer. A strict Content Security Policy limits which scripts can run, and HttpOnly cookies stop scripts from reading session cookies.

Defense in depth also helps after a script runs. Step-up authentication on sensitive changes and device checks on sessions make it harder for an attacker to use a stolen session.

← All glossary terms

Ship fraud, bot and KYB checks in minutes.

Start with $5 of free credit, or copy a prompt and let your coding agent set Finic up.

Sign up See pricing