medium · M9 · MASVS-STORAGE-2 · PTKD-LEFTOVER-SECRET-LOGGED
Tokens or passwords written to the device log
The app logs values whose names say they are credentials (token, password, apiKey, session…). Release builds keep these log calls: anyone with the phone, a crash reporter, or a log-reading app can collect them.
How it is exploited
After login the app runs console.log('session', session) to debug a redirect. In the release build that line still runs; on Android the token lands in logcat and in the crash reporter's breadcrumbs, where a support contractor or a malicious log-reading app can replay it.
Why it matters
Account takeover by replaying tokens, and personal data in third-party log systems (a GDPR problem on its own).
How to fix it
- Delete the log line, or wrap it in a development-only guard (__DEV__, kDebugMode, BuildConfig.DEBUG, #if DEBUG).
- Strip console.* calls from release bundles (babel-plugin-transform-remove-console, R8 -assumenosideeffects for android.util.Log).
- Scrub tokens in your crash reporter's beforeSend hook.
Does your app have this?
PTKD checks your build or your source project for PTKD-LEFTOVER-SECRET-LOGGED and every other check in this knowledge base.
Scan your appReferences
Related checks (M9)
- Android file or preferences created world-readable or world-writable
- Public Supabase bucket can be listed by anyone
- Public Supabase storage bucket (heuristic)
- Sensitive data written to external storage
- Sensitive data written to the log
- Secret written to device storage
- Tokens or passwords stored in plain app preferences
- Keychain item accessible while locked