From 974de956da25167762f8bf1ea153cf4c47763692 Mon Sep 17 00:00:00 2001 From: Bernardo Rufino Date: Tue, 22 Oct 2019 11:53:42 +0100 Subject: [PATCH] Make toasts non-clickable Since enforcement was only on client-side, in Toast class, an app could use reflection (or other means) to make the Toast clickable. This is a security vulnerability since it allows tapjacking, that is, intercept touch events and do stuff like steal PINs and passwords. This CL brings the enforcement to the system by applying flag FLAG_NOT_TOUCHABLE. Test: Working on CTS test Test: Construct app that uses reflection to remove flag FLAG_NOT_TOUCHABLE and log click events. Then: 1) Observe click events are logged without this CL. 2) Observer click events are not logged with this CL. Bug: 128674520 Change-Id: Ic36585bc4f186e0224f5b687c49c0b3d9266838c --- services/core/java/com/android/server/wm/DisplayPolicy.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java index 10d48c4d5282b..a1d6df94fb542 100644 --- a/services/core/java/com/android/server/wm/DisplayPolicy.java +++ b/services/core/java/com/android/server/wm/DisplayPolicy.java @@ -860,6 +860,8 @@ public class DisplayPolicy { if (canToastShowWhenLocked(callingPid)) { attrs.flags |= WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; } + // Toasts can't be clickable + attrs.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE; break; }