Skip to content

Conversation

@macik09
Copy link
Contributor

@macik09 macik09 commented Nov 27, 2025

This PR closes #3449
Description

This PR introduces a new demo and finalizes the corresponding test for the MASVS-STORAGE requirement concerning unencrypted data persistence.
This submission specifically addresses data persistence via Jetpack DataStore by adding MASTG-DEMO-0069 and finalizing MASTG-TEST-0305.

The demo proves that sensitive PII (Email) and a secret (Password/Token) are stored in plaintext within the application's DataStore files (.preferences_pb or .proto). This occurs when developers fail to implement an explicit encryption layer, confirming the weakness MASWE-0006.

The included run.sh script demonstrates that these sensitive contents are trivially accessible from the app's private sandbox on a privileged device.

[x] I have read the contributing guidelines.

Comment on lines 22 to 39
### Static Analysis
1. Obtain the application package (e.g., APK file) using @MASTG-TECH-0003.
2. Use a static analysis technique (@MASTG-TECH-0014) to identify references to DataStore APIs such as:
- `androidx.datastore.preferences.preferencesDataStore`
- `androidx.datastore.core.DataStore` (or usage of generated Proto classes).
- `dataStore.edit`, `updateData`, or `write` operations.
3. Inspect the code to determine whether:
- sensitive data is stored using the default, unencrypted implementation.
- a secure mechanism (e.g., applying an `EncryptedFile.Builder` for Preferences DataStore or using an encrypted custom serializer for Proto DataStore) is explicitly applied to the sensitive fields.

### Dynamic Analysis
1. Install and run the app on a rooted or emulated device (@MASTG-TECH-0005).
2. Trigger app functionality that processes or stores sensitive data.
3. Access the app’s private storage (typically `/data/data/<package_name>/datastore/`) and locate the DataStore files. This requires accessing the app data directories (@MASTG-TECH-0008). File names usually end with:
- `.preferences_pb` (Preferences DataStore)
- `.proto` (Proto DataStore)
4. Extract the DataStore files from the device using @MASTG-TECH-0003.
5. Inspect the file content using a suitable tool, applying the technique for Dynamic Analysis (@MASTG-TECH-0015) to confirm whether sensitive data is stored in plaintext. *Note: Proto DataStore files require a Proto decoder for inspection.*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all the new PRs:

We require separate tests.

See for example:

@cpholguera cpholguera changed the title add Demo-0069 and Test-0305 Add Tests and Demos about "Sensitive Data Stored Unencrypted via DataStore" Nov 28, 2025
@macik09 macik09 force-pushed the feature/mastg-datastore-clean branch from 7e31c5f to 57ed186 Compare November 28, 2025 09:20
@macik09 macik09 force-pushed the feature/mastg-datastore-clean branch from 57ed186 to 4a930bc Compare November 28, 2025 09:25
@macik09 macik09 requested a review from cpholguera December 1, 2025 07:31
@cpholguera cpholguera requested a review from Diolor December 1, 2025 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants