Cloak & Dagger
From Two Permissions to Complete�Control of the UI Feedback Loop
Yanick Fratantonio
joint work with�Chenxiong Qian, Simon Chung, Wenke Lee
Black Hat USA 2017
July 27th, 2017
Who am I?
Who am I?
Who am I?
What is this work about?
UI Feedback Loop
Output channel
Input channel
Know what is currently displayed to the user
Modify what the user sees
Know what the user is clicking on
Inject user input
Cloak & Dagger Attacks
Why should I care about UI bugs? ACADEMIC BS!
BH USA 2017 talk
“Honey, I shrunk the attack surface – Adventures in Android security hardening”�(by Nick Kralevich)
Good stuff!
Why should I care about UI bugs? ACADEMIC BS!
BH USA 2017 talk
“Honey, I shrunk the attack surface – Adventures in Android security hardening”�(by Nick Kralevich)
Good stuff!
Why should I care about UI bugs? ACADEMIC BS!
BH USA 2017 talk
“Honey, I shrunk the attack surface – Adventures in Android security hardening”�(by Nick Kralevich)
Good stuff!
Two Permissions
Run-time Granting Permissions
Apps targeting Android SDK level 23 or higher
SYSTEM_ALERT_WINDOW (“draw on top”)
BIND_ACCESSIBILITY_SERVICE (a11y)
These two permissions are enough to completely compromise your device
Why would a user grant these permissions?
Why would a user grant these permissions?
Why would a user grant these permissions?
The list of permissions is not even shown!
Security Mechanisms
Security Mechanism #1
1) The click is “captured” by the overlay
2) The click goes “through” the overlay
Security Mechanism #1
1) The click is “captured” by the overlay
2) The click goes “through” the overlay
Security Mechanism #1
Security Mechanism #1
Security Mechanism #1
Security Mechanism #2
Security Mechanism #2
Security Mechanism #3
Clickjacking 101
Click here
UI Redressing Attacks on Android Devices Revisited
Niemietz & Schwenk�BH ASIA 2014
Security Mechanism #3
Security Mechanism #3
“Because an app is obscuring a permission request, Settings can’t verify your response.”
Security Mechanism #4
“Since an event contains the text of its source privacy can be compromised by leaking sensitive information such as passwords. To address this issue any event fired in response to manipulation of a PASSWORD field does NOT CONTAIN the text of the password.”
Unleashing Mayhem
Attack: Context-aware Clickjacking
Attack: Context-aware Clickjacking
Attack: Context-aware Clickjacking
Attack: Context-aware Clickjacking
Target Button
Target Button
Clicks do NOT go through
Clicks go through
(100,100)
(200,300)
(0,0)
Obscured Flag Bypass
Obscured Flag Bypass
Obscured Flag Bypass
Capture?
Context-Hiding Attack
Attack: Context Hiding
Attack: Context Hiding
Context-aware clickjacking + Context hiding
Back to the “obscured flag”...
Back to the “obscured flag”...
FLAG_WINDOW_IS_OBSCURED docs
“This flag indicates that the window that received this motion event is partly or wholly obscured by another visible window above it.”
FLAG_WINDOW_IS_OBSCURED docs
/**
* This flag indicates that the window that received this motion event is partly
* or wholly obscured by another visible window above it. This flag is set to true
* even if the event did not directly pass through the obscured area.
* A security sensitive application can check this flag to identify situations in which
* a malicious application may have covered up part of its content for the purpose
* of misleading the user or hijacking touches. An appropriate response might be
* to drop the suspect touches or to take additional precautions to confirm the user's
* actual intent.
*
* Unlike FLAG_WINDOW_IS_OBSCURED, this is actually true.
* @hide
*/
public static final int FLAG_WINDOW_IS_PARTIALLY_OBSCURED = 0x2;
Same as FLAG_WINDOW_IS_OBSCURED
“Unlike FLAG_WINDOW_IS_OBSCURED, this is actually true.
Back to the “obscured flag”...
Attack: Invisible Grid Attack
Attack: Invisible Grid Attack
Attack: Invisible Grid Attack
1
3
4
Overlays are drawn
2
Attack: Invisible Grid Attack
1
2
3
4
Overlays are drawn
Attack: Invisible Grid Attack
MotionEvent
1
2
3
4
Overlays are drawn
1
2
3
4
Overlay #
MotionEvent
MotionEvent
MotionEvent
Where did the user click?
Attack: Invisible Grid Attack
MotionEvent
1
2
3
4
Overlays are drawn
1
2
3
4
Overlay #
MotionEvent
MotionEvent
MotionEvent
The “obscured” flag is set accordingly!
Not obscured
Not obscured
Not obscured
Not obscured
Where did the user click?
Attack: Invisible Grid Attack
MotionEvent
1
2
3
4
Overlays are drawn
1
2
3
4
Overlay #
MotionEvent
MotionEvent
MotionEvent
The “obscured” flag is set accordingly!
Obscured
Not obscured
Not obscured
Not obscured
Where did the user click?
Attack: Invisible Grid Attack
MotionEvent
1
2
3
4
Overlays are drawn
1
2
3
4
Overlay #
MotionEvent
MotionEvent
MotionEvent
The “obscured” flag is set accordingly!
Obscured
Not obscured
Not obscured
Obscured
Where did the user click?
Attack: Invisible Grid Attack
MotionEvent
1
2
3
4
Overlays are drawn
1
2
3
4
Overlay #
MotionEvent
MotionEvent
MotionEvent
The “obscured” flag is set accordingly!
Obscured
Not obscured
Obscured
Obscured
Where did the user click?
Attack: Invisible Grid Attack
1
2
3
4
Security mechanism used as side-channel!
The attacker can use these patterns to infer where the user clicked!
Attack: Invisible Grid Attack
These overlays are drawn invisible during a real attack
Design Shortcomings
Attack: a11y on steroids
Attack: a11y on steroids
1) Steal PIN
2) Inject PIN and unlock the phone!
Bonus point: phone unlock while keeping the screen off!
Cloak & Dagger attacks
Traditional Phishing
<username>
<password>
Login
<username>
<password>
Login
Traditional Phishing
<username>
<password>
Login
<username>
<password>
Login
Didn’t I click login???
JohnDoe
L33tP4ss
Login
Attack: Stealthy Phishing
<username>
<password>
<password>
<username>
Login
Login
JohnDoe
L33tP4ss
<username>
<password>
JohnDoe
L33tP4ss
Login
Filled�by a11y
Clicked by a11y
Welcome, John!
Great!
UI-in-the-middle
Attack
Attack: Silent God-mode App Installation
Attack: Silent God-mode App Installation
Attack: Silent God-mode App Installation
Additional Attack Scenarios
Additional Attack Scenarios
Additional Attack Scenarios
Clickjacking ~> a11y & Silent God-mode App Install
Ransomware Example
Are these attacks actually practical?
User Study
Results
Results
Results
Overall Awareness
Overall Awareness
How can we fix this?
Responsible Disclosure
Responsible Disclosure
Responsible Disclosure
Responsible Disclosure
Disclosure of “a11y on steroids” (August 22nd)
a11y documentation “patch”
a11y documentation “patch”
a11y documentation “patch”
Responsible Disclosure
Responsible Disclosure
Responsible Disclosure
Few classes of vulnerabilities will generally not qualify for a reward:
Android Rewards�Qualifying Vulnerabilities
Responsible Disclosure
Responsible Disclosure
Responsible Disclosure
All attacks are still working!�(Even on Android 7.1.2, with July’s updates)
How is the Android security team reacting?
“I’m not alone”
“I’m not alone”
“There are also plain boring bugs, for example in the UI [...], personally I don’t report them anymore because you just don’t care. My bugs are hanging with the ‘new’ status for years then they are just auto-closed.”
Securing Android UI
What happened next...
Google’s official answer
“[...] We have updated Google Play Protect — our security services on all Android devices with Google Play — to detect and prevent the installation of these apps. Prior to this report, we had already built new security protections into Android O that will further strengthen our protection from these issues moving forward.”
Detect Cloak & Dagger
Detect Cloak & Dagger
Detect Cloak & Dagger
Bootstrap the attacks from one permission
Bootstrap the attacks from one permission
Bootstrap the attacks from one permission
Clickjacking Everywhere!
Let’s go one step further...
Let’s go one step further...
Let’s go one step further...
FTW!
FTW!
FTW!
sed -i “s/TYPE_SYSTEM_ALERT/TYPE_TOAST/” *
Impact & Caveats
Impact & Caveats
Android O (Preview 3 developer version)
Android O (Preview 3 developer version)
Android O (Preview 3 developer version)
Android O (Preview 3 developer version)
Clickjacking ~> a11y seems fixed in Android O Preview 4!!�(released few days ago :-))
Fixing clickjacking might be trickier than expected...
An Android 6.0-only bug prevents granting permissions when Twilight is on (fixed in Android 7+)
Current state of Android security updates
Stuck with Android 6.0.1
Current state of Android security updates
$649
$769
Takeaways
Takeaways
Takeaways
Takeaways
Conclusions
Yanick Fratantonio
yanick@cs.ucsb.edu
@reyammer