Skip to main content

Reflected cross-site scripting (XSS)


The web application dynamically generates web content without validating the source of the potentially untrusted data.


Generate web pages that could contain malicious scripts injected into untrusted data.


Perform input data validations on the server-side to avoid common script injection attacks.


Authenticated attacker from the Internet.

Expected Remediation Time

โŒš 45 minutes.


Default score using CVSS 3.1. It may change depending on the context of the vulnerability.


  • Attack vector: N
  • Attack complexity: L
  • Privileges required: N
  • User interaction: R
  • Scope: U
  • Confidentiality: N
  • Integrity: L
  • Availability: N


  • Exploit code madurity: X
  • Remediation level: X
  • Report confidence: X


  • Vector string: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:N/E:X/RL:X/RC:X
  • Score:
    • Base: 4.3
    • Temporal: 4.3
  • Severity:
    • Base: Medium
    • Temporal: Medium

Code Examples

Compliant code

Implement correct and secure validation of input data

namespace Controllers{
public class Calculate{
public static void ProcessRequest(HttpRequest req, HttpResponse res){
string name = req.QueryString["name"];
res.Write("Hello " + name);

string value = req.QueryString["value"];
//Server side validation of entry data
if (value == null || !Regex.IsMatch(value, "^[a-zA-Z0-9]+$")){
throw new InvalidOperationException("Invalid value");
res.AddHeader("X-Header", value);

Non compliant code

A method that reads input data and does not properly validate the information, so an XSS attack could still be executed

public void bad(HttpServletRequest request, HttpServletResponse response) throws Throwable{
String data = "";
Socket socket = null;
BufferedReader readerBuffered = null;
InputStreamReader readerInputStream = null;
socket = new Socket("", 39544);
readerInputStream = new InputStreamReader(socket.getInputStream(), "UTF-8");
readerBuffered = new BufferedReader(readerInputStream);
data = readerBuffered.readLine();
catch (IOException exceptIO){
IO.logger.log(Level.WARNING, "Error with stream reading", exceptIO);
// Not shown: Code to close the socket...
if (data != null){
//* POTENTIAL FLAW: Display of data in web page after using replaceAll() to remove script tags,
// which will still allow XSS with strings like <scr<script>ipt>
response.getWriter().println("<br>bad(): data = " + data.replaceAll("(<script>)", ""));