Table of Contents
Reflected cross-site scripting (XSS) occurs when a site puts untrusted data from a request into its response and the browser interprets that data as executable code. The affected page can look as though it came from the legitimate site because it did. The unsafe request data is returned in that response.

What a visitor might notice
An unexpected sign-in prompt, a page that changes after opening a link, or account activity you did not initiate can warrant investigation. Those signs have many possible causes. Close the page, open the service from a trusted bookmark or by typing its address, and check account activity there. Contact the service through its official support channel if you see changes you did not make.
How site owners can prevent reflected XSS
- Use template auto-escaping for plain text and apply output encoding appropriate to the destination context, such as HTML text or an HTML attribute.
- Keep untrusted values out of inline scripts and event handlers. Validate URL schemes before using user-controlled values in links.
- Use a maintained HTML sanitizer when a feature intentionally accepts rich text. In client code, use
textContentto display plain text. - Apply Content Security Policy as an additional layer, alongside safe rendering. Add a regression check that request values render as literal text wherever the application displays them.
OWASP’s XSS prevention guide explains which protections fit each rendering context.
Reader Comments 0
Sign in with email or Google to join the discussion.