Skip to content

Add MASTG content for Android 14 accessibilityDataSensitive protection - #3679

Open
cpholguera with Copilot wants to merge 19 commits into
masterfrom
copilot/add-mastg-test-for-accessibility
Open

cpholguera with Copilot wants to merge 19 commits into
masterfrom
copilot/add-mastg-test-for-accessibility

Conversation

Copilot AI commented Jan 31, 2026 •

Copy link
Copy Markdown
Contributor

Adds MASTG content for Android's accessibility data sensitivity feature. Apps can mark views as accessibility data sensitive so that only accessibility services declared as accessibility tools (android:isAccessibilityTool="true"), such as screen readers, can read or interact with them. Other accessibility services, including malware that tricks users into enabling it, are denied access to these views. Views that set filterTouchesWhenObscured="true" are treated as sensitive automatically, and children inherit the protection from a sensitive parent.

The APIs (setAccessibilityDataSensitive, isAccessibilityDataSensitive, and the ACCESSIBILITY_DATA_SENSITIVE_* constants) were added in Android 14 (API level 34). Google's Android Developers Blog presents the feature as an Android 16 defense, but all content here uses API level 34 based on the official API reference.

All content is linked to MASWE-0040 (Sensitive Data Leaked via Accessibility Services) (MASWE v1.0.0) and uses fake IDs (0x01, 0x02) to avoid collisions with master.

Changes

Knowledge (MASTG-KNOW-0x01)

  • Describes the feature neutrally: XML and programmatic configuration, the AUTO/YES/NO values, automatic behavior through filterTouchesWhenObscured and parent inheritance, accessibility tools, and platform version considerations.

Best Practice (MASTG-BEST-0x01)

  • Explains which views to protect (login, payment and transaction confirmations, system prompts and settings, personal data, 2FA), how to mark them, how inheritance works, and why not to set ACCESSIBILITY_DATA_SENSITIVE_NO on sensitive views.
  • Covers caveats: impact on accessibility tools, older Android versions, and reliance on correct isAccessibilityTool declarations.

Tests

  • MASTG-TEST-0x01 ([static, code, manual]): References to accessibility data sensitivity APIs in code and layout files. Notes that views the app never configures don't appear in static output, and points to the dynamic test for confirmation.
  • MASTG-TEST-0x02 ([dynamic, hooks, manual]): Runtime verification. Hooks the setters (@MASTG-TECH-0043), obtains the UI hierarchy of each sensitive screen with the effective isAccessibilityDataSensitive value of each view (@MASTG-TECH-0x01), and takes a screenshot per screen (@MASTG-TECH-0x02). Warns that uiautomator dump can't be used to verify this protection.

Both tests include a "Further Validation Required" block, since automated tools can't reliably decide whether a screen shows sensitive data.

Demos

  • MASTG-DEMO-0x01 (static, semgrep): A MASTestApp sample with five configurations (unprotected, explicit YES, implied through filterTouchesWhenObscured, inherited from a payment container, and explicit NO overriding the container). Includes validated reverse-engineered code and semgrep output.
  • MASTG-DEMO-0x02 (dynamic, Frida): Reuses the same sample through a symlink. The script hooks the setters with backtraces and dumps the view hierarchy with each view's effective value, revealing inherited protection and views that were never configured. Includes validated output and a screenshot.

Rule

  • rules/mastg-android-accessibility-data-sensitive.yaml: Detects setAccessibilityDataSensitive calls (with a WARNING for ACCESSIBILITY_DATA_SENSITIVE_NO), setFilterTouchesWhenObscured calls, and the corresponding XML attributes.

Techniques

  • MASTG-TECH-0x01 (Inspecting the UI Hierarchy): Compares uiautomator dump, Maestro, dumpsys activity top, Layout Inspector, view enumeration with Frida, and a custom accessibility service. Explains what each method reveals and why most of them can't verify accessibility data sensitivity (for example, UI Automator and Maestro still list protected views).
  • MASTG-TECH-0x02 (Taking Screenshots): Using adb, the Android CLI, and Maestro.

Tools

  • MASTG-TOOL-0x01: Maestro
  • MASTG-TOOL-0x02: Android CLI

Validation

  • The demo sample was built with the MASTestApp and run on a physical device with Android 14 or higher.
  • The semgrep rule and the Frida script were run against the real reverse-engineered code and app, and their outputs are included.
  • The uiautomator dump, dumpsys activity top, and Maestro results described in MASTG-TECH-0x01 were checked on the same device.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • semgrep.dev
    • Triggering command: /home/REDACTED/.local/bin/pysemgrep osemgrep --config ../../../../rules/mastg-android-accessibility-data-sensitive.yaml activity_login.xml --text MASWE-0069 0.md rep MASWE-0069 (dns block)
    • Triggering command: /home/REDACTED/.local/bin/pysemgrep osemgrep --config ../../../../rules/mastg-android-accessibility-data-sensitive.yaml MastgTest.kt --text MASWE-0069 2.md p/bin/grep MASWE-0069 (dns block)
    • Triggering command: /home/REDACTED/.local/bin/pysemgrep osemgrep --config ../../../../rules/mastg-android-accessibility-data-sensitive.yaml activity_login.xml --text MASWE-0069 4.md ndor/bin/grep MASWE-0069 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Create new MASTG Test, Best Practice and Demo for marking UI views in the app as containing sensitive data</issue_title>
<issue_description>Android 16 provides a new, powerful defense in a single line of code: accessibilityDataSensitive. This flag lets you explicitly mark views in your app as containing sensitive data and block malicious apps from seeing or performing interactions on it. If you already use setFilterTouchesWhenObscured(true) to protect your app from tapjacking, your views are automatically treated as sensitive data for accessibility for an instant additional layer of defense with no extra work.

Android 16 and accessibilityDataSensitive: Starting with Android 16 (API level 16) and higher, developers can use the accessibilityDataSensitive flag to further protect sensitive data from malicious accessibility services that are not legitimate accessibility tools. When this flag is set on sensitive views (e.g., login screens, transaction confirmation screens), it restricts apps with accessibility permission from reading or interacting with the sensitive data unless they are declared as an isA11yTool=true in their manifest. This provides a more robust, system-level protection against eavesdropping and click injection attacks that are characteristic of partial occlusion scenarios. Developers can often implicitly enable accessibilityDataSensitive by specifying android:filterTouchesWhenObscured="true" in their layout files.

More info:

https://android-developers.googleblog.com/2025/12/enhancing-android-security-stop-malware.html

https://developer.android.com/privacy-and-security/risks/tapjacking#mitigations</issue_description>

Comments on the Issue (you are @copilot in this section)

@cpholguera Sounds great, thank you! @cpholguera @hharshhsaini you can, but please carefully read the contribution guidelines:

https://mas.owasp.org/contributing/#what-not-to-do

And consider the previously closed PR.</comment_new>


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Created Knowledge page MASTG-KNOW-0108 for accessibilityDataSensitive
- Created Best Practice MASTG-BEST-0029 for marking UI views as sensitive
- Created Test MASTG-TEST-0321 for static detection
- Created Test MASTG-TEST-0322 for dynamic verification
- Created Demo MASTG-DEMO-0083 demonstrating detection with semgrep
- Created semgrep rule for static analysis

Co-authored-by: cpholguera <29175115+cpholguera@users.noreply.github.com>
Copilot AI changed the title [WIP] Add new MASTG test for marking sensitive data in UI views Add MASTG content for Android 16 accessibilityDataSensitive protection Jan 31, 2026
Copilot AI requested a review from cpholguera January 31, 2026 22:59
Carlos Holguera added 16 commits October 24, 2026 12:01
…DataSensitive attribute and updated recommendation
…el for accessibilityDataSensitive attribute and enhance validation guidance with Further Validation
…sensitive views and adjust API level references
…riting guidelines, enhance accessibility data sensitivity explanation and add accessibility tools
@cpholguera
cpholguera marked this pull request as ready for review October 25, 2026 17:42
@cpholguera cpholguera changed the title Add MASTG content for Android 16 accessibilityDataSensitive protection Add MASTG content for Android 14 accessibilityDataSensitive protection Oct 26, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create new MASTG Test, Best Practice and Demo for marking UI views in the app as containing sensitive data

2 participants