Use Android Keystore for device auth storage - #856
Draft
0xh3rman wants to merge 1 commit into
Draft
Conversation
1. Encrypt device auth values with a direct Android Keystore AEAD, migrating legacy Tink and DataStore values on read 2. Recover from keystore failures: drop corrupt values, retry transient faults once, reset only this namespace's keystore values 3. Regenerate device keys only when no stored value exists and return synthetic 599 when request signing fails 4. Add missing getPriceAlertAssetIds override in price alerts test fake
0xh3rman
force-pushed
the
hotfix/android-device-auth-keystore
branch
from
August 8, 2026 14:16
bdaba61 to
1a2a9c5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause
The exact originating Keystore condition is unknown. The crash happens when
AndroidKeysetManagercannot authenticate its SharedPreferences-wrapped Tink keyset with the Android Keystore master key, which raisesBadPaddingExceptionorAEADBadTagException.GetDeviceIdImplcatches the failed read and generates a new device key pair, but the old implementation then writes through the same unreadable Tink keyset and crashes again. New device-auth writes now use Android Keystore AEAD directly, so regeneration no longer depends on that legacy keyset. Existing readable values migrate on first read.Impact
Fixes the two observed device-auth crash paths. Invalid direct-Keystore data is cleared so the device identity can be regenerated; unrelated Android Keystore failures may still surface.
Validation
./gradlew :app:assembleGoogleDebug./gradlew :app:lintGoogleDebugTinkEncryptedKeyValueStoreInstrumentedTesttests on API 35git diff --check