Our website uses cookies to enhance your browsing experience.
Accept
to the top
>
>
>
V5323. OWASP. Potentially tainted...
menu mobile close menu
Additional information
toggle menu Contents

V5323. OWASP. Potentially tainted data is used to define 'Access-Control-Allow-Origin' header.

Apr 02 2025

The analyzer has detected an insecure configuration of Cross-origin resource sharing (CORS). The Access-Control-Allow-Origin server response header value is generated based on unverified external data.

It is an insecure practice to configure the value of the Access-Control-Allow-Origin header based on unverified external data. Depending on the context, this can lead to varying levels of security risks. Attackers' websites can gain access to user's page resources, and under special circumstances, sensitive information could be exposed.

This vulnerability can be categorized under the OWASP Top 10 2021 classification as follows:

The example of an insecure configuration:

@GetMapping("/test")
public ResponseEntity<?> getExample(@RequestParam("origin") String origin) {
  var httpHeaders = new HttpHeaders();
  httpHeaders.add("Access-Control-Allow-Origin", origin); // <=

  return new ResponseEntity<>("ok", httpHeaders, HttpStatus.ACCEPTED);
}

To mitigate these risks, ensure that external data is checked against the whitelisted values.

The fixed example:

private static final List<String> ALLOWED_ORIGINS = List.of(
        "https://first-allowed-domain.com",
        "https://second-allowed-domain.com"
);

@GetMapping("/test")
public ResponseEntity<?> getExample(@RequestParam("origin") String origin) {
  var httpHeaders = new HttpHeaders();
  if (ALLOWED_ORIGINS.contains(origin)) {
      httpHeaders.add("Access-Control-Allow-Origin", origin);
  }
  // ....
}

This diagnostic is classified as:

close form

Fill out the form in 2 simple steps below:

Your contact information:

Step 1
Congratulations! This is your promo code!

Desired license type:

Step 2
Team license
Enterprise license
close form
Request our prices
New License
License Renewal
--Select currency--
USD
EUR
close form
Free PVS‑Studio license for Microsoft MVP specialists
close form
To get the licence for your open-source project, please fill out this form
close form
I want to join the test
* By clicking this button you agree to our Privacy Policy statement

close form
check circle
Message submitted.

Your message has been sent. We will email you at


If you do not see the email in your inbox, please check if it is filtered to one of the following folders:

  • Promotion
  • Updates
  • Spam