MASTG-DEMO-0159: Sensitive Views Without Accessibility Data Sensitivity
Download MASTG-DEMO-0159 APK Open MASTG-DEMO-0159 Folder Build MASTG-DEMO-0159 APK
Sample¶
The sample creates a login and payment form with views that handle sensitive data, each using a different accessibility data sensitivity configuration. It does so by using Kotlin and the Android View APIs (instead of Android layout XML).
- Username field: isn't marked as accessibility data sensitive.
- Password field: is explicitly marked as accessibility data sensitive using
setAccessibilityDataSensitive(View.ACCESSIBILITY_DATA_SENSITIVE_YES). - One-time code field: sets
filterTouchesWhenObscured, which implies accessibility data sensitivity. - Payment container: a
LinearLayoutthat is explicitly marked as accessibility data sensitive usingsetAccessibilityDataSensitive(View.ACCESSIBILITY_DATA_SENSITIVE_YES). It contains two views:- Card number field: keeps the default value,
ACCESSIBILITY_DATA_SENSITIVE_AUTO, so it inherits the protection from the payment container. - Confirm Payment button: explicitly disables the protection using
setAccessibilityDataSensitive(View.ACCESSIBILITY_DATA_SENSITIVE_NO), which overrides the value inherited from the payment container.
- Card number field: keeps the default value,
- Cancel button: is outside the payment container and keeps the default value,
ACCESSIBILITY_DATA_SENSITIVE_AUTO. It doesn't handle sensitive data, so it isn't protected.
Marking a view as accessibility data sensitive only restricts accessibility services that aren't declared as accessibility tools. Accessibility tools, such as screen readers, can still read and interact with all of these views (see "Accessibility Tools" in Accessibility Data Sensitivity).
When you tap Start, the app shows the form at the bottom of the screen and lists the value returned by isAccessibilityDataSensitive for each view. Tapping Confirm Payment or Cancel closes the form and shows a confirmation message.
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
Steps¶
Let's run our semgrep rule against the reverse-engineered code.
| ../../../../rules/mastg-android-accessibility-data-sensitive.yaml | |
|---|---|
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 | |
| run.sh | |
|---|---|
1 2 3 4 | |
Observation¶
The rule reports the calls to setAccessibilityDataSensitive and setFilterTouchesWhenObscured in the reverse-engineered code. In the decompiled code, the constants appear as their integer values: 1 for ACCESSIBILITY_DATA_SENSITIVE_YES and 2 for ACCESSIBILITY_DATA_SENSITIVE_NO.
| output.txt | |
|---|---|
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 | |
- Line 64: the password field calls
setAccessibilityDataSensitive(1). - Line 67: the one-time code field calls
setFilterTouchesWhenObscured(true). - Line 71: the payment container calls
setAccessibilityDataSensitive(1). - Line 82: the Confirm Payment button calls
setAccessibilityDataSensitive(2).
Evaluation¶
The test case fails because two views that handle sensitive data aren't accessibility data sensitive:
- The username field (line 61) doesn't appear in the output because the app doesn't configure any protection for it.
- The Confirm Payment button (line 82) is reported by the
mastg-android-accessibility-data-sensitive-disabledrule because the app callssetAccessibilityDataSensitive(2)on it, which overrides the protection inherited from the payment container.
The remaining views are protected:
- The password field (line 64) is explicitly marked as accessibility data sensitive.
- The one-time code field (line 67) sets
filterTouchesWhenObscuredand keeps the defaultACCESSIBILITY_DATA_SENSITIVE_AUTOvalue, so it's treated as accessibility data sensitive. - The card number field (line 72) doesn't appear in the output, but the payment container (line 71) is marked as accessibility data sensitive and the field keeps the default value, so it inherits the protection.
Note that the output only lists the views for which the app configures the protection. Views without any configuration, such as the username field (line 61) and the Cancel button (line 85), don't appear, so you have to find them by reviewing the reverse-engineered code. This is manageable in a small sample but hard in a real app. Runtime Accessibility Data Sensitivity of Sensitive Views with Frida shows how enumerating the views at runtime lists every view on the screen, including these, together with its effective value.
When you tap Start, the app confirms these results at runtime by listing the value returned by isAccessibilityDataSensitive for each view: false for the username field and the Confirm Payment button, and true for the other fields.