Sensitive Data Stored Insecurely on the Device

The app stores sensitive data, such as tokens or personal data, on the device in a readable form instead of protecting it with the platform's secure storage.

SeverityMedium
CVSS 3.14.2 CVSS:3.1/AV:P/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N Open in the calculator
CVSS 4.04.1 CVSS:4.0/AV:P/AC:L/AT:P/PR:N/UI:N/VC:H/VI:N/VA:N/SC:N/SI:N/SA:N Open in the calculator
CWECWE-312: Cleartext Storage of Sensitive Information
OWASP Top 10A06:2025 Insecure Design
CategoryCryptographic Failures

Description

The application stores sensitive information, such as authentication tokens, passwords, personal data or cryptographic keys, in a form that anyone with access to the device's file system can read. Common locations are Android SharedPreferences files, SQLite databases and other files in the app's data directory or in shared external storage, and on iOS property lists such as UserDefaults, databases, caches and files created without a suitable Data Protection class. Data the app encrypts itself is equally exposed when the key is stored beside it or built into the app.

The app's private storage is protected by the operating system's sandbox and, by default, by device encryption only until the device is first unlocked after a restart, but it can be read on a rooted or jailbroken device, by malware that has gained root, from some device backups and with forensic tools, while files in Android's shared storage may be readable by other apps. An attacker with such access, including physical possession of an unlocked or rooted device, can read the stored data: session or refresh tokens let them act as the user without knowing their password, often for long periods, and stored personal data may need to be treated as a breach. The need for privileged access to the device limits the likelihood, but lost, shared and rooted devices make it a realistic scenario.

Testing confirms the issue by using the app's features, extracting its data directory and reviewing the files for sensitive values, as described for the storage controls (MASVS-STORAGE) of the OWASP Mobile Application Security Verification Standard.

Remediation

  • Store as little sensitive data on the device as possible, and keep long-lived secrets on the server.
  • Keep keys in the platform's protected key stores, the Android Keystore (hardware-backed where available) and the iOS Keychain or Secure Enclave, and use them to encrypt any sensitive data the app must store; store small secrets such as tokens directly in the Keychain with a restrictive accessibility class such as kSecAttrAccessibleWhenUnlockedThisDeviceOnly.
  • On iOS, give files containing sensitive data the NSFileProtectionComplete protection class, noting that the app then cannot read them while the device is locked, for example from background tasks; on Android, keep them in app-specific internal storage rather than shared storage.
  • Exclude sensitive files from backups, and delete cached responses, temporary files and stored data at logout.
  • Use short-lived access tokens that the server can revoke, so that stored tokens have limited value.

Confirm the fix by repeating the extraction of the app's data after using its sensitive features and checking that no sensitive values can be read.

References


Add This Finding to Your Library

In Pental this write-up is in Settings, Library. Add to my library copies it into your own, rated in your firm's CVSS version, ready to put in your own words.

Free trial  ·  No card required

Only need the reporting? Our reporting tool is free and open source, with the same library.


More Mobile Applications Findings

Every Mobile Applications finding