+MASTG-BEST-0050 Store Data Encrypted in App Sandbox Directory (Android)

MASTG-BEST-0050 Store Data Encrypted in App Sandbox Directory (Android)

Store sensitive data in SharedPreferences only after encrypting it. Standard SharedPreferences stores values in XML files inside the app's private data directory, so values such as credentials, authentication tokens, private keys, or personally identifiable information (PII) should not be stored in cleartext.

For apps that use SharedPreferences, use EncryptedSharedPreferences or an equivalent mechanism that encrypts preference keys and values before they are written to disk. An equivalent mechanism should use authenticated encryption, protect encryption keys with the Android Keystore or another appropriate key management system, and avoid custom cryptography.

Note

EncryptedSharedPreferences is part of the Jetpack Security Crypto library. All APIs in that library were deprecated in version 1.1.0, and Android states that there will be no subsequent releases. It may still be a practical mitigation for existing apps that must keep using SharedPreferences, but it should not be treated as a long term storage strategy. Monitor Android's cryptography and DataStore guidance, and plan a migration to a supported encryption approach when available.

Android recommends DataStore as a modern replacement for SharedPreferences, but DataStore does not encrypt data by default. If you migrate sensitive data to DataStore, use an appropriate encryption layer before writing the data. AndroidX introduced the androidx.datastore:datastore-tink artifact for DataStore encryption support in version 1.3.0-alpha07. This provides encryption using the Tink library and AeadSerializer, which wraps an existing DataStore serializer and performs authenticated encryption and decryption. See the DataStore release notes for more information and an example of use.

1. Ülevaade

Pealkiri Standard

1.1 Viited

1.2 Tuvastatud nõuded

1.3 Seotud regulatsioonid

2. Tuvastatud nõuded

Nõuded
Allikas Nõue

3. Seotud regulatsioonid

Regulatsioonid
Allikas Regulatsioon

Lingitud teemad

  • OWASP -

    EN: Publications of the OWASP Foundation, https://owasp.org/. OWASP® is a registered trademark of the OWASP Foundation, Inc.; GRCA is not affiliated with, nor endorsed by, the OWASP Foundation. Only the versions published by OWASP are authoritative.

    DE: Veröffentlichungen der OWASP Foundation, https://owasp.org/. OWASP® ist eine eingetragene Marke der OWASP Foundation, Inc.; GRCA steht in keiner Verbindung zur OWASP Foundation und wird von ihr nicht unterstützt. Maßgeblich sind allein die von OWASP veröffentlichten Fassungen.