00:00:00.133-->00:00:05.138 >> And without further ado, here’s Slava. >> Hello everyone. Thank you for attending this 00:00:07.975-->00:00:12.980 talk. Today I’m doing - going to compromise Android sandbox through a new Man-In-The-Disk 00:00:15.382-->00:00:20.387 attack surface. I will show how the simplest Android app, like Hello World, can attack an app 00:00:24.291-->00:00:30.130 through external storage and gain possibilities for silent type installation, denial of 00:00:30.130-->00:00:35.135 service attack of preinstalled apps, uh, or even code execution in conteXt of um system or 00:00:38.639-->00:00:43.644 popular apps. Uh, I - I’m - I’m Sl - Slava from Check Point and, uh, I work at Check Point and 00:00:51.985-->00:00:56.990 vulnerability research and reverse engineering are my daily work. So let’s begin this 00:00:59.293-->00:01:04.231 Android security basics of course. Android application is highly fortified I think and 00:01:07.668-->00:01:12.673 Android implements a concept of application Sandbox to delay execution of one app from others 00:01:15.042-->00:01:20.047 and this simplified model shows, uh, few different things. Uh, Android, uh, application has its 00:01:23.817-->00:01:28.822 own, uh, process and private storage accessible for this application only. And the 00:01:30.891-->00:01:35.896 second, communication between apps are limited by Android framework. So, each application 00:01:39.066-->00:01:45.372 has its indiv - individual permissions and Android application Sandbox, uh, just 00:01:45.372-->00:01:50.377 prevents escalation of privilege attacks between them. Android frameworks provides hundreds of 00:01:53.613-->00:01:58.618 permissions, uh, to permit application access to user data or system features and all these 00:02:01.588-->00:02:07.627 permissions can be grouped to 3 categories. Uh, normal and dangerous permissions can be 00:02:07.627-->00:02:12.633 granted by a user to an app to - and permit access to his SMS, contacts and to storage. 00:02:17.771-->00:02:23.977 Preinstal, uh, preinstalled apps which are synced to the device, uh, have more extended 00:02:23.977-->00:02:30.884 permission such as, such as change font settings or silent type installation. And the most 00:02:30.884-->00:02:37.290 privileged applications are signed or ROM signature or associated with some Android 00:02:37.290-->00:02:42.295 component like media or radio or something else. Uh, so to find - to find the way for low 00:02:47.401-->00:02:54.274 privileged app from the first category, uh, to attack another apps from the second or third 00:02:54.274-->00:02:59.279 category and try to gain, uh, some privileges and so, and, that’s it. Uh, there is a lot of 00:03:04.518-->00:03:09.523 types of attacks of one app to others but to - today I’m going to talk about storage based. So, 00:03:17.130-->00:03:22.135 what about Android application storage, of course. Uh, Android apps has uh, there are 3 types 00:03:24.604-->00:03:31.211 of Android app storage and so internal storage is built in memory, always available and - 00:03:31.211-->00:03:36.216 and accessible and - and private for each app. No one can get access for the app internal 00:03:39.219-->00:03:45.926 storage except the app itself. Another way, another type, external storage. External 00:03:45.926-->00:03:50.931 storage is partition in internal storage but shared between all apps. Removable storage is 00:03:53.800-->00:03:59.072 actually the cartridge can be extracted from the device and, uh, world accessible as well. 00:03:59.072-->00:04:04.010 From the app perspective, uh, external and removable storage, uh, are, uh, the same thing and, 00:04:08.048-->00:04:13.053 uh Android framework provides one API for both of them. Why Android needs an external at 00:04:16.223-->00:04:21.228 all. First of all, users want to transfer, uh, they want to share their media data like photo, 00:04:24.464-->00:04:29.469 video, audio data between the apps and, uh, and transfer these data to the PC. Plus old devices 00:04:32.839-->00:04:37.844 are limited in internal storage, uh, but supported as well but not reason to save any sensitive 00:04:40.113-->00:04:45.118 internal apps information in the external storage. How it’s difficult for, uh, a third party 00:04:48.722-->00:04:53.727 app, uh, to get, uh storage access is really simply - an app can ask, uh, the user for, uh - 00:04:57.531-->00:05:02.469 uh for storage permission a - a - the same way as any other permission and gain global 00:05:05.839-->00:05:11.912 application access, global storage access. And it should be noted that each app can allocate 00:05:11.912-->00:05:17.617 in the external storage slightly more protected directory for, uh, preventing internal 00:05:17.617-->00:05:22.622 observing but if a third party app, uh, has global storage access, it can read and write 00:05:25.192-->00:05:30.197 any files inside it, uh, of this directory as well. Let’s look at possible Man-In-The-Disk attack 00:05:34.367-->00:05:41.341 scenarios on application Sandbox. And most popular are external storage user scenarios. 00:05:41.341-->00:05:46.346 Uh, downloading of some data to external storage and after that transferring this data and 00:05:48.448-->00:05:54.221 extract to compress to internal storage. And the second scenario, uh, application holds 00:05:54.221-->00:06:00.927 maintain its working data on external storage without any transferring at all. Both these 00:06:00.927-->00:06:07.567 communication scenarios can be hijacked. So any third party app can overwrite any file located 00:06:07.567-->00:06:12.572 in external storage providing them a disk attack. Uh, so I will show that the - even one 00:06:15.442-->00:06:22.015 data file overwritten on external storage can lead to crash of Android application and 00:06:22.015-->00:06:27.020 it’s library and as you know the crash is the uh first step for the code execution inside of, 00:06:30.924-->00:06:35.929 uh, attacked apps. The most challenging part of the first scenario is detect the moment 00:06:37.964-->00:06:43.670 when actually downloaded file should be overwritten. It’s really, uh, right after the file 00:06:43.670-->00:06:48.675 downloading. To resolve this problem, uh, file observing techniques can be used and, uh, 00:06:52.912-->00:06:57.917 Android application is mostly java and, uh, virtual uh maybe. Its native code so Android java 00:07:00.553-->00:07:06.326 framework provides file observer [indiscernible] for file, uh, for file observation or 00:07:06.326-->00:07:12.999 observing the native part can be implemented to use an Inotify syscalls. And in case of private 00:07:12.999-->00:07:18.004 observing in external storage when Inotify based, uh, methods would not work but polling 00:07:20.674-->00:07:25.679 methods based on timers will get the job done always. Let’s get several examples of 00:07:28.915-->00:07:33.920 Man-In-The-Disk, uh, attack. Uh, but, I discover it much more, the - and the, uh, for this 00:07:36.656-->00:07:42.395 presentation I uh, uh, I took several excerpts from Android security guides for application 00:07:42.395-->00:07:49.336 developers to show that it’s not enough to write the guide to prevent any, uh, any security 00:07:49.336-->00:07:56.176 gaps. And even biggest Android vendors, uh, don’t follow the proposed rules. The first 00:07:56.176-->00:08:01.114 excerpt, uh, you should perform input validation when handing data from external storage. Ok, 00:08:03.149-->00:08:08.154 validation is - is quite simple. Google translate holds its offline translation packages on 00:08:10.657-->00:08:17.030 external storage. So, any certain app can overwrite, can generate rogue file and 00:08:17.030-->00:08:23.603 overwrite the regional file in, uh, the external storage. Uh, I should say it with uh, Google 00:08:23.603-->00:08:28.608 translate and to crash native library of this app. Libtranslate is, uh, itself a 00:08:31.411-->00:08:37.851 native library. Because this library, uh, handles parses, files located in external 00:08:37.851-->00:08:42.856 storage and associated with, uh, Android translate in, uh, in Google translate application. I 00:08:45.592-->00:08:50.597 will show a quick demo video. Here - here you can see that, uh, I will show just the, uh, 00:08:58.071-->00:09:03.009 files located in the external storage and, uh, what’s readable. I started my hello 00:09:06.713-->00:09:11.718 world application and, uh, and just over the right it is obtained the observer two files 00:09:16.689-->00:09:21.694 to work on and in moment when, uh, translator, uh, goes to, uh, translate this later you’ll be 00:09:27.901-->00:09:34.874 crashed. That’s it. [applause]. Thank you. The same story with Yandex translator. Most popular 00:09:34.874-->00:09:41.781 Russian translator but and - and another library, uh, Libmobile Android so is, uh, is - is 00:09:41.781-->00:09:47.220 compromised. I think that everybody knows ok Google application. Ok Google, so it’s 00:09:47.220-->00:09:52.592 actually Google voice assistant and, uh, Google voice assist is the app downloads offline speak 00:09:52.592-->00:09:57.630 recognition files through external storage without any verification. So, uh, 00:09:57.630-->00:10:04.471 Man-In-The-Disk attack can overwrite search files and to crash Libgoogle speech jni so 00:10:04.471-->00:10:11.411 again, it crashes. I will not show all of my demo videos. I will, uh, I prepared, uh, a lot 00:10:11.411-->00:10:17.250 of videos but this PDF presentation file will links to all of them. The next excerpts, 00:10:17.250-->00:10:23.656 you should not store executable files on external storage. Really? [laughter]. LG - LG, uh, 00:10:23.656-->00:10:28.661 has its own app stores for, uh, application associated with LG devices and, uh, LG application 00:10:32.866-->00:10:37.871 mana - manager is actually LG appbox client system app is high privileged. Uh, responsible for 00:10:42.108-->00:10:47.113 downloading, installing of such updates on LG, uh, LG telephones. So it means that, 00:10:50.049-->00:10:56.222 uh, but the app downloads, uh, updating, uh, Android package file through external storage 00:10:56.222-->00:10:59.959 and installed through, uh, installs from external storage. This means that Man-In-The-Disk 00:10:59.959-->00:11:06.132 attack, uh, can overwrite such updates and install any app, any, uh, in any moment what he 00:11:06.132-->00:11:11.137 wants on all LG phones. Quite simple. So, I will show - I will show another demo with LG. So, I 00:11:17.777-->00:11:22.782 just start my Hello World application and ok, let’s hack app manager and I - I - I’m sure 00:11:25.685-->00:11:30.690 that the user for example, uh, not going to update application but he wants to install some, 00:11:33.359-->00:11:38.364 uh, LG related application. For example, FM radio. Ok, I - I want to install FM radio but 00:11:41.467-->00:11:46.472 instead of FM radio right now I have installed some other application [applause]. Quite 00:11:49.876-->00:11:54.881 simple. Thank you. The same story with another LG - LG related system app which is, uh, 00:11:59.652-->00:12:04.490 which - which is responsible for displaying themes and for phones, on LG phones, downloads 00:12:04.490-->00:12:08.795 update through external storage and again same story. I can overwrite this file and install 00:12:08.795-->00:12:13.800 another app without, uh, any problem. Quite simply. And another excerpt. Ok, you should 00:12:16.269-->00:12:22.308 sign and verify signature of all files created in external storage. Ok, understood? Uh, 00:12:22.308-->00:12:27.313 Google text-to-speech. Again, all phones in the world, and, uh, downloads a voice packet in 00:12:31.117-->00:12:36.122 archive to, uh, to external storage, verify signature, ok, and, uh, decompress such files 00:12:38.925-->00:12:44.330 to the internal storage. It looks nice. We’ll have, uh, signature - verification of 00:12:44.330-->00:12:49.335 signature but - but - but, uh the second and third part of the, uh, second and third part 00:12:52.538-->00:12:58.945 of the algorithm, uh, are not automatic actions, this means that an attacker can overwrite 00:12:58.945-->00:13:02.682 file after verification [laughter]. What is the problem with this? Ok, and again, 00:13:02.682-->00:13:07.687 internal application, uh, internal native library under attack. Another example, Xiaomi 00:13:10.556-->00:13:17.163 browser downloads self-update to external storage, verifies the one hash and installs update. 00:13:17.163-->00:13:22.168 Again, uh, I - I - I - you can overwrite this file after verification. You might be 00:13:24.837-->00:13:31.711 wondering how’s it possible, uh, to integrate in the exact moment when file, when update, uh, was 00:13:31.711-->00:13:36.716 verified but, uh, has not, uh - uh, but installation, uh, has not begun. So I will show that 00:13:42.321-->00:13:47.326 this example for example, uh, installation and verification are 2 separ - separate and uh, 00:13:50.730-->00:13:55.735 and, manually inboxed actions. So I’m going to update browser and, ok, hello world application 00:13:59.105-->00:14:04.043 let’s - let’s hide. And, uh, I’m going to update, uh, Xiaomi browser and, uh, and in update 00:14:06.813-->00:14:12.485 button. In moment when user press update button, download and veri - verifications, we’ll 00:14:12.485-->00:14:17.490 be done. And after that we have another button, install. Ok, so I - I - I’m attacker. I have a 00:14:20.993-->00:14:26.966 lot of time to install, uh, between verification and installation. I - I quite simple 00:14:26.966-->00:14:33.106 to overwrite this file and, uh, again he stole my mobile, [laughter] no problem 00:14:33.106-->00:14:40.046 [applause]. Thank you. To summarize, any attack app can overwrite any file located in 00:14:40.046-->00:14:45.051 external storage and Android has no, uh, relevant protection to offer. And may high privileged 00:14:48.054-->00:14:53.059 and popular apps have, uh, transfer and hold their data through external storage. It - 00:14:56.095-->00:15:02.969 it allows, uh, a lot, uh to Man-In-The-Disk attack your wireless attack possibilities 00:15:02.969-->00:15:07.974 and of course comprise, uh, Android application Sandbox. I have a few minutes so let’s 00:15:11.611-->00:15:17.850 talk, uh, let’s look at how to find your Man-In-The-Disk vulnerability. When first 00:15:17.850-->00:15:22.722 approaching this program I - I was quite surprised that very little work in this field exists 00:15:22.722-->00:15:27.727 and, uh, I - I could not find any prior information to, uh, to uh, to - to help me with my 00:15:30.563-->00:15:37.203 investigation and - and I, uh, my decision was to prepare my own set up. And, uh, so, the - 00:15:37.203-->00:15:42.208 the research started easy, uh, native library. Application native library’s so file because 00:15:44.811-->00:15:51.317 I am going to crash C code but no java and, uh, if such library, Android application 00:15:51.317-->00:15:56.522 library handles in any way controllable file this application can be attacked. And 00:15:56.522-->00:16:02.461 now in case the controller file is - file located in, uh, in the external storage, uh, in moment, 00:16:02.461-->00:16:07.466 uh, once a suitable native library and, uh, storage based file found I’m going to 00:16:09.735-->00:16:15.708 implement my simple java program to reproduce attack flow. The attack’s flow just means that, 00:16:15.708-->00:16:20.713 uh, that the loading, uh, parse of the - of the storage file. It’s - all this implemented code 00:16:24.851-->00:16:29.856 does is just load in targeted library and call in 1 - 2, uh, functions from the one and, uh, 00:16:34.427-->00:16:39.432 and that’s it. And after that, uh, files in prepared java program, uh, is start. This is 00:16:42.201-->00:16:48.007 real-time, uh, examples of adapters which are used to find vulnerability. Uh, Google 00:16:48.007-->00:16:53.012 handwriting or Yandex search and uh, you’re welcome to try them and, uh, um, so in this point I 00:16:55.615-->00:17:01.654 just want to stress that, uh, adapter is quite - is very simple. It’s very simple 00:17:01.654-->00:17:06.626 problem. So I have an adapter but - but how to fuzz? And, uh, I prepare a fuzzing setup, uh, 00:17:08.895-->00:17:13.900 based on the Linux counterparts. It’s famous, uh, American fuzzing loop and, uh, fuzzer and 00:17:17.536-->00:17:22.541 QEMU in - in emulator and I get the possibility to fuzz Android application native libraries. 00:17:24.677-->00:17:29.682 The setup preparation poses several challenges and, uh, record many pages throughout all 00:17:32.718-->00:17:38.624 the listed here stack. Unfortunately, uh, my time is up but, uh, I would be happy to 00:17:38.624-->00:17:42.828 supply any additional information about this tool stack to everybody who is 00:17:42.828-->00:17:47.833 interested and, of course, you can download this as open - open source too and I - I will open 00:17:49.902-->00:17:54.907 this link and try to find your own Man-In-The-Disk vulnerability. Thank you 00:18:00.780-->00:18:02.915 [applause].