Skip to content

Add MASTG-TEST-0264, MASTG-TEST-0265, MASTG-DEMO-0038, MASTG-DEMO-0039 #3246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

cpholguera
Copy link
Collaborator

@cpholguera cpholguera commented Mar 28, 2025

This pull request introduces two new demo tests for detecting StrictMode usage in Android applications, using both dynamic and static analysis techniques.

New demos

New Tests

@cpholguera cpholguera changed the title Add-demos-38-and-39 Add MASTG-TEST-0264, MASTG-TEST-0265, MASTG-DEMO-0038, MASTG-DEMO-0039 Mar 28, 2025
@cpholguera cpholguera requested a review from titze April 1, 2025 13:42
@cpholguera cpholguera marked this pull request as ready for review April 4, 2025 09:25
@cpholguera cpholguera requested a review from Copilot April 4, 2025 09:30
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 7 out of 11 changed files in this pull request and generated 1 comment.

Files not reviewed (4)
  • demos/android/MASVS-RESILIENCE/MASTG-DEMO-0038/output.txt: Language not supported
  • demos/android/MASVS-RESILIENCE/MASTG-DEMO-0038/run.sh: Language not supported
  • demos/android/MASVS-RESILIENCE/MASTG-DEMO-0039/output.txt: Language not supported
  • demos/android/MASVS-RESILIENCE/MASTG-DEMO-0039/run.sh: Language not supported
Comments suppressed due to low confidence (1)

rules/mastg-android-strictmode.yml:10

  • [nitpick] The pattern 'StrictMode.setVmPolicy(...)' may be too generic and might not catch all variants of StrictMode usage (e.g., chained calls or alternative configurations such as penaltyLog). Consider expanding the pattern or adding an additional rule to ensure comprehensive detection.
- pattern: StrictMode.setVmPolicy(...)

### Steps

1. Install the app on a device (@MASTG-TECH-0005)
2. Make sure you have @MASTG-TOOL-0001 installed on your machine and the frida-server running on the device
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
2. Make sure you have @MASTG-TOOL-0001 installed on your machine and the frida-server running on the device
2. Make sure you have @MASTG-TOOL-0031 installed on your machine and the frida-server running on the device

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also: shouldn't this (eventually?) be a Technique?

1. Install the app on a device (@MASTG-TECH-0005)
2. Make sure you have @MASTG-TOOL-0001 installed on your machine and the frida-server running on the device
3. Run `run.sh` to spawn the app with Frida
4. Click the **Start** button
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
4. Click the **Start** button
4. Click the **Start** button in the app


### Sample

This sample demonstrates the detection of `StrictMode` uses at runtime using Frida. The app enables a `StrictMode` policy to detect leaked SQLite objects and intentionally leaves a cursor unclosed to trigger the policy.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This sample demonstrates the detection of `StrictMode` uses at runtime using Frida. The app enables a `StrictMode` policy to detect leaked SQLite objects and intentionally leaves a cursor unclosed to trigger the policy.
This sample demonstrates the static detection of `StrictMode` in the app using Semgrep. The app enables a `StrictMode` policy to detect leaked SQLite objects and intentionally leaves a cursor unclosed to trigger the policy.


### Evaluation

The test fails because the output shows usages of `StrictMode` APIs, specifically:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since we were only looking for the setVmPolicy, the text sounds a bit off?

Comment on lines +18 to +22
Let's run @MASTG-TOOL-0110 rules against the sample code.

{{ ../../../../rules/mastg-android-strictmode.yml }}

{{ run.sh }}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't there a step missing? Since you run the semgrep rule against java code, I guess the app needs to be decompiled?

But since decompiling does not work so reliably, why not run a semgrep rule against the smali code?


This test checks whether the app uses `StrictMode` by dynamically analyzing the app's behavior and placing relevant hooks to detect the use of `StrictMode` APIs, such as `StrictMode.setVmPolicy` and `StrictMode.VmPolicy.Builder.penaltyLog`.

While `StrictMode` is useful for developers to log policy violations such as disk I/O or network operations in production apps, it can expose sensitive implementation details in the logs that could be exploited by attackers.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
While `StrictMode` is useful for developers to log policy violations such as disk I/O or network operations in production apps, it can expose sensitive implementation details in the logs that could be exploited by attackers.
While `StrictMode` is useful for developers to log policy violations such as disk I/O or network operations during development, it can expose sensitive implementation details in the logs that could be exploited by attackers.

I know we have the same text in the existing test, but I think it sounds a bit confusing.


## Steps

1. Run a dynamic analysis tool like @MASTG-TOOL-0039 and look for uses of `StrictMode` APIs.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
1. Run a dynamic analysis tool like @MASTG-TOOL-0039 and look for uses of `StrictMode` APIs.
1. Run a dynamic analysis tool like @MASTG-TOOL-0031 and look for uses of `StrictMode` APIs.


## Overview

This test checks whether the app uses `StrictMode`, which while useful for developers to log policy violations such as disk I/O or network operations in production apps, can expose sensitive implementation details in the logs that could be exploited by attackers.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
This test checks whether the app uses `StrictMode`, which while useful for developers to log policy violations such as disk I/O or network operations in production apps, can expose sensitive implementation details in the logs that could be exploited by attackers.
This test checks whether the app uses `StrictMode`. While useful for developers to log policy violations such as disk I/O or network operations during development, it can expose sensitive implementation details in the logs that could be exploited by attackers.

Comment on lines +17 to +18
1. Use @MASTG-TOOL-0110 to identify all instances of `StrictMode`
APIs.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Wouldn't it be better to reference a technique here?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants