-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Android] SecureStorage: Rework logic to delete shared prefs when key is corrupt #23850
Merged
mattleibow
merged 2 commits into
main
from
dev/redth/fix-android-securestorage-corrupt-key
Aug 30, 2024
Merged
[Android] SecureStorage: Rework logic to delete shared prefs when key is corrupt #23850
mattleibow
merged 2 commits into
main
from
dev/redth/fix-android-securestorage-corrupt-key
Aug 30, 2024
Conversation
This file contains 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
samhouts
added
the
area-essentials
Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info
label
Jul 31, 2024
Any ETA for this fix or should I just fix it in my code first while waiting for library update? It looks like android update can break the secure storage |
/rebase |
Sometimes encrypted shared preferences can become unusable on android when backed up data gets migrated between different devices (and possibly in other scenarios). We tried to work around this by catching one particular exception and calling PlatformRemoveAll() to try and delete the shared prefs so we could create a new set, however this logic was flawed since the error occurs when getting an instance of the encrypted shared preferences, which the PlatformRemoveAll attempts to do itself (so it would fail to get the thing to remove the thing). This changes up the logic a bit and directly clears the shared preference that the encrypted one is stored in, without first trying to get an instance of the corrupt shared prefs. It then also tries to directly create a new instance afterwards, and return that, in an attempt to make this failsafe / reset operation transparent to the original call to get or set a secure storage key/value.
github-actions
bot
force-pushed
the
dev/redth/fix-android-securestorage-corrupt-key
branch
from
August 22, 2024 18:01
65d3f94
to
ceed3a0
Compare
It's worth pointing this out again here too: |
mattleibow
reviewed
Aug 22, 2024
mattleibow
approved these changes
Aug 30, 2024
Failing tests unrelated, retrying but this can probably be merged. |
samhouts
added
fixed-in-net9.0-nightly
This may be available in a nightly release!
fixed-in-net8.0-nightly
This may be available in a nightly release!
labels
Sep 5, 2024
samhouts
added
fixed-in-9.0.0-rc.2.24503.2
fixed-in-8.0.90
and removed
fixed-in-net9.0-nightly
This may be available in a nightly release!
fixed-in-net8.0-nightly
This may be available in a nightly release!
labels
Oct 14, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
area-essentials
Essentials: Device, Display, Connectivity, Secure Storage, Sensors, App Info
fixed-in-8.0.90
fixed-in-9.0.0-rc.2.24503.2
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.
Sometimes encrypted shared preferences can become unusable on android when backed up data gets migrated between different devices (and possibly in other scenarios).
We tried to work around this by catching one particular exception and calling PlatformRemoveAll() to try and delete the shared prefs so we could create a new set, however this logic was flawed since the error occurs when getting an instance of the encrypted shared preferences, which the PlatformRemoveAll attempts to do itself (so it would fail to get the thing to remove the thing).
This changes up the logic a bit and directly clears the shared preference that the encrypted one is stored in, without first trying to get an instance of the corrupt shared prefs.
It then also tries to directly create a new instance afterwards, and return that, in an attempt to make this failsafe / reset operation transparent to the original call to get or set a secure storage key/value.
Description of Change
Issues Fixed
Fixes #18230
Fixes #22094