MASTG Tests

πŸ“Œ These study notes serve as a concise reference, capturing the essential insights, guidelines, and best practices for securing mobile applications, based on the OWASP MASTG (Mobile Application Security Testing) Standard - Tests.


🌐 Resources πŸ”—


Android


MASTG-TEST-0001arrow-up-right Testing Local Storage for Sensitive Data

  1. Open the app and click everywhere possible to trigger all possible functionalities and ensure data generation

  2. Check all app generated files (SharedPreferences, SQL, Realm dbs, Internal/External Storage, etc)

Data stored locally should be at least encrypted and stored within the app sandbox. If possible, sensitive data should not be stored at all.

Static

Input the apk into jadx-gui

  • Check AndroidManifest.xml for uses-permission android:name="android.permission

  • Check the source code for file permissions, classes and functions, and bad practices.

Dynamic

To manage all those tests, a full pull data from an Android device's local storage may be useful.

  • Check internal and external local storage, dev files, backup files, old files

  • Check permissions in the app folder /data/data/<package-name>

  • Check SQLite databases stored in /data/data/<package-name>/databases (on device) for sensitive data and db encryption

  • Check Shared Preferences in /data/data/<package-name>/shared_prefs

  • Check for Firebase Real-time dbs in /data/data/<package-name>/files/


MASTG-TEST-0003arrow-up-right Testing Logs for Sensitive Data

  • Check for log related source code and files, and analyze them for any sensitive data

Logging should be removed from production releases.

Static

  • Check the source code for logging classes.

Dynamic

Use all the app functions at least once. Look for logs inside the app's data directory /data/data/<package-name

pidcat

MASTG-TEST-0004arrow-up-right Determining Whether Sensitive Data Is Shared with Third Parties via Embedded Services

Static

  • Review third-party libraries source code, requested permissions and vulnerabilities

  • Prevent PII exposure

Dynamic

Launch a man-in-the-middle (MITM) attack by routing the traffic through BurpSuite or ZAP proxy and sniffing the traffic between the app and the server.

  • Check for sensitive information (PII), specially in ads or tracking services


MASTG-TEST-0005arrow-up-right Determining Whether Sensitive Data Is Shared with Third Parties via Notifications

Static

  • Understand if notification management classes (e.g. NotificationManager) are used, how the application works and which data is shown in the generated notifications.

Dynamic

Trace calls to functions related to notifications creation and check if it contains any sensitive information.

  • use Frida scripts


MASTG-TEST-0006arrow-up-right Determining Whether the Keyboard Cache Is Disabled for Text Input Fields

Static

  • Check for the android:inputType XML attribute and its constants like

    • textPassword, textVisiblePassword, numberPassword, textWebPassword

    • Check the android:minSdkVersion in the AndroidManifest.xml file for the above constants support

Dynamic

Check for input fields that take sensitive data.

  • Keyboard cache is enabled if strings are suggested


MASTG-TEST-0009arrow-up-right Testing Backups for Sensitive Data

Static

  • Check the AndroidManifest.xml for android:allowBackup

    • if true, check for sensitive data in the saved backup

  • Pay attention to cloud (auto) backup, it may contain unencrypted sensitive data files

  • Check the source code for BackupAgent, BackupAgentHelper classes

Dynamic

Use adb to backup the app and check the backup archive for sensitive data.

  • Approve the backup in the device

  • Convert the .ab backup file (with ABEarrow-up-right) to .tar and extract the data from it


MASTG-TEST-0011arrow-up-right Testing Memory for Sensitive Data

  • Check for data disclosure via process memory, by creating a memory dump or real-time memory analysis (debugger).

Static

  • Identify and map data usage across application components.

  • Minimize the number of components handling sensitive data.

  • Ensure prompt removal of object references when sensitive data is no longer needed.

  • Request garbage collection after removing references.

  • Overwrite sensitive data immediately when it becomes unnecessary.

Follow best practices and coding recommendations (SecureSecretKey class, etc) to make sure that sensitive data in memory is cleared out at logout and during onPause events for example, managing user's authentication experience.

Dynamic

Retrieve and analyze a memory dump using objectionarrow-up-right or fridumparrow-up-right.

  • Check the memory dump for sensitive data, using strings command to extract strings from the dmp files

    • Indicative field names like "password", "pass", "pin", "secret", "private", etc.

    • Indicative patterns in strings, char arrays, byte arrays, etc.

    • Known secrets (credit card number, etc)

Objection Tutorial - HackTricksarrow-up-right

r2fridaarrow-up-right can be used for Runtime Memory Analysis, searching the memory for a strings, values, etc.


MASTG-TEST-0012arrow-up-right Testing the Device-Access-Security Policy

Applications dealing with sensitive data should run in a secure and trusted environment. To establish this environment, the app can verify the device for:

  • Device lock with PIN or password protection

  • Up-to-date Android OS version

  • Activated USB Debugging

  • Device encryption

  • Device rooting

Static

Check the source code for functions implementing a device-access-security policy (e.g. App runs only on Android 9.0+) and determine if it can be bypassed.

  • system preferences Settings.Secure

Dynamic

Validate the bypassed security enforcing checks if present.



MASTG-TEST-0019arrow-up-right Testing Data Encryption on the Network


MASTG-TEST-0020arrow-up-right Testing the TLS Settings


MASTG-TEST-0021arrow-up-right Testing Endpoint Identify Verification


MASTG-TEST-0022arrow-up-right Testing Custom Certificate Stores and Certificate Pinning


MASTG-TEST-0023arrow-up-right Testing the Security Provider


Last updated