Android Insecure Data Storage
Overview
Android applications commonly store sensitive data insecurely:
- SharedPreferences plaintext: Tokens, passwords, PII stored in XML files readable on rooted devices
- External storage: Files on SD card readable by all apps with READ_EXTERNAL_STORAGE permission
- SQLite without encryption: Sensitive data in databases accessible after physical extraction
- Logcat logs: Sensitive data logged and accessible via
adb logcat - Clipboard: Sensitive data copied to clipboard accessible by other apps
Detection Strategy
SharedPreferences.edit().putString("password", ...)— storing sensitive values in plain SharedPreferencesEnvironment.getExternalStorageDirectory()— writing to external storageLog.d/i/v/w/ewith sensitive parameter values
Remediation
- Use Android Keystore System for cryptographic keys
- Use EncryptedSharedPreferences (Jetpack Security library)
- Store sensitive files in internal storage with MODE_PRIVATE
- Use SQLCipher for encrypted database storage
- Never log sensitive data