Rule Definition
Android 9 introduces the unlockedDeviceRequired flag. This option determines whether the Keystore requires the screen to be unlocked before allowing decryption of any in-flight or stored data using the specified key. These types of keys are well suited for encrypting sensitive data to store on disk, such as health or enterprise data. The flag provides users a higher assurance that the data cannot be decrypted while the device is locked should their phone be lost or stolen.
Remediation
Enable the flag 'unlockedDeviceRequired' by passing true to the setUnlockedDeviceRequired() method.
Violation Code Sample
API >= 28:
.setUnlockedDeviceRequired(false) or not set
Fixed Code Sample
API >= 28:
.setUnlockedDeviceRequired(true)
Reference
https://developer.android.com/reference/android/security/keystore/KeyGenParameterSpec.Builder#setUnlockedDeviceRequired(boolean)
https://developer.android.com/about/versions/pie/android-9.0#security
Related Technologies
Technical Criterion
Secure Coding - Weak Security Features
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.