fix(ios): relax AsyncStorage data protection to allow access while locked#4
fix(ios): relax AsyncStorage data protection to allow access while locked#4exodus-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
|
|
Yep, you're right, thanks for pushing on this. I checked and my root cause was wrong, so I'm closing this one. What I confirmed:
The failing window is also narrower than I wrote: under that class, files are blocked only before the first unlock after a reboot, not whenever the screen is locked. The one real failing case is a system background launch (we have To actually cover that window you need |
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.