Clear, practical technology insights BSOD Code Lookup · Windows Error Code Lookup · Wi-Fi Troubleshooting · PC Troubleshooting Checklist

What is reflected XSS? Signs, risks, and prevention

Understand how reflected cross-site scripting affects a page, what to do after a suspicious link, and how site owners can prevent it.

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 is Reflected XSS? How to know if you are attacked by Reflected XSS Picture 1
Reflected XSS involves untrusted request data appearing in a site’s 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 textContent to 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.

Discussion

Reader Comments 0

Sign in with email or Google to join the discussion.