A password encoder keeps passwords readable or hashes them with a quick digest
What it finds
NoOpPasswordEncoder stores passwords as they are, and StandardPasswordEncoder, MessageDigestPasswordEncoder, Md4PasswordEncoder and LdapShaPasswordEncoder hash them with fast digests that a graphics card tries billions of times per second (CWE-916). Spring Security deprecates them all in favour of adaptive functions such as bcrypt, scrypt, PBKDF2 or Argon2.
Reported is the use of one of these encoders.
From the rule's source, weak_password_encoder.rs.
import org.springframework.security.crypto.password.NoOpPasswordEncoder;import org.springframework.security.crypto.password.PasswordEncoder;import org.springframework.security.crypto.password.StandardPasswordEncoder; class Encoders { PasswordEncoder plain() { return NoOpPasswordEncoder.getInstance();tx0 reports: stores passwords in plain text } PasswordEncoder fast() { return new StandardPasswordEncoder();tx0 reports: fast digest }} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/java:weak-password-encoder" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/java:weak-password-encoder] reason="..."tx0 explain tx0/java:weak-password-encoder shows the same in the terminal. Found a false positive? Report it.