MASTG-DEMO-0078: App Leaking Sensitive Data via Notifications
Download MASTG-DEMO-0078 APK Open MASTG-DEMO-0078 Folder Build MASTG-DEMO-0078 APK
Sample¶
The following sample code contains:
- the Kotlin code that creates a notification with the
NotificationManagerclass and exposes sensitive data. - the AndroidManifest.xml that declares the runtime permission
POST_NOTIFICATIONSpermission that allows the app to post notifications (Android API 33 and higher).
Note
To execute the test on a device, we must ensure that the app has the POST_NOTIFICATIONS permission granted. This can be done either via the adb command, such as adb shell pm grant org.owasp.mastestapp android.permission.POST_NOTIFICATIONS or by navigating to the app settings on the device and manually enabling the permission.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | |
Steps¶
Let's run our semgrep rule against the reversed Java code.
| ../../../../rules/mastg-android-sensitive-data-in-notifications.yml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 | |
And another one against the sample manifest file.
| ../../../../rules/mastg-android-sensitive-data-in-notifications-manifest.yml | |
|---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | |
| run.sh | |
|---|---|
1 2 3 | |
Observation¶
The rule detected two instances in the code where the setContentTitle API is used to set the notification title, and 2 cases where the setContentText API is used to set the notification text. It also identified the location in the manifest file where the POST_NOTIFICATIONS permission is declared.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | |
Evaluation¶
After reviewing the decompiled code at the location specified in the output (file and line number), we can conclude that the test fails because the notification contains sensitive data, specifically a first and a last name (PII).