An Android app can be made to act against its own user when another app draws over it, hides what a button really does, or captures what the user types into a screen that only looks genuine. Tapjacking is the Android form of clickjacking, and overlay abuse is a core technique of banking trojans and credential stealers. Android has narrowed the attack with every release from Android 6 to Android 16, but the strongest protections only apply when the app turns them on, and partial occlusion has no default defence at all. This guide explains the attack variants at a defender's level of detail, gives a version table of platform mitigations checked against Android and AOSP documentation in November 2026, and sets out the app-level, enterprise and testing controls Android developers and mobile security teams should apply. For broader Android hardening see the Android App Security Guide; this page goes deeper on overlays.
Key takeaways
- Android 12 blocks the classic full-occlusion attack by default. From API 31 the system drops touches that pass through untrusted overlays owned by another app, but translucent system alert windows with a combined opacity at or below 0.8 are still allowed through.
- Partial occlusion is the app's job. Android's tapjacking guidance states there is no default protection when the attacker covers the area around a control rather than the control itself; apps must reject events flagged FLAG_WINDOW_IS_PARTIALLY_OBSCURED on sensitive views.
- Hiding overlays beats filtering touches. Window.setHideOverlayWindows(true) with the HIDE_OVERLAY_WINDOWS permission (protection level normal in AOSP) removes non-system overlays while your sensitive screen is shown. OWASP MASTG ranks it the most robust option.
- Accessibility abuse is the bigger threat now. Banking malware increasingly uses accessibility services rather than overlays alone. On Android 14 and later, accessibilityDataSensitive keeps non-tool accessibility services away from sensitive views, and on Android 16 it also blocks their injected gestures.
- Test for it explicitly. OWASP MASTG-TEST-0340 checks for overlay protections under MASVS-PLATFORM-3. Make it a release gate for login, payment, consent and recovery screens.
What tapjacking and overlays are
Android's security guidance describes tapjacking as a malicious app tricking a user into tapping a security-relevant control by obscuring the interface or by other means. The guidance covers full and partial occlusion, plus custom toast and activity sandwich risks. These four matter because each has a different defence.
| Variant | What the user sees | What happens | Primary defence |
|---|---|---|---|
| Full occlusion | An attacker window covering the target control | The tap lands on or passes through the overlay to a hidden control | Android 12 default blocking; filterTouchesWhenObscured; setHideOverlayWindows |
| Partial occlusion | The genuine control, with attacker content around it | Surrounding content misleads the user about what the visible control does, or captures nearby input | Reject FLAG_WINDOW_IS_PARTIALLY_OBSCURED events; setHideOverlayWindows |
| Custom toast | A toast with a custom view shown over another app | Toast content misleads the user, historically launched from the background | Platform: background custom toasts blocked from Android 11 for apps targeting API 30, fully mitigated from Android 12 |
| Activity sandwich | The victim activity with an attacker activity stacked on it | An app the user opened launches the victim activity and covers it | Do not export activities that do not need to be exported |
A separate but related pattern is the fake screen: malware detects that a banking or wallet app has come to the foreground and immediately shows its own full-screen login page that imitates it. This is ATT&CK for Mobile T1417.002 GUI Input Capture. No touch passes through to the real app, so touch filtering does not help; the defences are on the device and on the server side, covered below. See Mobile T1417 Input Capture.
How overlay abuse is used in fraud and malware
Overlay and screen-capture techniques sit at the heart of Android banking fraud. The Android Banking Trojans Guide covers families and fraud flows in depth; the techniques that matter for overlay defence are:
- Credential capture (T1417.002 GUI Input Capture): a fake login screen appears over the target app and collects the username, password or card details.
- Accessibility abuse (T1453 Abuse Accessibility Features): once the user is persuaded to enable a malicious accessibility service, the malware can read screen content, capture input and act for the user. Android's restricted settings feature locks accessibility access for newly installed apps until the user explicitly allows it, which is why social engineering instructions to "allow restricted settings" appear in scam flows. See Mobile T1453 Abuse Accessibility Features.
- Input injection (T1516 Input Injection): malware taps through screens itself, for example approving a transfer or granting a permission, often while an overlay hides what is happening.
- Permission grant tricks: overlays have historically been used to steer users into granting further permissions, including SYSTEM_ALERT_WINDOW or device administrator rights. See Mobile T1516 Input Injection.
The common thread is that the fraud runs on the customer's own, already authenticated device. Server-side controls that assume a trusted session miss it, which is why overlay defence belongs in the app and transaction confirmation design, not only in a fraud engine.
Platform mitigations by Android version
Each release has narrowed overlay abuse. Versions and API levels below were checked against Android developer documentation and the AOSP framework source in November 2026. Many controls apply only when the app targets the relevant API level.
| Android version (API) | Change | What it means for defenders |
|---|---|---|
| 6 (23) | SYSTEM_ALERT_WINDOW must be granted by the user through a settings screen (Settings.ACTION_MANAGE_OVERLAY_PERMISSION) for apps targeting API 23 or higher; apps check with Settings.canDrawOverlays() | Overlay malware needs a user grant, so it relies on social engineering |
| 8.0 (26) | Apps using SYSTEM_ALERT_WINDOW must use TYPE_APPLICATION_OVERLAY instead of TYPE_PHONE, TYPE_SYSTEM_ALERT, TYPE_SYSTEM_OVERLAY and similar; these windows always appear under critical system windows such as the status bar and IMEs; users can block an app's alert windows from the notification shade | Overlays cannot cover the keyboard or status bar; users have a visible kill switch |
| 11 (30) | Custom toasts from the background are blocked for apps targeting API 30 or higher (a "toast burst" workaround remained) | Reduces the toast variant |
| 12 (31) | Untrusted touch events are blocked: touches passing through a TYPE_APPLICATION_OVERLAY or other untrusted window owned by another app are dropped, unless the overlay is invisible, fully transparent, or a system alert window with combined opacity at or below 0.8. Trusted windows include accessibility overlays and the input method. Background toasts and toast bursts fully mitigated. Window.setHideOverlayWindows() available | Full occlusion largely mitigated by default; partial occlusion and translucent overlays remain |
| 13 (33) | Restricted settings: accessibility access and other sensitive settings are locked for newly installed apps until the user chooses "Allow restricted settings" in App info | Adds friction for malware delivered outside app stores |
| 14 (34) | View attribute accessibilityDataSensitive: only accessibility services declaring android:isAccessibilityTool="true" can read or act on marked views. Setting filterTouchesWhenObscured in layouts implicitly enables it | Apps can wall off login and confirmation screens from abusive accessibility services |
| 16 (36) | accessibilityDataSensitive also blocks gestures injected with AccessibilityService.dispatchGesture by services that are not accessibility tools | Reduces automated tapping on protected views |
Two cautions. First, a device's Android version, not your targetSdkVersion, decides whether the platform protections exist at all: a customer on Android 11 has none of the API 31 changes. Second, platform behaviour differs between device makers and can change in monthly updates, so verify on the devices your customers use. The Android and Pixel Security Update Support tracker helps set a minimum supported version.
App-level defences
Apply these to every screen where a tap or a typed value has security or financial consequences: sign-in, step-up authentication, payment and transfer confirmation, adding a payee or device, changing recovery details, consent and permission prompts inside the app.
Hide overlays on sensitive screens
- Declare the permission: add android.permission.HIDE_OVERLAY_WINDOWS to the manifest. In AOSP it has protection level normal, so it is granted at install with no user prompt.
- Call Window.setHideOverlayWindows(true): in the sensitive activity (API 31 and later). The AOSP source describes it as preventing non-system overlay windows from being drawn on top of the window. Turn it off again when leaving the screen if the app legitimately coexists with overlays elsewhere.
- Trade-off: legitimate overlays such as chat heads, screen dimmers or accessibility helpers that use TYPE_APPLICATION_OVERLAY disappear while the screen is shown. Explain this in support material.
Filter obscured touches
- filterTouchesWhenObscured: set android:filterTouchesWhenObscured="true" in the layout, or setFilterTouchesWhenObscured(true) in code, on confirm buttons and input fields. The view then discards touches delivered while another visible window obscures it. On Android 14 and later this also enables accessibilityDataSensitive.
- Partial occlusion: in the view's touch handling, ignore events whose flags include MotionEvent.FLAG_WINDOW_IS_PARTIALLY_OBSCURED. Android warns this can disrupt users when a benign app causes the occlusion, so apply it to the few highest-risk controls only and show a message explaining why the tap was ignored.
- Custom policy: override View.onFilterTouchEventForSecurity() where you need finer logic, for example to log the event for fraud analytics before rejecting it.
Protect sensitive views from accessibility abuse
- Views: set android:accessibilityDataSensitive on credential fields, one-time code inputs and confirmation buttons (API 34 and later).
- Jetpack Compose: OWASP MASTG-BEST-0075 gives the semantics modifier with isSensitiveData = true for the equivalent effect.
- Accessibility users: genuine assistive services that declare isAccessibilityTool keep access, so this does not block screen readers that are real accessibility tools. Test with TalkBack. See Accessible Security.
Reduce what an overlay can achieve
- Export nothing you do not need: set android:exported="false" on activities that are not entry points, which addresses the activity sandwich variant.
- Bind confirmation to the server: show transaction details (payee, amount) on the confirmation screen and require a fresh, user-verified signature for high-value actions, for example a Keystore key that requires biometric authentication through BiometricPrompt, which is drawn by the system rather than the app.
- Prefer passkeys and system credential UI: Credential Manager and passkeys move credential entry into system UI and remove the password a fake screen would steal. See the Passwordless and Passkeys Guide.
- Feed signals to fraud detection: record when sensitive actions were attempted with obscured-touch flags set, when the device reports enabled non-system accessibility services, and Play Integrity verdicts, and use them in server-side risk scoring. See Mobile App Attestation.
Enterprise and MDM controls
On managed devices, the organisation can remove much of the attack surface before an app's own defences are needed. The Android Enterprise Security Guide covers the wider baseline.
| Control | Mechanism | Effect on overlay and accessibility abuse |
|---|---|---|
| Allowlist accessibility services | DevicePolicyManager.setPermittedAccessibilityServices(), called by a device or profile owner, or the equivalent setting in your UEM | Non-system accessibility services not on the list cannot be enabled by the user; an empty list allows only built-in system services |
| Block unknown sources | UEM policy disallowing installation from unknown sources in the work profile or on fully managed devices | Removes the main delivery route for overlay malware. See APK sideloading |
| Keep Google Play Protect on | UEM policy enforcing app verification | Scans installed apps for known malware |
| Minimum OS version | Compliance rule denying access below a chosen Android version or patch level | Ensures API 31 untrusted touch blocking and later protections exist |
| Mobile threat defence signals | MTD app reporting risky permissions and accessibility services to conditional access | Flags devices where an app holds SYSTEM_ALERT_WINDOW or an unexpected accessibility service. See the Mobile Threat Defense Buyer's Guide |
For consumer apps you cannot control the device, so the app-level defences and server-side risk signals carry the load.
Testing for tapjacking
- Inventory sensitive screens: list every activity and composable where a tap or entry authorises something. This list is the test scope.
- Static review: OWASP MASTG-TEST-0340 (References to Overlay Attack Protections, which supersedes the deprecated MASTG-TEST-0035) looks for setFilterTouchesWhenObscured, the filterTouchesWhenObscured layout attribute, onFilterTouchEventForSecurity, checks for FLAG_WINDOW_IS_OBSCURED or FLAG_WINDOW_IS_PARTIALLY_OBSCURED, and setHideOverlayWindows with HIDE_OVERLAY_WINDOWS. It maps to MASVS-PLATFORM-3 and weakness MASWE-0036. Automate the check in CI with a lint rule that fails a build when a sensitive layout lacks the attribute.
- Dynamic test on several versions: in an authorised test lab, use a purpose-built test harness app that draws overlays of varying opacity, and confirm protected views reject the touch on Android 11, 12 and the latest release. When Android 12 or later blocks a touch, Logcat records "Untrusted touch due to occlusion by" followed by the package name.
- Accessibility test: confirm that a test accessibility service without isAccessibilityTool cannot read or act on views marked sensitive on Android 14 and 16, and that TalkBack still works.
- Exported component review: confirm no sensitive activity is exported without need.
- Regression gate: repeat the static check on every release and the dynamic test on each new Android major version. See the Mobile App Security Testing Guide.
Rollback: if partial-occlusion rejection or overlay hiding causes support calls from users of legitimate overlay apps, narrow the scope to fewer views behind a remote configuration flag rather than removing the control entirely.
Measures that show it is working
- Coverage: percentage of sensitive screens with overlay hiding or touch filtering, and with accessibilityDataSensitive, measured from the static check.
- Blocked events: count of sensitive actions rejected because of obscured-touch flags, per app version and Android version.
- Risk signal rate: share of high-value transactions from devices reporting enabled non-system accessibility services.
- Fraud outcome: confirmed account takeover or authorised-push-payment cases linked to on-device malware, before and after rollout.
- Usability cost: support tickets citing ignored taps or hidden overlays.
Common failure patterns
- Relying on Android 12 alone: the default protects full occlusion only, ignores translucent overlays up to 0.8 combined opacity, and does nothing for customers on older devices.
- Protecting the login screen but not the confirmation: malware waits for the transfer or payee approval screen. Every authorising tap needs the same protection.
- Touch filtering without accessibility protection: modern banking malware drives the app through an accessibility service, which touch filtering does not stop. Add accessibilityDataSensitive and server-side signals.
- Applying partial-occlusion rejection everywhere: users with screen dimmers or chat heads find the app unusable and the control gets removed. Apply it narrowly.
- Exported activities: a sensitive activity exported for convenience lets another app launch and cover it.
- Password-only sign-in: a fake login screen captures a reusable credential. Passkeys and system biometric prompts give the overlay nothing to steal.
Framework mapping
| Framework | Reference | Relevance |
|---|---|---|
| OWASP MASVS v2 | MASVS-PLATFORM-3 | Secure use of the user interface, including overlay protections |
| OWASP MASTG | MASTG-TEST-0340; MASTG-BEST-0040 Preventing Overlay Attacks; MASTG-BEST-0075 Restricting Accessibility Service Access to Sensitive Views | Test and best-practice references |
| MITRE ATT&CK for Mobile v20 | T1417.002 GUI Input Capture; T1453 Abuse Accessibility Features; T1516 Input Injection | Attacker techniques the controls address |
| CWE | CWE-1021 Improper Restriction of Rendered UI Layers or Frames | Weakness class for UI redressing |
Practitioner checklist
- List every screen where a tap or entry authorises sign-in, payment, payee, recovery or consent.
- On those screens, declare HIDE_OVERLAY_WINDOWS and call setHideOverlayWindows(true) for API 31 and later.
- Set filterTouchesWhenObscured on every authorising control, and reject FLAG_WINDOW_IS_PARTIALLY_OBSCURED on the highest-risk few.
- Mark credential, code and confirmation views with accessibilityDataSensitive, or isSensitiveData in Compose.
- Set android:exported="false" on every activity that is not an entry point.
- Confirm high-value actions with a system-drawn BiometricPrompt bound to a Keystore key, and offer passkeys.
- Send obscured-touch, accessibility service and Play Integrity signals to server-side fraud scoring.
- On managed devices, allowlist accessibility services, block unknown sources and enforce a minimum Android version.
- Add MASTG-TEST-0340 checks to CI and test protected screens on Android 11, 12 and the latest release.
Standards and references
- Android Developers: Tapjacking
- Android Developers: Behaviour changes in Android 12, untrusted touch events
- Android Developers: Android 8.0 behaviour changes, alert windows
- AOSP: Framework permission definitions (HIDE_OVERLAY_WINDOWS, SYSTEM_ALERT_WINDOW)
- OWASP MASTG: MASTG-TEST-0340 References to Overlay Attack Protections
- OWASP MASTG: MASTG-BEST-0040 Preventing Overlay Attacks
- OWASP MASTG: MASTG-BEST-0075 Restricting Accessibility Service Access to Sensitive Views
- Google Android Help: Allow restricted settings
Related NHI Mgmt Group resources: Android App Security Guide · Android Banking Trojans Guide · Mobile Malware Guide · Mobile App Permissions