← Java / Spring · Contents

JAVA-066 / Intermediate

Sensitive information in exception messages

A05:2021 · CWE-209 Error Message Information Exposure

Why is this a problem?

A response may contain text such as "User 'admin' password=...".

How to fix it

java
throw new IllegalStateException("invalid credentials");   // Log only an ID internally for details

Further reading