What is XSS (cross-site scripting)?
Cross-site scripting (XSS) is a vulnerability where a website puts untrusted text into a page without escaping it, so the browser runs it as code. An attacker can then act as the visitor: read their session, change what they see or send requests in their name.
How it works
The classic case is a search page that prints the query back. If the page inserts the text as HTML, a link with a script in the query runs that script on your domain, with access to the visitor's cookies, storage and logged-in session. Stored XSS is worse: the script is saved (in a comment or profile) and runs for everyone who views it. DOM-based XSS happens fully in the browser when your own JavaScript writes URL or user data into the page.
// Vulnerable: user input becomes HTML
const q = new URLSearchParams(location.search).get("q");
results.innerHTML = "You searched for " + q;
// Safe: input stays text
results.textContent = "You searched for " + q;How to tell if your site is affected
- Your code assigns user, URL or database values to innerHTML, outerHTML, document.write or dangerouslySetInnerHTML.
- A search box, comment, name or profile field shows the value back on a page and the markup characters < and > appear unchanged in the page source.
- You render Markdown or rich text from users without a sanitizer.
- The site has no Content-Security-Policy, so nothing limits what an injected script may do.
How to fix it
Treat all text as text: use textContent, framework templating and JSX braces, which escape output by default.
Where you must render HTML (comments, CMS content), pass it through a maintained sanitizer such as DOMPurify and keep an allow-list of tags.
In Next.js and React avoid dangerouslySetInnerHTML with user data, and never build href or src values from raw input. Allow only http, https and mailto links.
Add a Content-Security-Policy without unsafe-inline so an injected script is blocked even if one slips through.
Mark session cookies HttpOnly so a script cannot read them, and retest the affected page.
How ScanAnt checks for it
The free quick scan reads your public JavaScript for patterns that write URL data into HTML (DOM-based XSS risks) and reports a missing or weak Content-Security-Policy. The deep scan, for verified owners who tick the deep option, adds harmless markers in GET parameters to see whether a value is echoed back unescaped. ScanAnt does not submit your forms with test payloads (level-3 rate-limit probes send only a tagged test body), so stored XSS in comments or profiles is not tested.
Questions
What does XSS stand for?
Cross-site scripting. The abbreviation is XSS rather than CSS to avoid confusion with cascading style sheets.
What can an attacker do with XSS?
Anything the visitor can do on your site: read data shown on the page, steal tokens kept in JavaScript-readable storage, submit actions as the user, show fake login forms or redirect to a malicious site.
Does React protect me from XSS?
Mostly. React escapes values in JSX by default. The gaps are dangerouslySetInnerHTML, links built from user input, and libraries that write to the DOM directly.
Is HTTPS enough to prevent XSS?
No. HTTPS protects data in transit. XSS is a flaw in how the page is built, so it works equally well over HTTPS.
What is the difference between reflected, stored and DOM XSS?
Reflected XSS bounces from the request into the response. Stored XSS is saved on the server and served to others. DOM XSS never reaches the server: client-side code inserts the data unsafely.
Related terms
Content Security Policy (CSP)
A header that limits which scripts and resources a page may load.
Read →CSRF
Another site makes a logged-in user's browser act on your site.
Read →SQL injection
User input rewrites your database query.
Read →OWASP Top 10
The ranked list of the most critical web application risks.
Read →Check your own site
Known CVEs, injection probes, open redirects and exposed files, in plain language.
Open the matching check →
See if your site is affected
Free for any public site, no signup. Need the verified or deep scan? Choose the level on the scan page.
Choose a scan level →