Skip to content

Conversation

@maxschwinghammer
Copy link
Collaborator

Potential fix for https://github.com/FreshKeeper/AndroidApp/security/code-scanning/8

The best way to fix the problem is to leverage an Android KeyStore-backed cryptographic key for guarding changes to the biometric-enabled state, ensuring that only an authenticated user (with a registered biometric) can enable this setting by successfully unlocking a secret key. Specifically:

  • Generate a symmetric encryption key using Android's KeyStore, requiring biometric user authentication for use.
  • On biometric prompt, supply a Cipher (as a CryptoObject) that can only be used after successful biometric authentication.
  • In onAuthenticationSucceeded, require and use the Cipher (via result.getCryptoObject().getCipher()), ensuring that biometric authentication was needed to access the key/cipher operation. Update the setting state only in this context.
  • This change should be implemented within the onBiometricSwitchChanged method in ProfileSettingsViewModel.

The following edits are required:

  1. Add functions for generating and retrieving the KeyStore-backed key, similar to the provided secure example.
  2. Prepare a Cipher before launching the biometric prompt and use it as a CryptoObject.
  3. Change the call to authenticate() to pass a CryptoObject.
  4. In onAuthenticationSucceeded, verify and use the Cipher from the CryptoObject before updating state.

Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…ation

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants