← Java / Spring · Contents

JAVA-041 / Intermediate

Logging passwords, tokens or national ID numbers

A09:2021 Security Logging and Monitoring Failures · CWE-532 Sensitive Info in Log

Why is this a problem?

Sensitive information spreads through the log collection system.

How to fix it

java
@JsonIgnore private String password;   // Alternatively, use a masking utility or filter DTOs before logging

Further reading