Without further ado, here's Slava. Hello, everyone. Thank you for attending this talk. Today I'm going to compromise Android sandbox through a new disk attack surface. I will show how the simplest Android app like Hello World can attack another app through external storage and gain possibilities for silent app installation, denial of service attack of preinstalled apps, or even code execution in context of system or popular apps. I'm Slava from Check Point and I'm working at Check Point and vulnerability research and revenue engineering. So let's begin with Android security basics, of course. Android application is highly fortified IT and Android implements the concept of application sandbox to isolate execution of one app from others. And this simplified model shows following things. Android application has its own process and private storage accessible for this application only. And the second, communication between apps are limited by Android framework. So each application has its individual permissions and Android application sandbox just prevents escalation of privilege attacks between them. Android frameworks provide hundreds of permissions. To permit application access to user data or system features. And all these permissions can be grouped to three categories. Normal and dangerous permissions can be granted by a user to an app and permit access to his SMS contacts and storage. Preinstalled apps which are shipped with a device have more extended permissions. And the most privileged applications are assigned with a ROM signature or associated with some Android component like media or radio or something else. So it will be fine to find a way for a low privileged app from the first category to attack another apps from the second or third category and try to gain some privileges. And so and that's it. There are a lot of types of attacks of one app to others. But today I'm going to talk about storage based. So what about Android application storage of course. Android apps has, there are three types of Android app storage. So internal storage is built-in memory. All is available and accessible and private for each app. No one can get access for the app internal storage, except the app itself. Another way, another site, is external storage. External storage is partition via internal storage, but shared between all apps. Removal storage is actually SD card. can be extracted from a device and world accessible as well. From the app perspective, external and removable storage are the same thing. And Android framework provides one API for both of them. Why Android needs an external storage at all? First of all, users want to transfer, want to share their media data like photo, video, audio data between apps and transfer this data to the PC. Plus, all devices are limited in internal storage but should be supported as well. But no reason to save any sensitive internal apps information in the external storage. How it's difficult for a specific device to be able to transfer data to the PC. The third way to get storage access is really simply an app can ask the user for storage permissions in the same way as any other permission and gain global application access, global storage access. And it should be noted that each app can locate in the external storage slightly more protected directory for preventing of internal file observing. And it should be noted that each app can locate in the external storage slightly more protected directory for preventing of internal file observing. But if a third party app has global storage access, it can read and write any files inside of this directory as well. Let's look at possible disk attack scenarios on application sandbox. And most popular external storage usage scenarios are downloading of some data to external storage and after that transferring this data and then I mean extract, decompress to internal storage. And the second scenario is application holds maintained working data on external storage without any transferring at all. Both these communication scenarios can be hijacked. So any third party app can rewrite any file located in external storage providing disk attack. So I will show that even one data file overwritten in the external storage can lead to crash of Android application native library. And as you know, the crash is the first step for the code execution inside of attacked apps. The most challenging part of the first scenario is detect the moment when actually downloaded file should be overwritten. It's really right after the file downloading. To resolve this problem, file observing tech techniques can be used. And Android application is mostly Java and maybe it's native code. So Android Java framework provides file observer component for file observation. Or observing native part can be implemented using inotify syscalls. And in case of private app directory in external storage, when inotify-based application is used, it can be used. And in case of private app directory, methods would not work. But polling methods based on timers will get the job done always. Let's get several examples of disk attack. But I discovered much more. And for this presentation, I took several excerpts from Android security guides for application developers to show that it's not enough to write a guide to provide anything. And to do that, you need to write a security gaps. And even biggest Android vendors don't follow the proposed rules. The first excerpt is you should perform input validation when handling data from external storage. Okay, validation is quite simple. Google Translate holds its offline translation packages on external storage. So any third-party app can generate a rogue file and overwrite the original file in the external storage associated with Google Translate and to crash native library of this app. Because this library handles files located in external storage and associated with Android Translate in Google Translate application. I will show a quick demo video. Here you can see that I will show just the files located in the external storage. I started my Hello World application and just overwrite it without any observer to files to work one. And in moment when the translator gets back to work, I will show you how it works. I will show you how it goes to translate first later. It will be crashed. That's it. Thank you. The same story with Yandex Translator, most popular Russian translator, but another library, LibMobile, Android, so is compromised. I think that everybody knows OK Google application. OK Google. So it's actually a little bit complicated. I think that everybody knows OK Google application. Back in 2010 there was a Google voice assistant and Google was essentially app to download offlineIN speech recognition files through external storage without any verification, so immediately prior to the crash, leave google speech and ISO again, correct. I will not show all my demo videos. I prepare a lot of video. But this does need to dismissation file and links to all of that. The next excerpt, you should not store executable files on external storage. Really? LG has its own app stores for applications associated with LG devices. And LG application manager is actually LG App Box client system app. Responsible for updating, downloading, installing of such updates on all LG phones. So it means that the app downloads updating Android package file through external storage and installs from external storage. This means that disk attacker can override such updates and install any app in any moment that he wants on all LG phones. It's quite simple. So I also, I will show another example. Demo with LG. So I just start my whole world application and okay, let's hack app manager. And I'm sure that user, for example, not going to update application. He's going to install some LG related application. For example, FM radio. Okay, I want to install my FM radio. But instead of FM radio, right now, I have installed some other application. Quite simple. The same story with another LG related system app, which is responsible for displaying themes and files on all LG phones. Downloads self-update through external storage. And again, same story. I can override this file and install another app without any problem. Quite simply. And another excerpt. Okay. You should sign and verify signature of all files located in external storage. Okay, understood. Google text-to-speech. Again, all phones in the world. And downloads voice packet in archive to external storage. Verifies signature. Okay. And decompress such files to the internal storage. It looks nice. We have the signature. Okay. So I'm going to show you how to do it. So I'm going to show you how to do it. Signature, verification, not signature. But, but, but. The second and third part of the algorithm are not atomic action. This means that an attacker can override file after verification. What is the problem with this? Okay. And again, internal application, internal native library under attack. Another example. Xiaomi browser downloads self-update. external storage, verify SHA-1 hash, and install the update. Again, we can overwrite this file after verification. You might be wondering how is it possible to infiltrate in the exact moment when update was verified, but installation has not yet begun. So I'll show that in this example, for example, as installation and verification are to separate and manually invoke actions. So I'm going to update browser. And okay, slow world application. Let's talk it. And I'm going to update Sharmie browser and update button. The moment when user press update button, there's going to be some information about that, so I'll show how to do that. And we'll button, download, and verifications will be done. And after that, we have another button, install. Okay. So I'm attacker. I have a lot of time to install between verification and installation. I quite simple to write this file and then again install my model. No problem. To summarize, any App can override any file located in external storage and Android has no relevant protection to offer. And many high privileged and popular apps transfer and holds their data through external storage. It allows a lot to enable the user to use the manager disk attacker, various attack possibilities and, of course, compromises Android application sandbox. I have a few minutes, so let's look at how to find your manager disk vulnerability. When first approaching this problem, I was quite surprised that very little work in this field exists and I could not find any further automation tool to help me with my investigation and my decision was to prepare my own setup and so the research target is native library application, native library, a sole file because I'm going to crash C code but not Java and if such library, Android application library, handles in any way controllable file, this application can be attacked. In our case, the controllable file is file located in the network and the application can be attacked. The application can be attacked and in our case, the the external storage. In a moment, once a suitable native library and storage-based file found, I'm going to implement my simple Java program to reproduce the attack flow. The attack flow means that loading parsing of the storage file. All this implemented code does is just loading of targeted library and calling of one, two functions from the one and that's it. And after that, parsing of the prepared Java program is start. This is real-time examples of adapters which I used to find vulnerability in Google hand writing or Yandex search and you're welcome to try them. And so in this example, I'm using a simple adapter. And at this point, I just want to stress that adapter is very simple. It's a very simple program. So I have an adapter. But how to fuzz? And I prepared fuzzing setup based on the Linux counterparts. It's famous American fuzz loop and fuzzer and QEMU emulator. And I get the possibility to fuzz Android application native libraries. The preparation poses several challenges and I required many patches throughout of the listed here. Unfortunately my time is up. But I will happy to supply any additional information about this tool stack to everybody who is interested. And of course you can download this as a open source tool and I will open this link and try to find your own disk vulnerability. Thank you. Thank you.