[00:00.000 --> 00:05.740] I'd like to introduce Or and Shmuel. Here we go. And away we go. [00:11.890 --> 00:19.850] Okay, hi everyone. Today we will present Quickshare. Sharing is caring about an RC attack [00:19.850 --> 00:27.950] chain on Quickshare. So, my name is Or Yair, I'm the security research team lead at Safe [00:27.950 --> 00:33.390] Breach. I have more than 6 years of experience in security research. My past research [00:33.390 --> 00:41.130] included some research on Linux environments, embedded devices, Android devices and more. And [00:41.130 --> 00:46.170] for more than 3 years now my main focus lies in vulnerability research in a Windows operating [00:46.170 --> 00:53.900] system and third party apps that run on it. Hi everyone, my name is Shmuel Cohen and I'm [00:53.900 --> 00:59.260] excited to be here today and present the finding of our recent research. A little bit about [00:59.260 --> 01:05.660] myself, I have 6 years of experience in the cyber security industry. Previously I conducted [01:05.660 --> 01:11.220] APT malware research within the checkpoint research group and currently I'm part of the [01:11.220 --> 01:15.680] Safe Breach original research team where I focus primarily on vulnerability research on [01:15.680 --> 01:25.840] various products. Okay, so let's see what we're going to talk about today. We'll start with [01:25.840 --> 01:32.400] what is Quickshare and why we chose it as our primary target for this research. We'll then [01:32.400 --> 01:39.820] move on to get a brief overview about the protocol that Quickshare uses. We'll then see the [01:39.820 --> 01:45.140] first research approach that we took for this research which is fuzzing. We'll see the [01:45.140 --> 01:50.420] research approach shift um that we took that led us to other vulnerabilities and we'll see the [01:50.420 --> 01:56.180] vulnerability discovery that um that we had, vulnerability discoveries that we had um [01:56.180 --> 02:02.300] based on these two approaches. Then we'll see how we managed to assemble a very [02:02.300 --> 02:09.680] unconventional and creative RCE attack chain from these vulnerabilities. And we'll conclude [02:09.680 --> 02:18.020] with takeaways and a link to the GitHub repository of all the tools that we created. So, what [02:18.020 --> 02:24.760] is Quickshare? Quickshare is Google's nearby file transfer solution for Android just like [02:24.760 --> 02:32.260] Apple's AirDrop. Quickshare was formerly known as NearbyShare and then last January at CES, [02:32.260 --> 02:38.760] Google and Samsung decided to combine their file sharing solutions into a single one and call it [02:38.760 --> 02:45.200] Quickshare. So, we know what the talk is about, but why did we even choose to target [02:45.200 --> 02:51.620] Quickshare? Last July, Google has officially released a Windows version of Quickshare for [02:51.620 --> 02:56.720] Windows, allowing to share files between Windows computers to any other device with [02:56.720 --> 03:03.160] Quickshare. An interesting fact from Google's announcement about Quickshare at CES is that [03:03.160 --> 03:08.860] they are working with leading PC manufacturers, just like LG, to expand Quickshare to Windows [03:08.860 --> 03:14.860] PCs as a pre-installed app, making Quickshare for Windows a much more attractive target. [03:16.720 --> 03:22.380] Moreover, Quickshare performs file transfers using several communication methods. It [03:22.380 --> 03:28.840] supports WebRTC, Bluetooth, Wi-Fi, NFC, Wi-Fi direct and even sending files over a Wi-Fi [03:28.840 --> 03:36.500] hotspot of one of the devices. As far as we knew, Quickshare was Google's first Windows app [03:36.500 --> 03:42.620] to use all these communication methods. In general, most of Google's services that are used [03:42.620 --> 03:49.240] on Windows are in the browser. This was a first of a kind for Google and thus chances for [03:49.240 --> 03:56.160] mistakes were higher. Looking for past research, the only one that we could really find was a [03:56.160 --> 04:00.720] research called Nearby Threats, reversing, analyzing and attacking Google's nearby [04:00.720 --> 04:06.240] connections on Android. The research analyzed Google's Nearby Connections API, that is the [04:06.240 --> 04:13.480] API that NearbyShare and later on Quickshare use in their implementations. And Quickshare and [04:13.480 --> 04:19.940] NearbyShare didn't even exist back then. It was just an API for third party applications. The [04:19.940 --> 04:29.100] Windows app did not exist also of course. Another interesting fact was that we saw that most of [04:29.100 --> 04:34.560] the applications code can be found in open source repositories by Google. It was not all of [04:34.560 --> 04:42.880] it, but some of it at least. And in addition, we just could not find any CVEs related to [04:42.880 --> 04:49.520] Quickshare. Concluding all of these facts together led us to evaluate Quickshare as a valuable [04:49.520 --> 04:58.380] and likely to be breached target. Our final goal was to achieve something that was never achieved [04:58.380 --> 05:06.960] using Quickshare. And that was remote code execution. Starting our journey, we needed to [05:06.960 --> 05:13.660] understand Quickshare's protocol of course. Therefore, the first thing we did was to find the [05:13.660 --> 05:20.540] most basic functions that Quickshare uses to send and receive packets. Once we find such [05:20.540 --> 05:25.460] functions, if they are generic and are used for all communication methods, then we'll be able [05:25.460 --> 05:32.120] to get a clear view of all packets that are being sent and received by the app in their binary [05:32.120 --> 05:38.440] form. Then, just as we needed, we found the read and write functions as part of a base class [05:38.440 --> 05:44.380] that was called base endpoint channel. Deeper inside the read function, we were able to [05:44.380 --> 05:49.300] understand that the packets that are being sent and received are packets of a type called [05:49.300 --> 05:55.380] offline frame. That is because each packet that was received was parsed into an [05:55.380 --> 06:02.980] offline frame object. But the offline frame object was not a normal object as its class was [06:02.980 --> 06:11.760] generated by protobuf. In here we can see the protobuf definition of offline frame. And using [06:11.760 --> 06:19.140] protobuf, this proto file is being compiled into CPP files that define the offline frame and [06:19.140 --> 06:26.400] provide functions to serialize it to bytes and deserialize it from bytes. But don't be [06:26.400 --> 06:32.540] alarmed by the name offline frame too much because offline frame is the base type for almost [06:32.540 --> 06:38.680] all packet types that we are going to discuss in this talk and so from now on we will just [06:38.680 --> 06:47.140] mostly call them packets instead of offline frames. And so, our first tool for this [06:47.140 --> 06:52.460] research was born pretty fast. We needed a tool that will provide us abilities to watch the [06:52.460 --> 06:58.060] communication. So we wrote a DLL that hooks the read and write functions and textually logs [06:58.060 --> 07:03.920] each packet that is being sent and received with all of its fields. This tool allowed us to [07:03.920 --> 07:09.480] understand the protocol much better and Shmuel will be the one to elaborate on what we learned. [07:09.480 --> 07:18.460] Thank you all. Cool. So now that we can sniff QuickShare packets, it's time to take a deep [07:18.460 --> 07:25.360] dive of the protocol used by QuickShare. So there's an API called Nearby Connections API and [07:25.360 --> 07:31.900] it's used to discover, connect and exchange data with nearby devices in real time regardless [07:31.900 --> 07:37.000] of network connectivity. QuickShare uses the Nearby Connections API with its own [07:37.000 --> 07:43.480] implementation. Let's start with reviewing the Nearby Connections API. So it's based on [07:43.480 --> 07:48.580] protobuf which is used to serialize structure data. It's mostly encrypted. The encryption is [07:48.580 --> 07:54.540] handled using Google's UK2 library. Each app is uniquely identified within the Nearby [07:54.540 --> 08:01.220] Connections API by a service ID that is provided by the app's developers. It has multiple [08:01.220 --> 08:07.660] connections strategies such as peer-to-peer, star and cluster. We will focus on the [08:07.660 --> 08:13.080] peer-to-peer strategy because it's the one used by QuickShare. In this strategy there's [08:13.080 --> 08:18.780] initiator and the responder functioning much like a client and server. In our protocol [08:18.780 --> 08:25.720] overview we will examine packets that send during a file transfer from a phone to a PC. The [08:25.720 --> 08:30.720] first stage of communication is a connection request packet. Following that the initiator [08:30.720 --> 08:36.920] start with encryption handshake. The encryption handshake starts by sending a UK client init [08:36.920 --> 08:43.680] packet to the responder. Then the responder replies with a UK server initialization packet [08:43.680 --> 08:50.020] and finally the initiator responds with a UK client finish packet. At this point the UK [08:50.020 --> 08:55.120] encryption handshake is successfully completed ensuring that all subsequent packets will be [08:55.120 --> 09:00.840] encrypted. Next the responder sends a connection response packet indicating that it's [09:00.840 --> 09:07.000] accepted the connection and the initiator responds with a similar packet back. At this point [09:07.000 --> 09:11.540] QuickShare proprietary communication begins. This proprietary communication uses various [09:11.540 --> 09:17.460] types of packets provided by the nearby connections API. Let's review some of those packets. [09:17.800 --> 09:23.960] So these packets as all mentioned are called offline frames. Here you can see all types of [09:23.960 --> 09:30.320] packets that can be used within the protocol. So far we've seen two types, the connection [09:30.320 --> 09:37.100] request and the connection response. In our talk we will focus on two types, payload transfer [09:37.100 --> 09:43.760] and bandwidth upgrade negotiation. Now let's explore how QuickShare manages the connections [09:43.760 --> 09:49.440] at this stage. Just a quick reminder, this is where we stopped earlier, just when the [09:49.440 --> 09:55.420] proprietary communication begins. The next sequence of packets were payload transfer, which [09:55.420 --> 10:02.220] both sides send to each other. Using our sniffer, let's examine those packets. As shown in the [10:02.220 --> 10:09.360] image, the payload transfer packet contains binary data, which was initially unclear to us. [10:09.760 --> 10:14.240] However, with the help of another portable file that we found in the Chromium open source [10:14.240 --> 10:20.320] project, we were able to decode this binary data and we discovered that the payload transfer [10:20.320 --> 10:29.660] packet contained another packet called paired key encryption. So both sides exchanged this paired [10:29.660 --> 10:34.960] key encryption packet, followed by a paired key result packet. We want to understand the [10:34.960 --> 10:39.860] purpose of these packets and with the help of our sniffer, we observed that they used among [10:39.860 --> 10:46.460] other things to enforce device visibility modes. These modes allow the user to control who can [10:46.460 --> 10:52.000] send data to them. For example, the user can choose that only their contact will be able to [10:52.000 --> 10:58.840] send data to them. After this stage is done, the initiator that wants to send the file sends an [10:58.840 --> 11:04.140] introduction packet. As a result, the responder is prompted with a file introduction [11:04.140 --> 11:10.160] dialogue on the computer saying that the initiator would like to send the file. To receive [11:10.160 --> 11:16.520] the file, the responder simply needs to press the accept button, which will cause QuickShare to [11:16.520 --> 11:23.760] send an accept packet to the initiator. After the responder accepts, the initiator sends the [11:23.760 --> 11:29.300] file using a payload transfer packet. And that's it. After this stage is completed, the file [11:29.300 --> 11:35.620] will be sent. Let's see a short demo of this overview. So on the right side we have a phone [11:35.620 --> 11:41.680] and on the left side we have a PC which QuickShare has installed and we'll just show how a file [11:41.680 --> 11:50.140] transfer normally sent from a PC to a phone. So choosing the target device, the phone gets [11:50.140 --> 11:56.180] prompted with an accept or decline dialogue. The phone chooses to accept and the file is on [11:56.180 --> 12:03.780] the phone. It's very simple, right? So now that we have basic understanding of how QuickShare [12:03.780 --> 12:10.760] file transfer works under the hood, we can proceed to fuzz this flow on QuickShare for [12:10.760 --> 12:17.500] Windows. We chose the most straightforward infrastructure for fuzzing in Windows, which is [12:17.500 --> 12:24.100] WinAFL of course. For instrumentation we used Dynamario and since Protobuf is being used [12:24.100 --> 12:30.400] everywhere, we wanted a solution that supports Protobuf as well. Google developed a [12:30.400 --> 12:37.060] Leap Protobuf mutator that can be used with WinAFL. Combining these solutions together [12:37.220 --> 12:43.200] helped us a lot in the fuzzing process and let's now discuss our approach. So our goal is to [12:43.200 --> 12:49.360] fuzz an entire session of file sending rather than just individual packets. However, there [12:49.360 --> 12:55.240] might be a potential issue with this approach. Can you guess what? So as we already [12:55.240 --> 13:00.080] mentioned, when a file is sent, an accept or decline buttons are being prompted in the [13:00.080 --> 13:05.660] responder side. Since we want to fuzz all stages of communication, including when a file is [13:05.660 --> 13:12.580] being accepted, we needed our fuzzer, our fuzzing target, sorry, to accept every file that's [13:12.580 --> 13:18.560] being sent to it automatically without the need of the user to press the accept button. So we [13:18.560 --> 13:23.900] started to look for a way to accept automatically every file that is being sent. Our first [13:23.900 --> 13:27.960] approach was to reverse engineer the relevant models and patch it in such a way that every [13:27.960 --> 13:33.920] file will be accepted automatically. But fortunately for us, within the Chromium open [13:33.920 --> 13:38.600] source project, we found out that Google already implemented a built-in feature called [13:38.600 --> 13:44.800] auto accept. So we just needed to patch this if statement to make it work all the time. And [13:44.800 --> 13:50.840] that's exactly what we did. We located the relevant binary and we patched it. Now our [13:50.840 --> 13:59.140] fuzzing target automatically accept every file every time. Next, we needed to implement a [13:59.140 --> 14:04.540] harness that could handle an entire session during each fuzzing iteration rather than just [14:04.540 --> 14:10.000] sending single packets. To achieve that, we created a simple binary format to encapsulate all [14:10.000 --> 14:16.040] packets for an entire session which would be sent each fuzzing iteration. The structure we [14:16.040 --> 14:21.720] decided was straightforward. Four bytes for length followed by a serialized offline frame of [14:21.720 --> 14:28.320] that length. At this stage, we were ready to start fuzzing QuickShare for Windows. However, as [14:28.320 --> 14:34.960] you can see on the screen, this process was quite slow. So we started to check again what [14:34.960 --> 14:40.560] makes us slow. And with the help of QuickShare logs, we found that after each file is being [14:40.560 --> 14:46.660] transferred, the stop advertising function is getting called. And as the name suggests, this [14:46.660 --> 14:52.220] function used to stop the advertising of the device and later on it's starting advertising [14:52.220 --> 14:58.160] back again. Meaning it's closing sockets, it's opening new ones, and those things take time. [14:58.660 --> 15:04.500] On top of that, another function is called with the name remove endpoint. And it has 500 [15:04.500 --> 15:11.860] milliseconds flip at the end. Think about it. After each file is being sent, there's half of a [15:11.860 --> 15:17.700] second slip time. That's huge when you're talking about fuzzing speed. So again, we patched the [15:17.700 --> 15:24.080] relevant models and prevented this behavior. Those patches help us a lot as you can see. Made [15:24.080 --> 15:30.940] our fuzzing process much faster. About ten times. Unfortunately, the speed improvement [15:30.940 --> 15:36.340] created a persistent issue for us. The combination of instrumentation, which significantly [15:36.340 --> 15:42.040] slows down the fuzzing target, and our patch to increase the file transfer speed, led to an [15:42.040 --> 15:47.580] unheld race condition that was too complex to manage. As a result, we received numerous [15:47.580 --> 15:54.520] crashes report and we were unable to reproduce. Therefore, we made a decision to abandon this [15:54.520 --> 16:00.120] approach and revert back to the original functionality of QuickShare. Despite it's been [16:00.120 --> 16:05.380] slower performance over time, the fuzzer did yield several positive uh several positive [16:05.380 --> 16:12.800] positive results. Let's discuss that. Overall, there were four reproducible crashes. We [16:12.800 --> 16:17.760] attempted to explore further the exploitation of those crashes, but they are unlikely to be [16:17.760 --> 16:23.880] exploited. But now we have the ability to crush QuickShare and who knows, that ability might [16:23.880 --> 16:29.760] be handy in the future. Another very interesting uh finding by the fuzzer was a [16:29.760 --> 16:35.800] reproducible timeout. You see, when QuickShare receives a file, it first check the [16:35.800 --> 16:41.140] existence of a file with the same name by attempting to open it. If the file opens [16:41.140 --> 16:46.400] successfully, this indicates that the file is already exist. In response, QuickShare [16:46.400 --> 16:52.060] appends an index number suffix to the file name. It's very similar to what browsers do when [16:52.060 --> 16:59.640] you download the file. So, QuickShare tries to add um the suffix before the file [16:59.640 --> 17:05.060] extension. As you can see on the screen, that's why it splits the name into two parts. The [17:05.060 --> 17:11.380] name and the extension. But what happens if the name before the extension has a null [17:11.380 --> 17:18.280] terminator in it? The result is that anything added after the null terminator is irrelevant [17:18.820 --> 17:24.760] when the file name is passed to the open function. It reads the string up only to the null [17:24.760 --> 17:29.800] terminator. This causes QuickShare to get stuck in an endless loop. Continuously [17:29.800 --> 17:36.220] incrementing indexes while mistakenly thinking it's searching for available index. When [17:36.220 --> 17:43.900] in fact, it's trying to open the same files open over and over again. So, to sum things up. We [17:43.900 --> 17:49.160] managed to get um the fuzzer working constantly, but each fuzzing iteration took too much [17:49.160 --> 17:54.660] time, making the process quite slow. Even when we identified some crashes, it wasn't [17:54.660 --> 18:00.880] necessarily always exploitable. So, we thought it was time to review what we achieved and [18:00.880 --> 18:07.560] consider our next steps. We felt confident enough with the QuickShare and the protocol, and [18:07.560 --> 18:14.540] to start searching for logical vulnerabilities. And we certainly found some gold there. And [18:14.540 --> 18:20.580] one observation that we made is the code is extremely generic. With the handler class for [18:20.580 --> 18:25.720] each packet type. Additionally, the code is filled with threads and async methods all over [18:25.720 --> 18:32.720] the place. Those specs made us think it will be a good place to find vulnerability in it. So, [18:32.720 --> 18:38.820] the first logical vulnerability that we'll introduce is a file acceptance bypass. As [18:38.820 --> 18:43.500] mentioned earlier, to send a file, the initiator first need to send an introduction packet [18:43.500 --> 18:49.000] and wait for an accept packet from the responder. After that, the initiator will send a [18:49.000 --> 18:54.960] payload transfer packet containing our file. We thought to ourself, wait, what happen if we [18:54.960 --> 19:00.400] skip the introduction and accept packets and send the payload transfer packet directly? We [19:00.400 --> 19:05.940] found out that the file will be sent anyway, resulting a complete bypass of the acceptance [19:05.940 --> 19:10.700] of the, of the, of the file from the responder side. To make things even better, we [19:10.700 --> 19:15.460] discovered that this approach works for any discovery mode. So, even if your device is [19:15.460 --> 19:21.260] configured to accept files from your context, for example, we could still be able to send [19:21.260 --> 19:27.780] files to your device without requiring your acceptance and without any notification. It's [19:27.780 --> 19:32.920] on, also important to note that this visibility mode doesn't grant a file transfer [19:32.920 --> 19:38.100] capability. Even if someone else can see your device for some reason in the quick share app, [19:38.100 --> 19:43.480] they won't be able to send files if your device is set to accept files only from your [19:43.480 --> 19:48.580] context. This is because the protocol includes a verification step at the beginning to [19:48.580 --> 19:56.660] ensure the sender is authorized to send files to the receiver. Let's see a demo of it. So, we [19:56.660 --> 20:01.800] have our phone here and we can see that I configured the phone to allow, um, files [20:01.800 --> 20:07.460] acceptance only from your device. Now, let's see the quick share folder. We can see that [20:07.460 --> 20:13.440] it's empty on the phone. And now, let's see our attacker, uh, machine. We used our [20:13.440 --> 20:18.740] tools, send files with bypass. And a few seconds after it, you could see that nothing [20:18.740 --> 20:23.500] happened on the phone, but our file is there. So, we implement the file in the phone [20:23.500 --> 20:29.000] without any notification on any Android device that has quick share and we can do it, um, [20:29.000 --> 20:35.480] even on any, any Windows device that has quick share in it. Pretty awesome, right? Thank [20:35.480 --> 20:44.440] you. So, let's continue with our next logical vulnerability. Forcing victim device to [20:44.440 --> 20:52.060] connect to a rogue Wi-Fi access point. In the context of data transfer, a medium refers to a [20:52.060 --> 20:56.900] channel through which information is transmitted. When sending a file, quick share checks [20:56.900 --> 21:01.920] whether there's a need to upgrade the medium and to achieve better transmission, uh, speed. [21:01.920 --> 21:06.460] For example, upgrade from Bluetooth to Wi-Fi. As shown on the slide, there are various [21:06.460 --> 21:12.600] possible upgrades connections. When discussing, um, bandwidth upgrades negotiation, uh, [21:12.600 --> 21:17.080] bandwidth upgrade negotiations, sorry, it's important to reference previous research that [21:17.080 --> 21:22.320] highlighted a specific attack scenario. In that study, researchers forced an Android device [21:22.320 --> 21:28.280] to connect to a rogue Wi-Fi network to carry out a man in the middle attack. This attack [21:28.280 --> 21:33.080] lasted maximum of 30 seconds and hence been mitigated by Google. Today, if your Android [21:33.080 --> 21:38.040] device receive an, uh, bandwidth upgrade negotiation packet via quick share, other [21:38.040 --> 21:44.140] internet connections, uh, will not be redirected to that Wi-Fi network. But what about [21:44.140 --> 21:50.020] Windows? We have noticed that, uh, one of the upgrade methods is through Wi-Fi hotspot access [21:50.020 --> 21:55.180] point. Basically doing transfer, the initiator creates a temporary hotspot and send the [21:55.180 --> 21:59.520] responder the credentials to connect to this hotspot. By the way, this process can be [21:59.520 --> 22:04.740] initiated from the responder side as well. When the transfer is completed, this hotspot is [22:04.740 --> 22:10.340] getting closed. But we've noticed that during this time, the internet connection of the [22:10.340 --> 22:16.220] responder device is still working, even though it's connected to our hotspot. We started to [22:16.220 --> 22:20.980] sniff the network packets from the initiator device and we found out that all the traffic [22:20.980 --> 22:26.860] from the responder side is going through our device. Meaning that we can get a man in the [22:26.860 --> 22:32.420] middle for the time of the transfer and sniff the entire responder traffic. So, I can [22:32.420 --> 22:36.920] connect every phone that has a quick share to my hotspot and create a man in the middle [22:36.920 --> 22:47.900] attack. Now, I will continue and explain what we can be done next. Cool. Okay, yeah, so, uh, [22:47.900 --> 22:54.240] that was pretty awesome. Forcing any Windows device with quick share to connect to our [22:54.760 --> 23:03.740] rogue Wi-Fi AP. Um, but let's see what we managed to uh, find so far. So, so far we found [23:03.740 --> 23:09.620] eight vulnerabilities in total. The most critical vulnerability in our opinion was the one [23:09.620 --> 23:16.080] that allowed us to send a file without approval. But we were looking really for the holy [23:16.080 --> 23:22.360] grail as I mentioned at the beginning, which was an RCE vulnerability that we still did not [23:22.360 --> 23:30.740] have. Thus, just like turning standard stones into deadly drones, that sounds pretty much [23:30.740 --> 23:39.260] impossible, we decided that we are going to chain these vulnerabilities into an RCE. So, so [23:39.260 --> 23:45.900] far we had four primary abilities using these eight vulnerabilities. We could create files [23:45.900 --> 23:51.460] in the victim's downloads folder without any requirement for acceptance or authorization. We [23:51.460 --> 23:56.900] could force the target device, the target Windows device, into connecting to a different Wi-Fi [23:56.900 --> 24:05.060] network and um, connect to the internet through it, but only for about 30 seconds. Um, we [24:05.060 --> 24:11.980] could also crash quick share in multiple ways that we found using the fuzzer. And finally, um, [24:11.980 --> 24:17.360] we could also reproduce the reproducible timeout that we saw in, that uh, the fuzzer found, [24:17.360 --> 24:24.000] which um, can force quick share into an endless loop continuously opening a file that we [24:24.000 --> 24:31.760] choose from the victim's download folder. Talking about the men, the Wi-Fi men in the middle [24:31.760 --> 24:37.820] vulnerability, as um, uh, as I mentioned, it allows us to see all the Wi-Fi traffic of the [24:37.820 --> 24:44.440] victim for about 30 seconds and, but with that being said, as you all know, encryption is a [24:44.440 --> 24:50.880] standard for today's application layer, so manipulating the traffic in 30 seconds to [24:50.880 --> 25:00.780] achieve an RCE is not likely to succeed except in very specific situations. However, we then [25:00.780 --> 25:06.700] had a crucial insight and I want you to remember that. The insight was that the downloads [25:06.700 --> 25:13.500] folder to which we can write any file that we want using our exploits on quick share for [25:13.500 --> 25:23.320] Windows, is the same folder where browsers place their downloaded files. This led us to an [25:23.320 --> 25:30.120] idea. What if we could overwrite an executable that was downloaded into the downloads [25:30.120 --> 25:36.880] folder before it runs? If being a man in the middle can somehow help us know which [25:36.880 --> 25:43.940] executable files are downloaded by the browser to the downloads folder, and if we can [25:43.940 --> 25:51.180] somehow overwrite them using our abilities, then this would lead to an RCE. That is [25:51.180 --> 25:55.940] because we'll be able to replace the executable with our malicious one and then the user [25:55.940 --> 26:02.540] will run our executable. The simplest example would be a victim that downloads the VS code [26:02.540 --> 26:08.340] installer for instance and then we overwrite it with one of our vulnerabilities right after it [26:08.340 --> 26:15.060] was downloaded and then the victim runs our executable instead of the VS code installer. Now [26:15.060 --> 26:22.260] of course we still did not have uh sorry, yeah, okay. Now of course we still did not have [26:22.260 --> 26:28.380] the exact abilities we needed but since being a man in the middle might help us anyway, we [26:28.380 --> 26:33.960] decided to start with making the Wi-Fi connection last longer as it was only active for about 30 [26:33.960 --> 26:41.080] seconds. To do that, we tried to think of a way to prevent QuickShare from returning to its [26:41.080 --> 26:48.200] original Wi-Fi network once a file sending session was over. Then, a very simple solution [26:48.200 --> 26:54.560] came up. Crashing QuickShare right after the Wi-Fi connection to our road Wi-Fi AP was [26:54.560 --> 27:01.080] established. The result was that if we force a Windows computer with QuickShare to connect to [27:01.080 --> 27:07.380] our Wi-Fi network, to our malicious Wi-Fi network, and then instantly crash the app with one [27:07.380 --> 27:13.240] of our denial of service vulnerabilities that a fuzzer found, we get a forever lasting Wi-Fi [27:13.240 --> 27:22.820] connection to our Wi-Fi hotspot. As regards to the crash, the fear of it preventing us from [27:22.820 --> 27:29.320] continuing to exploit the app did not exist. Why? Because when QuickShare is installed, it [27:29.320 --> 27:35.840] creates a scheduled task that runs every 15 minutes and runs QuickShare if it's not already [27:35.840 --> 27:43.660] running. So we don't really lose the ability to further exploit QuickShare. And actually, we [27:43.660 --> 27:48.980] will continue to exploit QuickShare. And this is why these two links are only the first part [27:48.980 --> 27:55.640] of our RCE attack chain. So far, we established a lasting Wi-Fi connection that we expect to [27:55.640 --> 28:02.380] come in handy for identifying downloaded file. Now, let's understand the reason for why it [28:02.380 --> 28:08.980] was actually so helpful for doing that. And the reason, and this is the reason. Metadata [28:08.980 --> 28:15.520] matters. Seeing this tweet by Talberry, which by the way, had a different picture that we [28:15.520 --> 28:21.820] changed, but can still be found in Tal's feed. Uh, we thought that it explains exactly how we [28:21.820 --> 28:27.700] leveraged the Wi-Fi connection. It was indeed true that files are normally downloaded over [28:27.700 --> 28:35.060] HTTPS, meaning that the traffic is encrypted. However, there were still two very important [28:35.060 --> 28:43.220] elements in the metadata of an HTTPS session. The first one is the server's domain. The [28:43.220 --> 28:48.640] encryption of HTTPS is performed using the TLS protocol, of course, and the TLS session [28:48.640 --> 28:56.580] starts with an unencrypted client hello message that is sent by the client. Normally, a [28:56.580 --> 29:03.820] server name indication extension is being added to this message, which indicates the domain [29:03.820 --> 29:10.840] of the server. That means that if you are exposed to victim's traffic, you can determine the [29:10.840 --> 29:17.340] domains that they communicate with. The second element that is present of part of the [29:17.340 --> 29:24.480] metadata of an HTTPS session is the approximate size of data that is being transferred in the [29:24.480 --> 29:31.980] session. When a file is being downloaded over HTTPS, it's normally downloaded in one TCP [29:31.980 --> 29:38.460] session. Even though encryption might add some random padding, the amount of data that is [29:38.460 --> 29:44.760] being transferred from the server to the client during a file download of the same file [29:45.420 --> 29:51.820] stays relatively the same. In addition, the size of an executable file is usually much [29:51.820 --> 29:59.800] bigger than the size of other pages or resources that may be transferred from a website to a [29:59.800 --> 30:07.440] client in an HTTPS session. The conclusion is that if we know the domain that the client [30:07.440 --> 30:13.720] communicated with, and we know that there is a large file that is being downloaded along with [30:13.720 --> 30:21.100] its approximate size, then that means that we can also very accurately guess the name of the [30:21.100 --> 30:28.780] downloaded file. For instance, if we know that 95 megabytes were downloaded from code.visual [30:28.780 --> 30:36.320] studio.com, then we can confidently say that the latest VS Code installer was probably [30:36.320 --> 30:43.440] downloaded. Think of the most popular installers for software that you use, like VS Code, for [30:43.440 --> 30:49.760] example. Entering the VS Code download page leads you to a single download button for a single [30:49.760 --> 30:58.280] VS Code version that matches your OS and is the newest one. This installer has the size of 95 [30:58.280 --> 31:05.820] megabytes, which is larger than any other resource in the website. And so this really narrows down [31:05.820 --> 31:13.280] the options and makes it much easier to detect a download of the latest VS Code installer. Most [31:13.280 --> 31:22.820] websites that offer such installers have really only one relevant file. And so we framed and [31:22.820 --> 31:28.920] defined our new man-in-the-middle technique more specifically. In order to be as precise as [31:28.920 --> 31:35.800] possible, we understood that we need to define what we call domain paths. A domain path is a [31:35.800 --> 31:43.260] sequence of domains to which we expect the victim to access until the download starts. Let's [31:43.260 --> 31:50.140] look at Notepad++ for example. Clicking on the download button in its website does not [31:50.140 --> 31:59.640] download the executable from the Notepad++.org domain. Instead it references github.com. Then [31:59.640 --> 32:05.700] github.com actually redirects a request to another domain and this is the final domain. It's [32:05.700 --> 32:13.060] objects.githubusercontent.com. And the file is downloaded from there. If we just look at this [32:13.060 --> 32:18.320] final domain, we won't be able to determine that the downloaded file is the installer of [32:18.320 --> 32:26.700] Notepad++. However, what we can do is to follow access to previous domains. Basically what we [32:26.700 --> 32:34.380] need to do is to see that in a limited time period, Notepad++.org was accessed followed by [32:34.380 --> 32:41.040] access to github.com and then to objects.githubusercontent.com. If that access to the [32:41.040 --> 32:47.320] final domain downloads a file with an approximate size as we expect for the installer, then we [32:47.320 --> 32:54.280] can determine that it's actually the installer. To conclude, this is how we define the new [32:54.280 --> 33:00.120] man-in-the-middle technique that we created. We start by creating a mapping between domain [33:00.120 --> 33:08.720] paths to executables that match these domain paths and their sizes. Then we wait until the [33:08.720 --> 33:14.840] victim hits a certain domain path in a limited time frame and we start counting the [33:14.840 --> 33:21.700] downloaded data. Finally, we check if the size of the downloaded data is equal or a bit [33:21.700 --> 33:27.700] bigger than the installer that matches this domain path. If it does, then we are safe to [33:27.700 --> 33:35.160] determine that the expected installer was indeed the one that was downloaded. And so we [33:35.160 --> 33:41.840] change another link to our RCE chain. Now we can also detect the name of an executable that [33:41.840 --> 33:49.140] is downloaded by a victim. That being said, for an RCE, we still need the ability to [33:49.140 --> 33:57.680] override files as we mentioned before. And we did not have it yet. But it doesn't have to be [33:57.920 --> 34:03.600] a generic ability to override files using our vulnerabilities in Quick Share. It could be an [34:03.600 --> 34:08.960] ability that allows to override files only in our very specific situation when files are [34:08.960 --> 34:15.660] being downloaded. So what we're trying to do is to override Google Chrome's download while [34:15.660 --> 34:22.700] it's still ongoing. So first let's understand Chrome's basic download process. When Chrome [34:22.700 --> 34:28.460] downloads a file, no matter which file it is, it starts by checking if the file name already [34:28.460 --> 34:34.360] exists. If it does, it adds a number surrounded by parentheses to the file name for the [34:34.360 --> 34:42.600] download. If it doesn't, it keeps the original name. Then it starts downloading the file but [34:42.600 --> 34:51.360] into a temporary file with a CR download extension. Once the download is fully complete and [34:51.360 --> 34:56.680] we got all the contents of the file and only then Chrome renames the temporary file to the [34:56.680 --> 35:04.240] actual name of the downloaded file and the download is then really complete. But since Chrome [35:04.240 --> 35:10.720] checks whether the name already exists and decides on the final name for the downloaded file, [35:10.720 --> 35:16.760] only when it starts the download, we thought that there is good potential to create confusion [35:16.760 --> 35:23.200] if we send the file with the same name in the middle of this process. That will be after the [35:23.200 --> 35:32.240] name for the uh final downloaded file will already be final and has been decided on. We thought it [35:32.240 --> 35:39.140] might leave Chrome to fail in renaming the downloaded file, the temporary file, to the final [35:39.140 --> 35:45.520] name for the file, leaving our file in place. But how can we know the name of the downloaded [35:45.520 --> 35:52.920] file and still send it before the download is complete? We must wait for the final TCP packet [35:52.920 --> 35:59.660] to be sent from the server in order to determine the approximate size of the file and then as a [35:59.660 --> 36:05.900] result of it, determine its name. In order to prevent the download from being finished in [36:05.900 --> 36:11.120] Chrome, what we do is that we hold this last packet as the man in the middle and do not forward [36:11.120 --> 36:19.520] it to the client. So we try to send a file with the exact same name right before the download is [36:19.520 --> 36:26.160] finished, hoping Chrome might be confused and will fail to rename the temporary file leaving our [36:26.160 --> 36:35.700] file as the presumably downloaded file. But unfortunately this did not work. As a result, Chrome [36:35.700 --> 36:41.740] just overwrote the file that we sent, finishing its download successfully, deleting our [36:41.740 --> 36:48.100] malicious file. But this was not the end of it. We understood that we need to find a way to [36:48.100 --> 36:55.220] prevent Chrome from overriding our file. Then it was not long until we figured out that we [36:55.220 --> 37:05.300] maybe already have this ability. If you remember from before, one of the reproducible uh uh [37:05.700 --> 37:11.220] timeouts that the father found um was uh a vulnerability that allowed us to bring [37:11.220 --> 37:16.960] QuickShare into a state where it continuously opens and closes any file that we want from the [37:16.960 --> 37:23.280] downloads folder of the victim. We thought that we can utilize this vulnerability just right [37:23.280 --> 37:31.220] for this case. What we hoped for is that maybe if the file is endlessly opened and closed, the [37:31.220 --> 37:39.580] file that we sent, then this will fail Chrome in overwriting it. So the result was that our [37:39.580 --> 37:47.020] hopes actually became reality and Chrome actually failed in overwriting our file. It was [37:47.020 --> 37:53.260] actually the best scenario that we hoped for. Once Chrome finishes the download, the result is [37:53.260 --> 37:59.940] that it deletes the temporary CR download file, it fails to overwrite our malicious file, and [37:59.940 --> 38:06.060] it's user interface, Chrome reports that the download was finished successfully. And [38:06.060 --> 38:12.080] clicking on the downloaded file in Chrome's downloads window actually runs our malicious [38:12.080 --> 38:26.260] file. Thank you. Yeah I know it's cool. Okay so uh and so another two links were added to our [38:26.260 --> 38:31.880] RCE chain completing it into the RCE chain attack that we were aiming for from the [38:31.880 --> 38:39.640] beginning. And finally we prepared a demonstration video presenting the entire quick show [38:39.640 --> 38:47.620] RCE attack chain for you to see it in action. So let's watch it and before we do, I'll mention [38:47.620 --> 38:54.720] that the video starts um uh when the video starts we'll see the attacker's computer, we'll [38:54.720 --> 39:04.060] see that the attacker enabled a mobile hotspot on his Windows computer, and then we'll move [39:04.060 --> 39:11.100] on to the victim computer where we'll see quick share installed. Um and we'll start by [39:11.100 --> 39:17.540] seeing how the attacker forces the victim into connecting to the wifi hotspot that the [39:17.540 --> 39:24.700] attacker created. Okay so let's begin. So we can see that the hotspot is enabled and we can [39:24.720 --> 39:34.900] see just the IP address on that hotspot. Now we run our tool and we find nearby victims. One of [39:34.900 --> 39:39.260] them is called test machine. We choose test machine. This is test machine. And now it's [39:39.260 --> 39:45.420] connected to safe breach but we force it into connecting to our test AP and crash creature to [39:45.420 --> 39:50.480] make it um to make the wifi connection last and now we see all the domains that the victim [39:50.480 --> 39:57.480] accesses. Now the victim goes into the Spotify website to download the Spotify for Windows [39:57.480 --> 40:04.460] installer. We can see that the downloads folder is just empty, there's nothing inside. Now [40:04.460 --> 40:09.720] the victim downloads the file. Let's see what happens uh with the download. It's now [40:09.720 --> 40:20.160] complete. We click it and our malware runs instead. Now, thank you. Now let's do the same with [40:20.160 --> 40:27.980] Notepad++. We go into it's website, download the newest version of Notepad++ for Windows. The [40:27.980 --> 40:34.060] victim downloads the file. The download starts. You can see that we can do that for many [40:34.060 --> 40:41.900] installers. So the download is now finished. And the victim runs it and it's again our [40:41.900 --> 40:50.140] malicious executable. Okay. Thank you. Now let's see what happens when we run the [40:50.160 --> 40:57.600] vulnerability. Pretty cool, right? So I know it might seem like we found exactly the [40:57.600 --> 41:02.600] vulnerabilities that we needed to build this RCE chain but in reality it was a bit [41:02.600 --> 41:07.260] different. In fact we discovered two additional vulnerabilities. One allowed us to send [41:07.260 --> 41:12.620] file to the parent folder of downloads folder and other let us crash quick share by [41:12.620 --> 41:18.500] leveraging some of the findings from all magic dot research that he presented last April. [41:18.500 --> 41:24.720] However this vulnerability weren't used, were not used in the RCE chain and could not be [41:24.720 --> 41:30.140] exploited for remote code execution. We'll share more details about them in our upcoming [41:30.140 --> 41:35.300] blog post that will be published after this talk. Overall we identified ten distinct [41:35.300 --> 41:42.000] vulnerabilities along with additional bug in Chrome. We ported all of these vulnerabilities [41:42.000 --> 41:47.420] to Google at the end of January this year. They've confirmed, they've confirmed they fixed [41:47.420 --> 41:53.920] every one of them, every one of them. Google decided to issue two CVEs for these ten [41:53.920 --> 41:59.420] vulnerabilities. The first CVE addresses how two of the vulnerabilities can combine, can [41:59.420 --> 42:05.240] force a persistent Wi-Fi connection. The second CVE deals with bypassing the file approval [42:05.240 --> 42:12.060] dialogue in Windows. Google was very responsive throughout the process confirming and [42:12.060 --> 42:16.560] reproducing each of the vulnerability reported. We wanted to thank them for their [42:16.560 --> 42:22.940] collaboration and for addressing these issues. Here's the official response. You can take a [42:22.940 --> 42:29.980] moment to read it now but of course it will be included in the published presentation. Give [42:30.100 --> 42:38.580] you a few seconds. So we've covered pretty much everything about technical flow and now it's [42:38.580 --> 42:44.180] time to talk about the takeaways which are just as important. Our first and most [42:44.180 --> 42:49.620] significant takeaway is that standard stones may sometimes be forged into deadly drones. What [42:49.620 --> 42:55.840] we mean by that is that as a hacker you often have limited tools at your disposal. You might [42:55.840 --> 43:00.880] achieve something but it's not exactly what you are aiming for. Reflecting on our research we [43:00.880 --> 43:06.400] believe that even a seamlessly basic or unimpressive abilities can sometime be transformed [43:06.400 --> 43:12.840] into much much greater uh much more powerful uh capabilities. We're all familiar with the [43:12.840 --> 43:18.100] typical chains of vulnerabilities that addresses non-issue like bypassing stack cookies or [43:18.100 --> 43:23.100] other memory corruption mitigations. But it's not always so straightforward. Sometimes you [43:23.100 --> 43:28.580] might have unconventional abilities like forcing an endless loop that repeatedly opens a [43:28.580 --> 43:35.180] file. For real, who thought this ability might be helpful? So this can use to create a very [43:35.800 --> 43:41.140] unconventional flows that still allow you to achieve your ultimate goal. The next takeaway [43:41.140 --> 43:46.860] shifts to the defensive side. Many products leave non-issue and bugs unfixed due to [43:46.860 --> 43:53.500] prioritization. Often this issue seems to pose no security risk or only minor ones that [43:53.500 --> 43:58.640] doesn't require immediate attention. However, addressing these non-issue bugs or minor [43:58.640 --> 44:04.600] security risk can sometime be crucial for mitigating much greater risk that you might not [44:04.600 --> 44:09.700] be aware of. For example, if we didn't have the DOS vulnerability that allows QuickShare to [44:09.700 --> 44:16.620] crash, we wouldn't be able to have a established stable Wi-Fi connection and this would [44:16.620 --> 44:22.900] have completely disabled our RC chain. Lastly, it's crucial for organizations to develop [44:22.900 --> 44:29.320] software and develop software to focus not only on specific programming mistakes like memory [44:29.320 --> 44:34.320] corruption bugs. When evaluating a program's security, it's important to take a broader [44:34.320 --> 44:40.620] perspective and consider whether a simple logic or intended behavior might also introduce [44:40.620 --> 44:47.260] security risk. That's pretty much it. Here's the QR code for our repository. Feel free to [44:47.260 --> 44:53.140] take a picture. It has a lot of tools to play with QuickShare. You can also find the [44:53.140 --> 44:59.080] contact details for all and myself. And we'd like to thank everyone for joining to our [44:59.080 --> 45:02.120] session. We hope you enjoyed it. Thank you. [45:02.120 --> 45:03.000] Thank you, everyone. [45:04.280 --> 45:06.400] Thank you. It was really fun.