From Insecure Storage to Secure Practices: A Follow-Up
Sensitive data such as a verified mobile number was stored in plaintext in Android SharedPreferences, so anyone with local access to the device could read it. The development team later replaced this with EncryptedSharedPreferences, and the post explains how to verify that the values are no longer readable.
Published on medium.com
In a previous article , I explored how attackers and security testers can inspect Android apps to find sensitive data stored insecurely in SharedPreferences, using tools like adb and apktool.
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the app used standard SharedPreferences, which stores keys and values as plain text on the device, instead of an encrypted storage mechanism.
Impact
An attacker with local access to the device, such as on a rooted phone or emulator, could read sensitive values like the verified mobile number; the text does not claim remote exploitation.
What the attacker needed
Local access to the device or emulator; app installed and used to store data
The fix
The development team replaced standard SharedPreferences with EncryptedSharedPreferences, which encrypts keys and values and stores the keyset in the Android Keystore.
How it was found
- Trigger the app workflow such as login, OTP validation, or phone number verification.
- List the shared preferences directory on the device.
- Read the contents of the preferences file.
- Check whether any sensitive keys or values are still in plaintext.
- Optionally decompile the APK and search for the use of EncryptedSharedPreferences.create.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.
Android apps can save small pieces of data, like a phone number or a login token, in a file called SharedPreferences. If that file is not encrypted, someone who can look at the phone's files, for example on a rooted phone or an emulator, can read those values directly. The fix is to use a special encrypted version of SharedPreferences so the saved data looks like random characters.
What is Info disclosure?
Data the application should keep private (personal data, internal details, other users' records) reaches someone it should not.