Open redirect (ARCH4122)
Esta página aún no está disponible en tu idioma.
Key java.security.open-redirect · Severity warning · Category security · CWE CWE-601
Taking the redirect target straight from user input lets attackers send victims to malicious sites through your trusted domain, enabling phishing.
Incorrect
Section titled “Incorrect”@GetMapping("/redirect")public String redirect(@RequestParam String url) { return "redirect:" + url;}Correct
Section titled “Correct”private static final Set<String> ALLOWED = Set.of("/home", "/dashboard");
@GetMapping("/redirect")public String redirect(@RequestParam String url) { return ALLOWED.contains(url) ? "redirect:" + url : "redirect:/home";}Validate redirect targets against an allowlist, or accept only application-relative paths.