A SecureRandom is seeded with a constant, which makes its output predictable
What it finds
SecureRandom(byteArrayOf(1, 2, 3)) or random.setSeed(42) with a constant makes the numbers reproducible, which is what an attacker needs. A SecureRandom seeds itself from the system when left alone.
From the rule's source, predictable_seed.rs.
import java.security.SecureRandom fun randoms() { val a = SecureRandom("seed".toByteArray())tx0 reports: seeded with a constant val secureRandom = SecureRandom() secureRandom.setSeed(42)tx0 reports: seeded with a constant val b = SecureRandom()} 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:seeded-secure-random" = "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:seeded-secure-random] reason="..."tx0 explain tx0/kotlin:seeded-secure-random shows the same in the terminal. Found a false positive? Report it.