We all have been told to always use char[]
instead of java.lang.String
to handle plain text passwords in Java applications. Due to the immutable nature of java.lang.String
that allows attackers to take a heap snapshot (before GC kicked in) and read the passwords from that snapshot.
Now I'm surprised to see spring-security using String
to transfer passwords. E.g. in UserDetails.
Is this a security issue? And if no, why not? If yes, how can I safely use spring-security without revealing passwords in the Java heap or at least minimizing the risk of revealing them?