Secrets In Shared Preferences
How Secrets In Shared Preferences works
Storing tokens, passwords, or keys in Android SharedPreferences or iOS UserDefaults without encryption allows easy extraction on rooted/jailbroken devices, backups, or via debug tools.
Secrets In Shared Preferences in practice
Android SharedPreferences
adb shell run-as com.example.app cat /data/data/com.example.app/shared_prefs/auth.xml
If tokens/PII are present in cleartext, storage is insecure.
How to fix and prevent Secrets In Shared Preferences
- Use secure storage
- Store secrets in Keystore/Keychain; encrypt any cached values with hardware‑backed keys.
- Minimise and rotate
- Avoid long‑term token storage; rotate refresh tokens and wipe on logout.
- Backup controls
- Exclude preference files from backups where secrets might exist.
Last updated