Encrypting private mobile app storage
Private app storage can still disclose information through device compromise, backups or unsafe key handling. Understanding private mobile app storage helps establish which security property the feature needs and where that property is actually enforced.
What does this involve?
Storage security concerns the copies that remain after an operation has finished. Files, databases, caches and exports can have different access rules and retention periods. A protected main database does not automatically protect a temporary copy or a restored backup.
In Android, applications can use the SharedPreferences API to store sensitive data without encryption, typically under the app's private data directory, such as /data/user/0//shared_prefs/ or /data/data//shared_prefs/.
While MODE_PRIVATE restricts file access to the app itself, it doesn't protect the data from being read by attackers who gain access to the device's file system (for example, through device compromise, backup extraction, or physical access to rooted/unlocked devices).
Why it matters
Consider a realistic failure: a field service app retains customer records after its user signs out.
Exposure can involve private records, reusable credentials or information that identifies a customer. The practical impact depends on which copy is accessible, the access an attacker needs and whether the recovered material remains useful.
Mobile behaviour can change between a fresh installation, an authenticated session, background activity and a device migration. The assessment needs the actual release and representative supported device states.
How penetration testers check for it
Inspect files after realistic user actions and compare locked, unlocked and logged-out states.
- or WebSettings.setCacheMode is any value other than WebSettings.LOAD_NO_CACHE.
- CookieManager.setAcceptCookie is not explicitly set to false (default is set to true).
- When exercising the app, make sure to keep a list of the sensitive data you expect to be cleaned up, so you can verify whether it is still present in the WebView storage directory after closing the app.
- Exercise the app extensively to trigger as many flows as possible and enter sensitive data wherever you can.
- Check temporary copies, exports, backups and deletion behaviour.
- Establish whether recovered information grants any further access.
How to fix it
Minimise retained data and bind encryption keys to appropriate platform protections.
- Retain only the information needed for the service.
- Separate private working data from deliberately shared content.
- Protect encryption keys independently of encrypted files.
- Verify removal and recovery behaviour against the intended lifecycle.
Encryption is one part of the design. It cannot compensate for an application that willingly returns plaintext to an unauthorised caller.
Recheck the changed behaviour against the original failure conditions and the legitimate user journey. Keep enough evidence to show which release and configuration were verified, and include related entry points that depend on the same security decision.
Related issues
- Sensitive mobile data in shared and external storage
- Mobile backups that expose private app data
- Private mobile data exposed in notifications
Read about our methodology or contact pentested.com to discuss your mobile applications.