After KeyPermanentlyInvalidatedException: silent key re-enrollment or forced server re-authentication?
0 reputation · 03 Jan 2020, 10:21 UTC
0 reputation · 03 Jan 2020, 10:21 UTC
I'm designing credential handling for an Android app that binds its refresh-token encryption key to the Android Keystore with setUserAuthenticationRequired(true) and setInvalidatedByBiometricEnrollment(true). The goal is least-privilege access: no usable credential without fresh user authentication.
The documented behavior creates a fork I can't resolve. When the user enrolls a new biometric or removes the lock screen, the key is permanently destroyed and Cipher.init throws KeyPermanentlyInvalidatedException. At that point the app can either silently generate a new key and re-bind the stored refresh token, or wipe local credentials and force full server re-authentication.
The trade-off: silent re-enrollment is seamless, but the platform provides no signal distinguishing a benign enrollment change from a compromised device, so re-binding could hand a fresh key to an attacker. Forced re-authentication is safer but punishes users for routine lock-screen changes, and I can't tell how common this is across OEM implementations given known inconsistencies in invalidation behavior.
Assume target SDK 30+, TEE-backed keys with StrongBox fallback where available.
setUserAuthenticationParameters change the risk calculus here?A thoughtful contribution can make all the difference. Be the first to share one.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.