A password is hashed or a key derived with a salt written in the code
What it finds
A salt makes the same password hash differently for each user. A salt written in the code is the same for everyone, so one precomputed table covers all of them. Reported for the salt argument of PBEKeySpec when it is a string literal turned into bytes or a byteArrayOf of literals.
From the rule's source, constant_salt.rs.
fun derive(password: CharArray, salt: ByteArray) { val a = PBEKeySpec(password, "pepper".toByteArray(), 600000, 256)tx0 reports: the salt is written in the code val b = PBEKeySpec(password, byteArrayOf(1, 2, 3, 4), 600000, 256)tx0 reports: the salt is written in the code val c = PBEKeySpec(password, salt, 600000, 256)} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/kotlin:constant-salt" = "warning"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/kotlin:constant-salt] reason="..."tx0 explain tx0/kotlin:constant-salt shows the same in the terminal. Found a false positive? Report it.