Android data storage

Sensitive data in Android logs

Debug logging that survives into a release build is one of the most common ways an app leaks tokens and personal data.

Why logs matter

Calls such as Log.d, println and HTTP logging interceptors write to the system log. Since Android 4.1, a normal app can only read its own log entries, but anyone with adb access, a bug report, a crash reporting service or a rooted device can read everything. Logs also end up in support tickets and third-party dashboards.

Leaking data through logs is covered by MASVS-STORAGE, which asks that sensitive data is not exposed through logs, backups or other unintended places.

What to look for

  • Access tokens, refresh tokens, session cookies and API keys.
  • Full request or response bodies, often from an HTTP client logging interceptor left at body level.
  • Personal data: names, phone numbers, email addresses, locations, identity numbers.
  • Payment data, one-time codes and password reset links.
  • Stack traces that reveal internal hostnames or query structure.

Static check

Search the decompiled code for logging calls and the libraries that wrap them, such as android.util.Log, Timber and HTTP logging interceptors. Note which calls pass variables that could hold sensitive values, and whether the call is guarded by a debug flag. Check the R8 or ProGuard configuration for rules that strip logging in release builds.

Runtime check

On an authorized test device, clear the log, then exercise login, profile, payment and any flow that handles personal data while recording the log filtered to the app's process:

adb logcat -c then adb logcat --pid=$(adb shell pidof -s <package>)

Search the capture for the test account's values: the email address, the token returned by the login response, the phone number. A match is direct evidence; a pattern match without the real value is only a candidate.

Commands run from adb shell have shell privileges that a normal app does not; repeat important results from an unprivileged test app before reporting them.

Fix and report

Remove sensitive values from log messages rather than masking them in a few places. Gate debug logging on the build type, set HTTP logging to none in release builds, and use R8 -assumenosideeffects rules to strip Log calls. Review what your crash reporter collects by default.

In the report, include the log line, the flow that produced it and the build that was tested. See our deep dive on verifying Android FLAG_SECURE and masked log canaries on real devices, and review related storage issues in the insecure data storage guide.

Related reading