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

    1. Delete the log line, or wrap it in a development-only guard (__DEV__, kDebugMode, BuildConfig.DEBUG, #if DEBUG).
    2. Strip console.* calls from release bundles (babel-plugin-transform-remove-console, R8 -assumenosideeffects for android.util.Log).
    3. 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 app

    References

    Related checks (M9)