fix(ios): relax AsyncStorage data protection to allow access while locked#4
Open
exodus-jee wants to merge 1 commit into
Open
fix(ios): relax AsyncStorage data protection to allow access while locked#4exodus-jee wants to merge 1 commit into
exodus-jee wants to merge 1 commit into
Conversation
where do you see this? (not convinced it's true 🤔 ) |
|
docs say https://developer.apple.com/documentation/uikit/encrypting-your-app-s-files?utm_source=chatgpt.com
|
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
Fixes
AsyncStorageError [Failed to write manifest file]/Failed to write value/Could not open the existing manifeston iOS, which locks users out of their wallet (exodus-mobile #39598). These have been reported across 6+ releases, predominantly iOS, with accelerating volume.Root cause
The storage directory and its files are created without an explicit data protection class, so they inherit
NSFileProtectionComplete(no file access while the device is locked). The app declaresUIBackgroundModes: remote-notification, so iOS can wake it in the background while the device is still locked. When that happens,_writeManifest:/_writeEntry:/_ensureSetupcannot read or write the manifest and value files, and the failure propagates to JS as a permanentAsyncStorageError, blocking wallet open. The existing code already documents this exact scenario in_ensureSetup("data protection is enabled ... while the device is locked ... started by the system even if the device is locked due to e.g. a geofence event").Fix
Set the data protection class to
NSFileProtectionCompleteUntilFirstUserAuthentication, which keeps the files accessible after the first unlock following boot, including while the device is later locked:_createStorageDirectorynow creates the directory with that protection class, so new installs and newly written files inherit it._ensureSetupapplies it to the existing storage directory and its current contents once per setup, so existing installs are migrated to the relaxed class the first time the app runs while unlocked.This is the standard fix for this RNCAsyncStorage data-protection issue and matches newer upstream defaults.
Security note
This relaxes AsyncStorage at-rest protection from "locked" to "after first unlock". That is acceptable here: secrets are not stored in AsyncStorage, and the directory is already excluded from backup. The trade is intentional, in exchange for not locking users out of their wallet.
Test plan
Failed to write manifest file/Could not open the existing manifest.Release
Bumps the package to
1.17.11-exodus.5. Tag/publish on merge, then bump@exodus/react-native-async-storagein exodus-mobile to pick it up.