Skip to content

Add Tests and Demos about "Sensitive Data Stored Unencrypted via Room"#3541

Open
macik09 wants to merge 16 commits into
OWASP:masterfrom
macik09:feature/mastg-roomdb-0306
Open

Add Tests and Demos about "Sensitive Data Stored Unencrypted via Room"#3541
macik09 wants to merge 16 commits into
OWASP:masterfrom
macik09:feature/mastg-roomdb-0306

Conversation

@macik09

@macik09 macik09 commented Nov 27, 2025

Copy link
Copy Markdown
Contributor

This PR closes #3448

##Summary

This PR introduces a new demo and finalizes the corresponding test for the MASVS-STORAGE requirement concerning unencrypted data persistence using the Room Library.

##Description

This submission specifically addresses data persistence via the Android Room Persistence Library by adding MASTG-DEMO-0070 and finalizing MASTG-TEST-0306.

The demo proves that sensitive PII (Email) and a secret (Access Token/Credential) are stored in plaintext within the default SQLite database created by Room. This is due to the lack of integration of an external encryption library (e.g., SQLCipher), confirming the weakness MASWE-0006.

The included run.sh script demonstrates the extraction of the Room database files from the app sandbox, allowing easy inspection of the sensitive contents in plaintext.

[x] I have read the contributing guidelines.

@cpholguera cpholguera changed the title add Demo-0070 and Test-0306 Add Tests and Demos about "Sensitive Data Stored Unencrypted via Room" Nov 28, 2025
@macik09 macik09 force-pushed the feature/mastg-roomdb-0306 branch 2 times, most recently from e96f24c to e1f04d1 Compare November 28, 2025 09:49
@cpholguera cpholguera requested a review from Diolor December 1, 2025 19:28

@jacobocasado jacobocasado May 2, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The DEMO must follow the content guidelines (https://mas.owasp.org/contributing/writing-content/mastg-demo.instructions).

For example, the "Evaluation" section should explain each relevant line of the output that is used as an evidence to give a FAIL to the test.

val dbPath = ctx.getDatabasePath("PrivateUnencryptedRoomDB")
Log.i("MASTG-ROOM", "Database absolute path: ${dbPath.absolutePath}")

// Wymuś utworzenie katalogu databases jeśli nie istnieje

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please, provide all comments / code lines in English :)

this.context = context;
}

public final String mastgTest() throws Exception {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This Java file does not seem to be the Java file resulting from decompiling the DEMO app. As commented previously, follow the DEMO guidelines (https://mas.owasp.org/contributing/writing-content/mastg-demo.instructions/) to provide these files accordingly.

@@ -0,0 +1,30 @@
#!/bin/bash

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The DEMO executes a run.sh file that extracts the Room database from the app's sandbox, but this is not what is made in the test. Normally, run.sh is a script that automates parts of the test (for example, if the tests consists on hooking several functions, the frida command is attached here for better reproducibility). Please also update run.sh accordingly to the TEST steps when updating the DEMO.

Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0306.md Outdated
id: MASTG-TEST-0309
type: [dynamic, filesystem]
weakness: MASWE-0006
best-practices: [MASTG-BEST-0025]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This BEST is about using PRNGs. How is this related to this test?

Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0309.md Outdated
Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0309.md Outdated
Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0309.md Outdated
Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0309.md Outdated

@jacobocasado jacobocasado left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@macik09 Review done! Please check https://mas.owasp.org/contributing/writing-content/mastg-demo.instructions/ and also https://mas.owasp.org/contributing/writing-content/mastg-test.instructions/ (for the TEST) and ensure that they are aligned with the instructions!

Thanks!

Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0309.md Outdated

4. Extract the database files to the host machine using @MASTG-TECH-0003.

5. Inspect database contents using a SQLite client or dynamic analysis tool (@MASTG-TECH-0015) to confirm whether sensitive data is stored in plaintext.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Such TECH is in TBD, try to use another TECH that is already done and fits better; otherwise, the TECH must be properly documented before relasing this TEST.

Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0309.md Outdated
Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0309.md Outdated
Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0309.md Outdated
@jacobocasado

Copy link
Copy Markdown
Collaborator

@macik09 Applied more suggestions after reviewing #3534. Ensure that they are both aligned!

Thanks!

title: Sensitive Data Stored Unencrypted via Android Room DB
platform: android
title: Static Analysis for Unencrypted Sensitive Data in Android Room DB
id: MASTG-TEST-0306

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Use a temporal ID to avoid drifts

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

While using temporal IDs my build failed because of regex. Is it ok or i misuderstood how to assign fake ID?

@jacobocasado jacobocasado May 21, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Yes, temporal IDs (e.g. MASTG-TEST-0x01) for the PRs are completely fine and the intended way to do it :)

See https://mas.owasp.org/contributing/writing-content/mastg-test.instructions/#creating-test-ids

Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0306.md Outdated
@macik09

macik09 commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

@jacobocasado The test process is now fully automated via run.sh, providing clear evidence in output.txt which is then mapped in the Evaluation section. I also changed the android_reversed.kt file.

From my perspective, looks good now. If you find this approach fine, I will proceed with updating my other pending PRs (SQLite - #3534 and Datastore - #3540 ) in the same manner to ensure consistency.

Looking forward to your feedback!

Comment thread demos/android/MASVS-STORAGE/MASTG-DEMO-0070/MASTG-DEMO-0070.md Outdated
Comment thread demos/android/MASVS-STORAGE/MASTG-DEMO-0070/MASTG-DEMO-0070.md Outdated
Comment thread demos/android/MASVS-STORAGE/MASTG-DEMO-0070/MASTG-DEMO-0070.md Outdated
Comment thread demos/android/MASVS-STORAGE/MASTG-DEMO-0070/MASTG-DEMO-0070.md Outdated
Comment thread demos/android/MASVS-STORAGE/MASTG-DEMO-0070/MASTG-DEMO-0070.md Outdated
Comment thread demos/android/MASVS-STORAGE/MASTG-DEMO-0070/MastgTest.kt Outdated
Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0x01.md Outdated

## Overview

This test verifies whether the app's code uses the [Android Room Persistence Library](https://developer.android.com/training/data-storage/room) to store sensitive data — such as tokens, credentials, or PII — without encryption. By default, Room stores data in unencrypted SQLite databases.

@jacobocasado jacobocasado May 21, 2026

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@cpholguera Should this be in a specific, little KNOW file talking about Room?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Also Room is a SQLite wrapper, I don't know if that serves a mention (there is already a KNOW file of SQLite: MASTG-KNOW-0037, https://mas.owasp.org/MASTG/knowledge/android/MASVS-STORAGE/MASTG-KNOW-0037/)

id: MASTG-TEST-0x01
type: [dynamic, filesystem]
weakness: MASWE-0006
best-practices: [MASTG-BEST-0x25]

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

BEST-0x25 is a new BEST file? Maybe you can make a BEST file for Android that recommends Storing Data Encrypted in App Sandbox Directory, like the one that exists for iOS right now (https://mas.owasp.org/MASTG/best-practices/MASTG-BEST-0024/).

You can attach this BEST file here, or in the other PRs, and expand it with examples of each of the ways to store data (Room, SQLite, DataStore) - If you are not doing this now, please create a PR to keep track of the needs of creating a file like this for Android.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Best 0x25 is part of PR #3534

Comment thread demos/android/MASVS-STORAGE/MASTG-DEMO-0070/run.sh
Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0x02.md Outdated

@jacobocasado jacobocasado left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Review done @macik09 , overall, good improvements!

If you have any questions, let me know before proceeding with the next ones!

Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0x01.md
Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0x02.md
Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0x02.md Outdated
Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0x01.md Outdated
Comment thread demos/android/MASVS-STORAGE/MASTG-DEMO-0070/MASTG-DEMO-0070.md Outdated
Comment thread tests-beta/android/MASVS-STORAGE/MASTG-TEST-0x02.md
@macik09 macik09 force-pushed the feature/mastg-roomdb-0306 branch from 6ac7b1d to c06b7ba Compare June 1, 2026 11:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add new Tests and Demo for MASWE-0006 using Android Room DB

2 participants