Android data storage checks

Android insecure data storage testing

Most storage findings come down to one question: can someone other than the signed-in user, on this device or from a copy of it, read data that should stay private?

Where Android apps store data

An Android app can write data to several places, and each has different exposure. The app sandbox gives every app a private directory under /data/data/<package>/ that other apps cannot read on a normal, non-rooted device. That directory holds shared_prefs/ XML files, SQLite databases under databases/ and arbitrary files under files/ and cache/.

Shared external storage, logs, the clipboard and backups are different: they can be reached outside the sandbox. These checks belong to MASVS-STORAGE, which asks that sensitive data is stored securely and does not leak through system mechanisms.

Sandbox protection is not encryption

Private storage is protected by the operating system, not by the app. On a rooted or compromised device, through a debuggable build or from an extracted backup, files in the sandbox can be read as plain text. Whether that matters depends on the data and the threat model agreed in scope.

Session tokens, refresh tokens, passwords and personal records are the usual concern. For high-value data, use encryption with a key held in the Android Keystore so the key material is not stored next to the data it protects.

Locations to inspect

Common storage locations and what to look for
LocationWhat to check
SharedPreferencesTokens, user identifiers, flags such as is_premium or is_admin that the app trusts.
SQLite and Room databasesCached personal data, messages or account records kept longer than needed.
Shared external storageExports, downloads or logs written outside the sandbox. Scoped storage on newer Android versions narrows access, but older targets and devices behave differently.
LogsTokens, request bodies or personal data written with Log calls, especially in release builds.
BackupsWhether private files are included in cloud or device-transfer backups; see the manifest review guide.
Screens and keyboardSensitive screens shown in the recent-apps preview, and input fields that allow keyboard learning for secrets.

Static review

  • Search the decompiled code for writes to preferences, databases and files, and note which keys or tables hold sensitive values.
  • Look for logging of request or response bodies, tokens and identifiers, and check whether it is removed in release builds.
  • Check for FLAG_SECURE on screens that show secrets, and for input types that disable suggestions on password or code fields.
  • Record any hardcoded encryption key: data encrypted with a key that ships in the APK is only obscured.

Runtime check

On an authorized test device with test accounts, log in and use the workflows in scope, then inspect the sandbox. A debuggable test build allows adb shell run-as <package>; on a release build, a rooted test device is usually needed. List the files, open preferences and databases, and record what is stored and in what form.

Repeat after logout. Data that survives logout, such as a still-valid refresh token or cached personal records, is often more significant than data stored during an active session. Watch adb logcat while exercising login and payment flows.

Report it with the evidence

Include the file path, the key or table, a redacted sample of the value, the build used, whether the device was rooted and whether the data remained after logout. State the threat model: data readable only with root access is a different severity from data on shared storage.

Recommend storing less, expiring tokens server-side, clearing data on logout and using Keystore-backed encryption for what must remain. Use the MASVS checklist to place the check in a full assessment and the report evidence guide to separate a candidate from a verified finding.

Related reading