A key of the Android KeyStore is created without requiring user authentication, so any code running as the app can use it
What it finds
A key in the Android KeyStore cannot be extracted, but it can be used by the app at any time. setUserAuthenticationRequired(true) makes each use wait for the user to unlock the device or confirm with a fingerprint.
Reported is build() on a chain that starts at new KeyGenParameterSpec.Builder(...) and does not call setUserAuthenticationRequired(true).
From the rule's source, keystore_key_without_authentication.rs.
import android.security.keystore.KeyGenParameterSpec; class Keys { Object run() { Object a = new KeyGenParameterSpec.Builder("a", 3).setKeySize(256).build();tx0 reports: without the user authenticating Object b = new KeyGenParameterSpec.Builder("b", 3).setUserAuthenticationRequired(true).build(); return a; }} 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/java:keystore-key-usable-unattended" = "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/java:keystore-key-usable-unattended] reason="..."tx0 explain tx0/java:keystore-key-usable-unattended shows the same in the terminal. Found a false positive? Report it.