Vulnsy
highMobile

Insecure Data Storage

OWASP Mobile Top 10 2024 - M9: Insecure Data StorageCWE-312: Cleartext Storage of Sensitive InformationCWE-922: Insecure Storage of Sensitive InformationCWE-311: Missing Encryption of Sensitive Data

Learn how mobile apps store sensitive data insecurely in plaintext databases, shared preferences, and local files. Understand platform-specific remediation.

What is Insecure Data Storage?

Insecure Data Storage is one of the most prevalent and impactful mobile application vulnerabilities, ranked consistently in the OWASP Mobile Top 10. This vulnerability occurs when mobile applications store sensitive information—credentials, tokens, personal data, financial information, health records—in locations or formats that are accessible to other applications, attackers with physical device access, or malicious actors who gain access through device backups, file system access, or operating system vulnerabilities.

Mobile devices present unique data storage challenges compared to server environments. Users carry devices that can be lost, stolen, or physically accessed by adversaries. Mobile operating systems provide multiple storage mechanisms (shared preferences, SQLite databases, keychain/keystore, file system, SD cards, cloud backups) each with different security properties. Applications that store sensitive data without leveraging platform-specific secure storage mechanisms expose that data to a wide range of attack scenarios.

The risk is compounded by mobile platform features designed for user convenience. Cloud backup services (iCloud, Google Backup) automatically sync application data to cloud storage, potentially exposing locally stored secrets. External storage (SD cards) on Android devices is world-readable by all applications. Debug builds and development configurations left in production releases may enable additional data access paths. Even seemingly innocuous data like cached API responses or application logs can contain sensitive information that persists on the device long after the user has logged out.

How It Works

Attackers access insecurely stored mobile data through several techniques. Physical device access allows direct file system examination: on rooted Android devices, the entire application sandbox (/data/data/[package-name]/) is accessible; on jailbroken iOS devices, application data directories are similarly exposed. Common targets include SQLite databases (often containing cached user data, messages, or credentials in plaintext), SharedPreferences/NSUserDefaults files (frequently used to store session tokens, user IDs, or feature flags), and application-specific files in the documents or cache directories.

Backup extraction provides another attack vector. Android backup files (ADB backup) and iTunes/iCloud backups contain application sandbox data unless the application explicitly opts out of backup. Attackers with access to a user's computer or cloud backup account can extract application data without physical device access. Forensic tools like iExplorer, Android Debug Bridge, and Cellebrite automate the extraction of application data from device backups, making this attack accessible even to unsophisticated adversaries.

On non-rooted/non-jailbroken devices, insecure data storage can still be exploited through malicious applications that exploit Android's external storage (readable by all apps), content provider misconfigurations that expose application data to other apps, clipboard data that persists sensitive information copied by users, and application log files that may be accessible through platform logging mechanisms. Screenshot caching by the OS when apps enter the background can expose sensitive screens, and keyboard cache/autocomplete data can reveal previously entered sensitive information.

Impact

  • Credential theft when authentication tokens, passwords, or API keys stored in plaintext are extracted from device storage or backups
  • Personal data exposure including names, addresses, financial information, health records, and private communications stored in unencrypted databases
  • Identity theft and fraud when government identifiers, credit card numbers, or bank account details are recovered from insecure storage
  • Privacy violations under GDPR, HIPAA, and CCPA when personal data is accessible through device forensics, backups, or malicious applications
  • Account takeover when session tokens or refresh tokens stored in insecure locations enable attackers to impersonate the user
  • Corporate data leakage in enterprise mobile applications when business-critical data, trade secrets, or customer information is stored insecurely on employee devices

Remediation Steps

  1. Use platform-specific secure storage mechanisms for all sensitive data. On iOS, use the Keychain Services API with appropriate access control flags (kSecAttrAccessibleWhenUnlockedThisDeviceOnly) for credentials and sensitive tokens. On Android, use the Android Keystore System for cryptographic keys and EncryptedSharedPreferences (Jetpack Security library) for sensitive key-value data.
  2. Encrypt all locally stored sensitive data using strong encryption algorithms (AES-256-GCM) with keys stored in the platform secure enclave (iOS Secure Enclave, Android Hardware-Backed Keystore). Never hardcode encryption keys in the application binary or store them alongside the encrypted data.
  3. Minimize data stored on the device. Apply the principle of data minimization: store only the data necessary for offline functionality, cache sensitive data only when required and clear it when no longer needed, and prefer server-side data storage with on-demand retrieval over local caching of sensitive information.
  4. Disable application data backup for applications handling sensitive data. On Android, set android:allowBackup="false" in the manifest and implement android:fullBackupContent rules to exclude sensitive files. On iOS, set the isExcludedFromBackup resource value on sensitive file URLs to prevent iCloud backup.
  5. Implement secure data deletion: overwrite sensitive data in memory before deallocation, clear all cached data and tokens on user logout, implement session timeout that clears sensitive local data after inactivity, and use secure file deletion that overwrites file contents before unlinking.
  6. Protect against screenshot and task switcher leakage by implementing screen obscuring when the app enters the background (iOS: applicationWillResignActive, Android: FLAG_SECURE). Disable clipboard access for sensitive fields and implement custom keyboard input for credential fields to prevent keyboard caching.
  7. Implement runtime application self-protection (RASP) that detects rooted/jailbroken devices and adjusts security posture accordingly—either refusing to run, clearing sensitive local data, or limiting functionality. Do not rely solely on root/jailbreak detection as it can be bypassed.

Testing Guidance

Begin by examining all local storage locations used by the application. On Android, use ADB to pull the application sandbox: adb backup -f backup.ab [package-name] and extract with abe unpack backup.ab backup.tar. Examine SharedPreferences XML files, SQLite databases, and files in the app's internal and external storage directories. On iOS, use ideviceinstaller and ifuse (or device backup extraction tools) to access application data directories. Search all extracted files for sensitive data patterns: email addresses, tokens, passwords, credit card numbers, and PII.

Use dynamic analysis tools like Frida to hook into storage APIs at runtime and monitor what data is being written to each storage location. Hook SharedPreferences.putString() on Android and NSUserDefaults.set() on iOS to capture all key-value storage operations. Use Objection (built on Frida) to dump the iOS Keychain and Android Keystore contents, verifying that sensitive data is stored in secure locations with appropriate access controls. Check whether the application properly clears sensitive data from memory after use using memory analysis tools.

Test backup data exposure by creating a device backup, extracting it, and searching for sensitive application data. Verify that allowBackup is disabled or that backup rules exclude sensitive files. Test screenshot protection by backgrounding the app while sensitive data is displayed and checking the task switcher thumbnail and screenshot cache. Test clipboard exposure by copying sensitive fields and checking clipboard contents from another application. Use MobSF (Mobile Security Framework) for automated static and dynamic analysis that checks for common insecure data storage patterns in both Android and iOS applications.

References

mobiledata-storageencryptionkeychainkeystoreandroidiosowasp-mobile-top-10

Frequently Asked Questions

What is Insecure Data Storage?

Insecure Data Storage is one of the most prevalent and impactful mobile application vulnerabilities, ranked consistently in the OWASP Mobile Top 10. This vulnerability occurs when mobile applications store sensitive information—credentials, tokens, personal data, financial information, health records—in locations or formats that are accessible to other applications, attackers with physical device access, or malicious actors who gain access through device...

How does Insecure Data Storage work?

Attackers access insecurely stored mobile data through several techniques. Physical device access allows direct file system examination: on rooted Android devices, the entire application sandbox (/data/data/[package-name]/) is accessible; on jailbroken iOS devices, application data directories are similarly exposed.

How do you test for Insecure Data Storage?

Begin by examining all local storage locations used by the application. On Android, use ADB to pull the application sandbox: adb backup -f backup.ab [package-name] and extract with abe unpack backup.ab backup.tar. Examine SharedPreferences XML files, SQLite databases, and files in the app's internal and external storage directories.

How do you remediate Insecure Data Storage?

Use platform-specific secure storage mechanisms for all sensitive data. On iOS, use the Keychain Services API with appropriate access control flags (kSecAttrAccessibleWhenUnlockedThisDeviceOnly) for credentials and sensitive tokens. On Android, use the Android Keystore System for cryptographic keys and EncryptedSharedPreferences (Jetpack Security library) for sensitive key-value data.

Report Vulnerabilities Faster with Vulnsy

Stop rewriting the same findings. Use Vulnsy's reusable templates, collaborative workflows, and professional report generation to deliver pentest reports 10x faster.

Start Free Trial