A SecureRandom is requested with the SHA1PRNG algorithm, whose output can be predictable when seeded
What it finds
SecureRandom.getInstance("SHA1PRNG") gives a generator that becomes deterministic when it is seeded before use, and its implementations have had flaws on Android. SecureRandom() picks the strongest source of the platform.
From the rule's source, sha1prng_random.rs.
fun random() { val a = SecureRandom.getInstance("SHA1PRNG")tx0 reports: SHA1PRNG can give predictable numbers val b = SecureRandom.getInstanceStrong() val c = 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:sha1prng-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:sha1prng-secure-random] reason="..."tx0 explain tx0/kotlin:sha1prng-secure-random shows the same in the terminal. Found a false positive? Report it.