Skip to main content

What do you think of this service? Your feedback will help us to improve it.

Author: Government Digital Service (GDS)

ASP.NET Reflected XSS

What this means

Reflected Cross-Site Scripting (XSS) is a security vulnerability where a cyber attacker injects malicious scripts into a web application. When other users load affected pages, the attacker’s scripts run, allowing them to:

  • steal cookies and session tokens
  • change the contents of the web page through Document Object Model (DOM) manipulation
  • redirect the browser to another page

XSS vulnerabilities typically occur when an application takes user input and outputs it to a page without validation.

Why this is a problem

XSS is an issue in ASP.NET because it compromises the security and integrity of web sites.

Some of the security risks of XSS in ASP.NET applications are:

  • session hijacking – attackers can steal authentication cookies, allowing them to impersonate legitimate users
  • data theft – malicious scripts can access or modify sensitive information displayed on web pages
  • defacement or malware injection – scripts can alter page content or redirect users to harmful sites
  • bypass of access controls – some exploits use XSS to escalate privileges or gain unauthorised access

How to check if the problem is there

To check if there’s a problem, you can use:

  • browser developer tools – inspect the response source code to see if user input appears in the HTML output without escaping
  • automated security scanners – submit various inputs using scanners such as BURP Suite or OWASP ZAP to see how the application responds
  • penetration testing frameworks – use tools such as XSStrike or XSSer to check for vulnerabilities

How to fix this

To protect against this vulnerability, web developers should:

  • use Content Security Policy (CSP) – by configuring a CSP header in your application you can restrict the execution of inline scripts
  • use a Web Application Firewall (WAF) or Next Generation Firewall (NGFW) to detect and block malicious requests
  • enable input validation – the web application should validate any input to the application before it is used

Sign up to UK Government Security

Subscribe to our newsletters to receive notifications when changes to strategy, policy, standards, and guidance are published on the website.

Sign up now