Stack trace exposure (ARCH4127)
Ce contenu n’est pas encore disponible dans votre langue.
Key java.security.stack-trace-exposure · Severity warning · Category security · CWE CWE-209
Writing exception details or stack traces to the HTTP response exposes internal implementation details such as class names, file paths, and library versions to attackers.
Incorrect
Section titled “Incorrect”} catch (Exception e) { response.getWriter().write(e.toString()); e.printStackTrace(response.getWriter());}Correct
Section titled “Correct”} catch (Exception e) { log.error("Request failed", e); response.setStatus(500); response.getWriter().write("An unexpected error occurred.");}Log the exception server-side and return only a generic error message to the client.