Skip to content

Conversation

@Diolor
Copy link
Collaborator

@Diolor Diolor commented Oct 14, 2025

This PR closes #2981

Description

Port mastg test 0008 from v1 to v2 incl. demo

The rule is on purpose in Kotlin (and not the usual Java) to detect Compose views.
If we truly want to use a rule against Java code, it is possible, but we would need to import more Java reverse-engineered files. Compose classes create a lot of boilerplate and detection would not be 1:1.

e.g. the semgrep rule would need to be looking for SecureTextFieldKt instances

TODO:

  • Allocate new TEST ID
  • Allocate new DEMO ID
  • Get peer feedback for tests-beta/android/MASVS-PRIVACY/MASTG-TEST-02te.md line 5

@sk3l10x1ng
Copy link
Collaborator

sk3l10x1ng commented Oct 23, 2025

@cpholguera @sushi2k could you pls assign , i'll do the review for the pull request

@cpholguera cpholguera requested a review from sk3l10x1ng October 23, 2025 06:45
@cpholguera cpholguera changed the title Port MASTG-TEST-0008: Codes in Text Input Fields Port MASTG-TEST-0008: Checking for Sensitive Data Disclosure Through the User Interface (android) Oct 28, 2025
Copy link
Collaborator

Choose a reason for hiding this comment

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

About the title, id and message: this isn't about privacy. We're actually testing from the security realm.

id: MASTG-TEST-02te
type: [static, manual] // TODO evaluate
weakness: MASWE-0053
profiles: [P]
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is L2, see MASWE-0053

Suggested change
profiles: [P]
profiles: [L2]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

#3464 's test that points to WE-54 with similar characteristics to 53 tests privacy. Can you please elaborate?

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's the same situation

MASWE-0054: Sensitive Data Leaked via Notifications is L2

We have different Tests there as well one for authenticators (L2) and another for PII (P)

Then the weakness will belong to both profiles. Actually weaknesses would inherit the profiles from the underlying tests.

platform: android
title: App Exposing Access and Verification Codes in Text Input Fields
id: MASTG-TEST-02te
type: [static, manual] // TODO evaluate
Copy link
Collaborator

Choose a reason for hiding this comment

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

There is no category "manual"

Suggested change
type: [static, manual] // TODO evaluate
type: [static]

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

The test should focus on the static analysis using Semgrep from the layout files. @cpholguera Could you please share your suggestion

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Please propose how to avoid the (manual) step 3.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Please propose how to avoid the (manual) step 3.

Could you please elaborate on this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Step 3 is required to perform the test. It is a manual step, and I could not think of an automatic way to replace it.
If you wish to mark this test as solely static, we would need to find a way to avoid that step, which to my best knowledge, is not possible.

Comment on lines +16 to +36
Proper masking (dots instead of input characters) of these codes is essential to protect user privacy. This can be achieved by using appropriate input types that obscure the characters entered by the user.

XML view:

```xml
<EditText
android:inputType="textPassword"
...
/>
```

Jetpack Compose:

```kotlin
SecureTextField(
textObfuscationMode = TextObfuscationMode.RevealLastTyped, // or TextObfuscationMode.Hidden
...
)
```

> Note: That even if the SecureTextField is used with `textObfuscationMode` set to `RevealLastTyped` or `Hidden`, it can later be changed to `Visible` programmatically.
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be better to incorporate this into the best practices MASTG-BEST-XXX.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

What purpose do you suggest the best practice would serve?

Copy link
Collaborator

Choose a reason for hiding this comment

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

This serves to standardize remediation advice, improve developer awareness.

Writing MAS Weaknesses & Tests document : https://docs.google.com/document/d/1EMsVdfrDBAu0gmjWAUEs60q-fWaOmDB5oecY9d9pOlg/edit?tab=t.0#heading=h.94f3yhwcmntt

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for pointing out the guidelines. My question above was to ask for and understand the value of extracting this note into a separate best practice.

The MASTG Best Practices are a collection of specific strategies and practices that can be used to prevent or mitigate security and privacy risks in mobile apps. What is the specific strategy or practice you wish we recommend to readers so that they can mitigate a security or privacy risk? What is the security risk you see here? Awareness is not considered a risk nor a mitigation.

@Diolor Diolor requested a review from sk3l10x1ng October 29, 2025 18:15
@@ -0,0 +1,87 @@
package org.owasp.mastestapp
Copy link
Collaborator

@sk3l10x1ng sk3l10x1ng Oct 30, 2025

Choose a reason for hiding this comment

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

@Diolor

  • Please change the demo. Testing should concentrate on black-box scenarios and demonstrate how an attacker might proceed: acquire the APK, decompile the APK, examine res/layout/ for entries, use semgrep to search for hints/ids such as password|pin|secret|pwd, and verify if any password field lacks android:inputType="textPassword".
  • Demo for App Notifications: The old test also had a static and dynamic analysis session, which would be great to migrate to this one too and not lose knowledge.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. Compose is pretty standard nowadays among developers and is gaining more and more traction over XML views. Why should we focus on XMLs?
  2. Port MASTG-TEST-0005: Determining Whether Sensitive Data Is Shared with Third Parties via Notifications (android) #3464 addresses notifications

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.

MASTG v1->v2 MASTG-TEST-0008: Checking for Sensitive Data Disclosure Through the User Interface (android)

3 participants