1 00:00:00,000 --> 00:00:02,080 I'd like to introduce Or and Shmuel. 2 00:00:02,600 --> 00:00:04,300 Here we go. 3 00:00:04,300 --> 00:00:05,740 And away we go. 4 00:00:11,890 --> 00:00:14,310 Okay, hi everyone. 5 00:00:14,370 --> 00:00:17,070 Today we will present Quickshare. 6 00:00:17,070 --> 00:00:22,250 Sharing is caring about an RC attack chain on Quickshare. 7 00:00:22,610 --> 00:00:28,630 So, my name is Or Yair, I'm the security research team lead at Safe Breach. 8 00:00:28,630 --> 00:00:32,450 I have more than 6 years of experience in security research. 9 00:00:32,450 --> 00:00:40,790 My past research included some research on Linux environments, embedded devices, Android devices and more. 10 00:00:41,010 --> 00:00:49,210 And for more than 3 years now my main focus lies in vulnerability research in a Windows operating system and third party apps that run on it. 11 00:00:51,440 --> 00:00:58,620 Hi everyone, my name is Shmuel Cohen and I'm excited to be here today and present the finding of our recent research. 12 00:00:58,620 --> 00:01:04,500 A little bit about myself, I have 6 years of experience in the cyber security industry. 13 00:01:04,500 --> 00:01:16,620 Previously I conducted APT malware research within the checkpoint research group and currently I'm part of the Safe Breach original research team where I focus primarily on vulnerability research on various products. 14 00:01:19,980 --> 00:01:24,200 Okay, so let's see what we're going to talk about today. 15 00:01:24,520 --> 00:01:32,080 We'll start with what is Quickshare and why we chose it as our primary target for this research. 16 00:01:32,080 --> 00:01:37,940 We'll then move on to get a brief overview about the protocol that Quickshare uses. 17 00:01:37,940 --> 00:01:44,260 We'll then see the first research approach that we took for this research which is fuzzing. 18 00:01:44,260 --> 00:01:58,520 We'll see the research approach shift um that we took that led us to other vulnerabilities and we'll see the vulnerability discovery that um that we had, vulnerability discoveries that we had um based on these two approaches. 19 00:01:58,740 --> 00:02:08,200 Then we'll see how we managed to assemble a very unconventional and creative RCE attack chain from these vulnerabilities. 20 00:02:08,380 --> 00:02:16,100 And we'll conclude with takeaways and a link to the GitHub repository of all the tools that we created. 21 00:02:16,240 --> 00:02:19,520 So, what is Quickshare? 22 00:02:20,040 --> 00:02:26,420 Quickshare is Google's nearby file transfer solution for Android just like Apple's AirDrop. 23 00:02:27,060 --> 00:02:40,120 Quickshare was formerly known as NearbyShare and then last January at CES, Google and Samsung decided to combine their file sharing solutions into a single one and call it Quickshare. 24 00:02:40,680 --> 00:02:45,920 So, we know what the talk is about, but why did we even choose to target Quickshare? 25 00:02:46,820 --> 00:02:57,980 Last July, Google has officially released a Windows version of Quickshare for Windows, allowing to share files between Windows computers to any other device with Quickshare. 26 00:02:58,300 --> 00:03:14,860 An interesting fact from Google's announcement about Quickshare at CES is that they are working with leading PC manufacturers, just like LG, to expand Quickshare to Windows PCs as a pre-installed app, making Quickshare for Windows a much more attractive target. 27 00:03:16,720 --> 00:03:22,180 Moreover, Quickshare performs file transfers using several communication methods. 28 00:03:22,180 --> 00:03:31,720 It supports WebRTC, Bluetooth, Wi-Fi, NFC, Wi-Fi direct and even sending files over a Wi-Fi hotspot of one of the devices. 29 00:03:32,080 --> 00:03:39,440 As far as we knew, Quickshare was Google's first Windows app to use all these communication methods. 30 00:03:39,520 --> 00:03:45,440 In general, most of Google's services that are used on Windows are in the browser. 31 00:03:45,620 --> 00:03:50,960 This was a first of a kind for Google and thus chances for mistakes were higher. 32 00:03:52,040 --> 00:04:02,000 Looking for past research, the only one that we could really find was a research called Nearby Threats, reversing, analyzing and attacking Google's nearby connections on Android. 33 00:04:02,160 --> 00:04:11,740 The research analyzed Google's Nearby Connections API, that is the API that NearbyShare and later on Quickshare use in their implementations. 34 00:04:12,120 --> 00:04:16,160 And Quickshare and NearbyShare didn't even exist back then. 35 00:04:16,160 --> 00:04:19,620 It was just an API for third party applications. 36 00:04:19,760 --> 00:04:24,880 The Windows app did not exist also of course. 37 00:04:26,160 --> 00:04:33,580 Another interesting fact was that we saw that most of the applications code can be found in open source repositories by Google. 38 00:04:33,580 --> 00:04:36,900 It was not all of it, but some of it at least. 39 00:04:37,200 --> 00:04:44,240 And in addition, we just could not find any CVEs related to Quickshare. 40 00:04:44,840 --> 00:04:52,640 Concluding all of these facts together led us to evaluate Quickshare as a valuable and likely to be breached target. 41 00:04:53,340 --> 00:05:00,080 Our final goal was to achieve something that was never achieved using Quickshare. 42 00:05:00,080 --> 00:05:03,580 And that was remote code execution. 43 00:05:05,200 --> 00:05:09,900 Starting our journey, we needed to understand Quickshare's protocol of course. 44 00:05:10,460 --> 00:05:19,120 Therefore, the first thing we did was to find the most basic functions that Quickshare uses to send and receive packets. 45 00:05:19,460 --> 00:05:33,080 Once we find such functions, if they are generic and are used for all communication methods, then we'll be able to get a clear view of all packets that are being sent and received by the app in their binary form. 46 00:05:33,580 --> 00:05:41,220 Then, just as we needed, we found the read and write functions as part of a base class that was called base endpoint channel. 47 00:05:42,320 --> 00:05:50,680 Deeper inside the read function, we were able to understand that the packets that are being sent and received are packets of a type called offline frame. 48 00:05:50,820 --> 00:05:57,200 That is because each packet that was received was parsed into an offline frame object. 49 00:05:57,200 --> 00:06:06,220 But the offline frame object was not a normal object as its class was generated by protobuf. 50 00:06:06,520 --> 00:06:11,180 In here we can see the protobuf definition of offline frame. 51 00:06:11,180 --> 00:06:24,840 And using protobuf, this proto file is being compiled into CPP files that define the offline frame and provide functions to serialize it to bytes and deserialize it from bytes. 52 00:06:25,180 --> 00:06:43,960 But don't be alarmed by the name offline frame too much because offline frame is the base type for almost all packet types that we are going to discuss in this talk and so from now on we will just mostly call them packets instead of offline frames. 53 00:06:44,640 --> 00:06:49,520 And so, our first tool for this research was born pretty fast. 54 00:06:49,560 --> 00:06:53,600 We needed a tool that will provide us abilities to watch the communication. 55 00:06:53,620 --> 00:07:02,760 So we wrote a DLL that hooks the read and write functions and textually logs each packet that is being sent and received with all of its fields. 56 00:07:02,980 --> 00:07:09,480 This tool allowed us to understand the protocol much better and Shmuel will be the one to elaborate on what we learned. 57 00:07:09,480 --> 00:07:12,200 Thank you all. 58 00:07:14,520 --> 00:07:15,280 Cool. 59 00:07:15,280 --> 00:07:21,260 So now that we can sniff QuickShare packets, it's time to take a deep dive of the protocol used by QuickShare. 60 00:07:21,320 --> 00:07:33,740 So there's an API called Nearby Connections API and it's used to discover, connect and exchange data with nearby devices in real time regardless of network connectivity. 61 00:07:34,040 --> 00:07:37,920 QuickShare uses the Nearby Connections API with its own implementation. 62 00:07:38,780 --> 00:07:42,560 Let's start with reviewing the Nearby Connections API. 63 00:07:42,560 --> 00:07:46,420 So it's based on protobuf which is used to serialize structure data. 64 00:07:46,560 --> 00:07:47,900 It's mostly encrypted. 65 00:07:47,900 --> 00:07:51,720 The encryption is handled using Google's UK2 library. 66 00:07:51,720 --> 00:08:00,360 Each app is uniquely identified within the Nearby Connections API by a service ID that is provided by the app's developers. 67 00:08:00,360 --> 00:08:05,800 It has multiple connections strategies such as peer-to-peer, star and cluster. 68 00:08:06,500 --> 00:08:11,420 We will focus on the peer-to-peer strategy because it's the one used by QuickShare. 69 00:08:11,900 --> 00:08:17,860 In this strategy there's initiator and the responder functioning much like a client and server. 70 00:08:17,940 --> 00:08:24,700 In our protocol overview we will examine packets that send during a file transfer from a phone to a PC. 71 00:08:25,120 --> 00:08:29,260 The first stage of communication is a connection request packet. 72 00:08:29,260 --> 00:08:33,320 Following that the initiator start with encryption handshake. 73 00:08:33,320 --> 00:08:38,980 The encryption handshake starts by sending a UK client init packet to the responder. 74 00:08:39,540 --> 00:08:48,580 Then the responder replies with a UK server initialization packet and finally the initiator responds with a UK client finish packet. 75 00:08:48,800 --> 00:08:56,240 At this point the UK encryption handshake is successfully completed ensuring that all subsequent packets will be encrypted. 76 00:08:56,500 --> 00:09:06,280 Next the responder sends a connection response packet indicating that it's accepted the connection and the initiator responds with a similar packet back. 77 00:09:06,280 --> 00:09:09,400 At this point QuickShare proprietary communication begins. 78 00:09:09,400 --> 00:09:15,200 This proprietary communication uses various types of packets provided by the nearby connections API. 79 00:09:15,200 --> 00:09:17,460 Let's review some of those packets. 80 00:09:17,800 --> 00:09:22,440 So these packets as all mentioned are called offline frames. 81 00:09:22,440 --> 00:09:26,820 Here you can see all types of packets that can be used within the protocol. 82 00:09:27,380 --> 00:09:32,760 So far we've seen two types, the connection request and the connection response. 83 00:09:34,180 --> 00:09:39,860 In our talk we will focus on two types, payload transfer and bandwidth upgrade negotiation. 84 00:09:40,480 --> 00:09:45,240 Now let's explore how QuickShare manages the connections at this stage. 85 00:09:45,440 --> 00:09:51,480 Just a quick reminder, this is where we stopped earlier, just when the proprietary communication begins. 86 00:09:52,280 --> 00:09:57,820 The next sequence of packets were payload transfer, which both sides send to each other. 87 00:09:58,300 --> 00:10:01,280 Using our sniffer, let's examine those packets. 88 00:10:01,500 --> 00:10:09,360 As shown in the image, the payload transfer packet contains binary data, which was initially unclear to us. 89 00:10:09,760 --> 00:10:25,040 However, with the help of another portable file that we found in the Chromium open source project, we were able to decode this binary data and we discovered that the payload transfer packet contained another packet called paired key encryption. 90 00:10:25,720 --> 00:10:33,540 So both sides exchanged this paired key encryption packet, followed by a paired key result packet. 91 00:10:33,600 --> 00:10:43,540 We want to understand the purpose of these packets and with the help of our sniffer, we observed that they used among other things to enforce device visibility modes. 92 00:10:43,700 --> 00:10:47,660 These modes allow the user to control who can send data to them. 93 00:10:47,660 --> 00:10:53,280 For example, the user can choose that only their contact will be able to send data to them. 94 00:10:54,180 --> 00:11:00,360 After this stage is done, the initiator that wants to send the file sends an introduction packet. 95 00:11:00,920 --> 00:11:08,920 As a result, the responder is prompted with a file introduction dialogue on the computer saying that the initiator would like to send the file. 96 00:11:09,600 --> 00:11:19,840 To receive the file, the responder simply needs to press the accept button, which will cause QuickShare to send an accept packet to the initiator. 97 00:11:20,900 --> 00:11:26,100 After the responder accepts, the initiator sends the file using a payload transfer packet. 98 00:11:26,100 --> 00:11:27,260 And that's it. 99 00:11:27,280 --> 00:11:30,580 After this stage is completed, the file will be sent. 100 00:11:30,620 --> 00:11:33,240 Let's see a short demo of this overview. 101 00:11:33,880 --> 00:11:45,680 So on the right side we have a phone and on the left side we have a PC which QuickShare has installed and we'll just show how a file transfer normally sent from a PC to a phone. 102 00:11:46,240 --> 00:11:52,740 So choosing the target device, the phone gets prompted with an accept or decline dialogue. 103 00:11:52,740 --> 00:11:56,700 The phone chooses to accept and the file is on the phone. 104 00:11:57,040 --> 00:11:59,280 It's very simple, right? 105 00:12:00,120 --> 00:12:11,780 So now that we have basic understanding of how QuickShare file transfer works under the hood, we can proceed to fuzz this flow on QuickShare for Windows. 106 00:12:12,660 --> 00:12:19,440 We chose the most straightforward infrastructure for fuzzing in Windows, which is WinAFL of course. 107 00:12:19,740 --> 00:12:28,840 For instrumentation we used Dynamario and since Protobuf is being used everywhere, we wanted a solution that supports Protobuf as well. 108 00:12:29,040 --> 00:12:35,080 Google developed a Leap Protobuf mutator that can be used with WinAFL. 109 00:12:35,080 --> 00:12:41,560 Combining these solutions together helped us a lot in the fuzzing process and let's now discuss our approach. 110 00:12:41,560 --> 00:12:48,460 So our goal is to fuzz an entire session of file sending rather than just individual packets. 111 00:12:48,460 --> 00:12:51,860 However, there might be a potential issue with this approach. 112 00:12:51,860 --> 00:12:53,080 Can you guess what? 113 00:12:54,180 --> 00:13:01,280 So as we already mentioned, when a file is sent, an accept or decline buttons are being prompted in the responder side. 114 00:13:01,280 --> 00:13:17,540 Since we want to fuzz all stages of communication, including when a file is being accepted, we needed our fuzzer, our fuzzing target, sorry, to accept every file that's being sent to it automatically without the need of the user to press the accept button. 115 00:13:17,980 --> 00:13:23,520 So we started to look for a way to accept automatically every file that is being sent. 116 00:13:23,520 --> 00:13:30,340 Our first approach was to reverse engineer the relevant models and patch it in such a way that every file will be accepted automatically. 117 00:13:30,360 --> 00:13:39,680 But fortunately for us, within the Chromium open source project, we found out that Google already implemented a built-in feature called auto accept. 118 00:13:39,760 --> 00:13:44,420 So we just needed to patch this if statement to make it work all the time. 119 00:13:44,540 --> 00:13:46,080 And that's exactly what we did. 120 00:13:46,080 --> 00:13:50,320 We located the relevant binary and we patched it. 121 00:13:50,320 --> 00:13:55,560 Now our fuzzing target automatically accept every file every time. 122 00:13:56,020 --> 00:14:05,960 Next, we needed to implement a harness that could handle an entire session during each fuzzing iteration rather than just sending single packets. 123 00:14:05,960 --> 00:14:14,980 To achieve that, we created a simple binary format to encapsulate all packets for an entire session which would be sent each fuzzing iteration. 124 00:14:15,140 --> 00:14:18,080 The structure we decided was straightforward. 125 00:14:18,100 --> 00:14:22,840 Four bytes for length followed by a serialized offline frame of that length. 126 00:14:23,680 --> 00:14:27,500 At this stage, we were ready to start fuzzing QuickShare for Windows. 127 00:14:27,500 --> 00:14:31,800 However, as you can see on the screen, this process was quite slow. 128 00:14:32,820 --> 00:14:36,140 So we started to check again what makes us slow. 129 00:14:36,140 --> 00:14:44,680 And with the help of QuickShare logs, we found that after each file is being transferred, the stop advertising function is getting called. 130 00:14:44,680 --> 00:14:53,340 And as the name suggests, this function used to stop the advertising of the device and later on it's starting advertising back again. 131 00:14:53,340 --> 00:14:58,160 Meaning it's closing sockets, it's opening new ones, and those things take time. 132 00:14:58,660 --> 00:15:03,140 On top of that, another function is called with the name remove endpoint. 133 00:15:03,140 --> 00:15:06,300 And it has 500 milliseconds flip at the end. 134 00:15:06,300 --> 00:15:07,240 Think about it. 135 00:15:07,240 --> 00:15:12,820 After each file is being sent, there's half of a second slip time. 136 00:15:12,820 --> 00:15:15,660 That's huge when you're talking about fuzzing speed. 137 00:15:15,660 --> 00:15:20,140 So again, we patched the relevant models and prevented this behavior. 138 00:15:21,220 --> 00:15:23,580 Those patches help us a lot as you can see. 139 00:15:23,580 --> 00:15:25,880 Made our fuzzing process much faster. 140 00:15:25,880 --> 00:15:27,360 About ten times. 141 00:15:29,160 --> 00:15:32,940 Unfortunately, the speed improvement created a persistent issue for us. 142 00:15:32,940 --> 00:15:45,620 The combination of instrumentation, which significantly slows down the fuzzing target, and our patch to increase the file transfer speed, led to an unheld race condition that was too complex to manage. 143 00:15:45,620 --> 00:15:51,980 As a result, we received numerous crashes report and we were unable to reproduce. 144 00:15:52,120 --> 00:15:59,100 Therefore, we made a decision to abandon this approach and revert back to the original functionality of QuickShare. 145 00:15:59,280 --> 00:16:07,620 Despite it's been slower performance over time, the fuzzer did yield several positive uh several positive positive results. 146 00:16:07,620 --> 00:16:09,020 Let's discuss that. 147 00:16:09,460 --> 00:16:12,580 Overall, there were four reproducible crashes. 148 00:16:12,580 --> 00:16:18,720 We attempted to explore further the exploitation of those crashes, but they are unlikely to be exploited. 149 00:16:18,720 --> 00:16:25,500 But now we have the ability to crush QuickShare and who knows, that ability might be handy in the future. 150 00:16:26,300 --> 00:16:31,460 Another very interesting uh finding by the fuzzer was a reproducible timeout. 151 00:16:31,460 --> 00:16:40,300 You see, when QuickShare receives a file, it first check the existence of a file with the same name by attempting to open it. 152 00:16:40,300 --> 00:16:45,280 If the file opens successfully, this indicates that the file is already exist. 153 00:16:45,280 --> 00:16:49,760 In response, QuickShare appends an index number suffix to the file name. 154 00:16:49,760 --> 00:16:53,420 It's very similar to what browsers do when you download the file. 155 00:16:54,960 --> 00:17:00,440 So, QuickShare tries to add um the suffix before the file extension. 156 00:17:00,440 --> 00:17:04,860 As you can see on the screen, that's why it splits the name into two parts. 157 00:17:04,860 --> 00:17:06,880 The name and the extension. 158 00:17:07,100 --> 00:17:12,820 But what happens if the name before the extension has a null terminator in it? 159 00:17:13,580 --> 00:17:21,820 The result is that anything added after the null terminator is irrelevant when the file name is passed to the open function. 160 00:17:21,920 --> 00:17:25,420 It reads the string up only to the null terminator. 161 00:17:25,420 --> 00:17:28,980 This causes QuickShare to get stuck in an endless loop. 162 00:17:29,140 --> 00:17:35,840 Continuously incrementing indexes while mistakenly thinking it's searching for available index. 163 00:17:35,980 --> 00:17:40,900 When in fact, it's trying to open the same files open over and over again. 164 00:17:41,520 --> 00:17:43,740 So, to sum things up. 165 00:17:43,740 --> 00:17:51,700 We managed to get um the fuzzer working constantly, but each fuzzing iteration took too much time, making the process quite slow. 166 00:17:51,780 --> 00:17:57,060 Even when we identified some crashes, it wasn't necessarily always exploitable. 167 00:17:57,540 --> 00:18:02,540 So, we thought it was time to review what we achieved and consider our next steps. 168 00:18:02,820 --> 00:18:10,340 We felt confident enough with the QuickShare and the protocol, and to start searching for logical vulnerabilities. 169 00:18:10,340 --> 00:18:12,900 And we certainly found some gold there. 170 00:18:13,940 --> 00:18:19,520 And one observation that we made is the code is extremely generic. 171 00:18:19,520 --> 00:18:21,460 With the handler class for each packet type. 172 00:18:21,460 --> 00:18:26,500 Additionally, the code is filled with threads and async methods all over the place. 173 00:18:26,500 --> 00:18:30,860 Those specs made us think it will be a good place to find vulnerability in it. 174 00:18:31,820 --> 00:18:37,660 So, the first logical vulnerability that we'll introduce is a file acceptance bypass. 175 00:18:38,440 --> 00:18:46,760 As mentioned earlier, to send a file, the initiator first need to send an introduction packet and wait for an accept packet from the responder. 176 00:18:46,760 --> 00:18:51,660 After that, the initiator will send a payload transfer packet containing our file. 177 00:18:51,680 --> 00:18:59,460 We thought to ourself, wait, what happen if we skip the introduction and accept packets and send the payload transfer packet directly? 178 00:18:59,740 --> 00:19:08,900 We found out that the file will be sent anyway, resulting a complete bypass of the acceptance of the, of the, of the file from the responder side. 179 00:19:09,040 --> 00:19:13,720 To make things even better, we discovered that this approach works for any discovery mode. 180 00:19:13,720 --> 00:19:27,500 So, even if your device is configured to accept files from your context, for example, we could still be able to send files to your device without requiring your acceptance and without any notification. 181 00:19:27,600 --> 00:19:34,000 It's on, also important to note that this visibility mode doesn't grant a file transfer capability. 182 00:19:34,000 --> 00:19:44,320 Even if someone else can see your device for some reason in the quick share app, they won't be able to send files if your device is set to accept files only from your context. 183 00:19:44,320 --> 00:19:52,820 This is because the protocol includes a verification step at the beginning to ensure the sender is authorized to send files to the receiver. 184 00:19:53,640 --> 00:19:55,140 Let's see a demo of it. 185 00:19:55,880 --> 00:20:04,060 So, we have our phone here and we can see that I configured the phone to allow, um, files acceptance only from your device. 186 00:20:04,760 --> 00:20:06,880 Now, let's see the quick share folder. 187 00:20:06,880 --> 00:20:09,660 We can see that it's empty on the phone. 188 00:20:09,720 --> 00:20:12,300 And now, let's see our attacker, uh, machine. 189 00:20:12,580 --> 00:20:15,920 We used our tools, send files with bypass. 190 00:20:16,240 --> 00:20:21,580 And a few seconds after it, you could see that nothing happened on the phone, but our file is there. 191 00:20:21,660 --> 00:20:32,760 So, we implement the file in the phone without any notification on any Android device that has quick share and we can do it, um, even on any, any Windows device that has quick share in it. 192 00:20:32,760 --> 00:20:34,060 Pretty awesome, right? 193 00:20:35,000 --> 00:20:36,140 Thank you. 194 00:20:39,340 --> 00:20:42,740 So, let's continue with our next logical vulnerability. 195 00:20:42,740 --> 00:20:47,400 Forcing victim device to connect to a rogue Wi-Fi access point. 196 00:20:48,140 --> 00:20:54,560 In the context of data transfer, a medium refers to a channel through which information is transmitted. 197 00:20:54,560 --> 00:21:01,780 When sending a file, quick share checks whether there's a need to upgrade the medium and to achieve better transmission, uh, speed. 198 00:21:01,780 --> 00:21:04,840 For example, upgrade from Bluetooth to Wi-Fi. 199 00:21:04,840 --> 00:21:08,440 As shown on the slide, there are various possible upgrades connections. 200 00:21:09,240 --> 00:21:19,540 When discussing, um, bandwidth upgrades negotiation, uh, bandwidth upgrade negotiations, sorry, it's important to reference previous research that highlighted a specific attack scenario. 201 00:21:19,540 --> 00:21:27,140 In that study, researchers forced an Android device to connect to a rogue Wi-Fi network to carry out a man in the middle attack. 202 00:21:27,520 --> 00:21:32,100 This attack lasted maximum of 30 seconds and hence been mitigated by Google. 203 00:21:32,100 --> 00:21:42,840 Today, if your Android device receive an, uh, bandwidth upgrade negotiation packet via quick share, other internet connections, uh, will not be redirected to that Wi-Fi network. 204 00:21:43,160 --> 00:21:45,020 But what about Windows? 205 00:21:45,020 --> 00:21:50,640 We have noticed that, uh, one of the upgrade methods is through Wi-Fi hotspot access point. 206 00:21:50,640 --> 00:21:58,120 Basically doing transfer, the initiator creates a temporary hotspot and send the responder the credentials to connect to this hotspot. 207 00:21:58,120 --> 00:22:02,100 By the way, this process can be initiated from the responder side as well. 208 00:22:02,140 --> 00:22:06,000 When the transfer is completed, this hotspot is getting closed. 209 00:22:06,320 --> 00:22:15,240 But we've noticed that during this time, the internet connection of the responder device is still working, even though it's connected to our hotspot. 210 00:22:15,620 --> 00:22:24,560 We started to sniff the network packets from the initiator device and we found out that all the traffic from the responder side is going through our device. 211 00:22:25,100 --> 00:22:31,620 Meaning that we can get a man in the middle for the time of the transfer and sniff the entire responder traffic. 212 00:22:31,640 --> 00:22:37,660 So, I can connect every phone that has a quick share to my hotspot and create a man in the middle attack. 213 00:22:37,660 --> 00:22:41,300 Now, I will continue and explain what we can be done next. 214 00:22:44,680 --> 00:22:45,720 Cool. 215 00:22:46,140 --> 00:22:49,980 Okay, yeah, so, uh, that was pretty awesome. 216 00:22:50,080 --> 00:22:56,740 Forcing any Windows device with quick share to connect to our rogue Wi-Fi AP. 217 00:22:56,740 --> 00:23:02,260 Um, but let's see what we managed to uh, find so far. 218 00:23:02,260 --> 00:23:06,320 So, so far we found eight vulnerabilities in total. 219 00:23:06,320 --> 00:23:13,140 The most critical vulnerability in our opinion was the one that allowed us to send a file without approval. 220 00:23:13,560 --> 00:23:23,460 But we were looking really for the holy grail as I mentioned at the beginning, which was an RCE vulnerability that we still did not have. 221 00:23:23,660 --> 00:23:37,120 Thus, just like turning standard stones into deadly drones, that sounds pretty much impossible, we decided that we are going to chain these vulnerabilities into an RCE. 222 00:23:37,980 --> 00:23:44,380 So, so far we had four primary abilities using these eight vulnerabilities. 223 00:23:44,380 --> 00:23:51,240 We could create files in the victim's downloads folder without any requirement for acceptance or authorization. 224 00:23:51,280 --> 00:24:03,680 We could force the target device, the target Windows device, into connecting to a different Wi-Fi network and um, connect to the internet through it, but only for about 30 seconds. 225 00:24:04,240 --> 00:24:09,800 Um, we could also crash quick share in multiple ways that we found using the fuzzer. 226 00:24:09,800 --> 00:24:27,160 And finally, um, we could also reproduce the reproducible timeout that we saw in, that uh, the fuzzer found, which um, can force quick share into an endless loop continuously opening a file that we choose from the victim's download folder. 227 00:24:28,520 --> 00:24:47,400 Talking about the men, the Wi-Fi men in the middle vulnerability, as um, uh, as I mentioned, it allows us to see all the Wi-Fi traffic of the victim for about 30 seconds and, but with that being said, as you all know, encryption is a standard for today's application layer, 228 00:24:47,400 --> 00:24:58,360 so manipulating the traffic in 30 seconds to achieve an RCE is not likely to succeed except in very specific situations. 229 00:24:59,220 --> 00:25:05,120 However, we then had a crucial insight and I want you to remember that. 230 00:25:05,120 --> 00:25:20,860 The insight was that the downloads folder to which we can write any file that we want using our exploits on quick share for Windows, is the same folder where browsers place their downloaded files. 231 00:25:21,840 --> 00:25:24,460 This led us to an idea. 232 00:25:24,600 --> 00:25:32,500 What if we could overwrite an executable that was downloaded into the downloads folder before it runs? 233 00:25:32,500 --> 00:25:50,620 If being a man in the middle can somehow help us know which executable files are downloaded by the browser to the downloads folder, and if we can somehow overwrite them using our abilities, then this would lead to an RCE. 234 00:25:50,680 --> 00:25:58,160 That is because we'll be able to replace the executable with our malicious one and then the user will run our executable. 235 00:25:58,880 --> 00:26:13,720 The simplest example would be a victim that downloads the VS code installer for instance and then we overwrite it with one of our vulnerabilities right after it was downloaded and then the victim runs our executable instead of the VS code installer. 236 00:26:14,460 --> 00:26:20,840 Now of course we still did not have uh sorry, yeah, okay. 237 00:26:20,840 --> 00:26:35,020 Now of course we still did not have the exact abilities we needed but since being a man in the middle might help us anyway, we decided to start with making the Wi-Fi connection last longer as it was only active for about 30 seconds. 238 00:26:35,240 --> 00:26:45,620 To do that, we tried to think of a way to prevent QuickShare from returning to its original Wi-Fi network once a file sending session was over. 239 00:26:46,060 --> 00:26:49,200 Then, a very simple solution came up. 240 00:26:49,200 --> 00:26:55,640 Crashing QuickShare right after the Wi-Fi connection to our road Wi-Fi AP was established. 241 00:26:56,280 --> 00:27:16,600 The result was that if we force a Windows computer with QuickShare to connect to our Wi-Fi network, to our malicious Wi-Fi network, and then instantly crash the app with one of our denial of service vulnerabilities that a fuzzer found, we get a forever lasting Wi-Fi connection to our Wi-Fi hotspot. 242 00:27:17,980 --> 00:27:26,560 As regards to the crash, the fear of it preventing us from continuing to exploit the app did not exist. 243 00:27:26,560 --> 00:27:27,100 Why? 244 00:27:27,100 --> 00:27:36,600 Because when QuickShare is installed, it creates a scheduled task that runs every 15 minutes and runs QuickShare if it's not already running. 245 00:27:36,600 --> 00:27:41,600 So we don't really lose the ability to further exploit QuickShare. 246 00:27:41,880 --> 00:27:45,980 And actually, we will continue to exploit QuickShare. 247 00:27:45,980 --> 00:27:51,840 And this is why these two links are only the first part of our RCE attack chain. 248 00:27:52,060 --> 00:27:59,460 So far, we established a lasting Wi-Fi connection that we expect to come in handy for identifying downloaded file. 249 00:27:59,880 --> 00:28:05,300 Now, let's understand the reason for why it was actually so helpful for doing that. 250 00:28:05,800 --> 00:28:08,420 And the reason, and this is the reason. 251 00:28:08,420 --> 00:28:10,380 Metadata matters. 252 00:28:10,520 --> 00:28:18,240 Seeing this tweet by Talberry, which by the way, had a different picture that we changed, but can still be found in Tal's feed. 253 00:28:18,240 --> 00:28:24,100 Uh, we thought that it explains exactly how we leveraged the Wi-Fi connection. 254 00:28:24,200 --> 00:28:32,200 It was indeed true that files are normally downloaded over HTTPS, meaning that the traffic is encrypted. 255 00:28:32,260 --> 00:28:39,020 However, there were still two very important elements in the metadata of an HTTPS session. 256 00:28:39,200 --> 00:28:42,960 The first one is the server's domain. 257 00:28:43,040 --> 00:28:54,540 The encryption of HTTPS is performed using the TLS protocol, of course, and the TLS session starts with an unencrypted client hello message that is sent by the client. 258 00:28:54,740 --> 00:29:05,020 Normally, a server name indication extension is being added to this message, which indicates the domain of the server. 259 00:29:05,140 --> 00:29:13,360 That means that if you are exposed to victim's traffic, you can determine the domains that they communicate with. 260 00:29:14,140 --> 00:29:25,540 The second element that is present of part of the metadata of an HTTPS session is the approximate size of data that is being transferred in the session. 261 00:29:25,620 --> 00:29:33,240 When a file is being downloaded over HTTPS, it's normally downloaded in one TCP session. 262 00:29:33,440 --> 00:29:47,800 Even though encryption might add some random padding, the amount of data that is being transferred from the server to the client during a file download of the same file stays relatively the same. 263 00:29:48,240 --> 00:30:02,040 In addition, the size of an executable file is usually much bigger than the size of other pages or resources that may be transferred from a website to a client in an HTTPS session. 264 00:30:03,160 --> 00:30:22,420 The conclusion is that if we know the domain that the client communicated with, and we know that there is a large file that is being downloaded along with its approximate size, then that means that we can also very accurately guess the name of the downloaded file. 265 00:30:22,420 --> 00:30:37,420 For instance, if we know that 95 megabytes were downloaded from code.visual studio.com, then we can confidently say that the latest VS Code installer was probably downloaded. 266 00:30:38,900 --> 00:30:44,580 Think of the most popular installers for software that you use, like VS Code, for example. 267 00:30:44,660 --> 00:30:55,100 Entering the VS Code download page leads you to a single download button for a single VS Code version that matches your OS and is the newest one. 268 00:30:55,180 --> 00:31:03,520 This installer has the size of 95 megabytes, which is larger than any other resource in the website. 269 00:31:03,700 --> 00:31:12,880 And so this really narrows down the options and makes it much easier to detect a download of the latest VS Code installer. 270 00:31:13,020 --> 00:31:19,480 Most websites that offer such installers have really only one relevant file. 271 00:31:20,300 --> 00:31:26,780 And so we framed and defined our new man-in-the-middle technique more specifically. 272 00:31:26,960 --> 00:31:34,240 In order to be as precise as possible, we understood that we need to define what we call domain paths. 273 00:31:34,420 --> 00:31:42,720 A domain path is a sequence of domains to which we expect the victim to access until the download starts. 274 00:31:42,720 --> 00:31:46,080 Let's look at Notepad++ for example. 275 00:31:46,500 --> 00:31:55,540 Clicking on the download button in its website does not download the executable from the Notepad++.org domain. 276 00:31:55,580 --> 00:31:59,260 Instead it references github.com. 277 00:31:59,260 --> 00:32:05,280 Then github.com actually redirects a request to another domain and this is the final domain. 278 00:32:05,280 --> 00:32:08,960 It's objects.githubusercontent.com. 279 00:32:09,120 --> 00:32:11,600 And the file is downloaded from there. 280 00:32:11,600 --> 00:32:19,540 If we just look at this final domain, we won't be able to determine that the downloaded file is the installer of Notepad++. 281 00:32:19,900 --> 00:32:25,040 However, what we can do is to follow access to previous domains. 282 00:32:25,540 --> 00:32:39,800 Basically what we need to do is to see that in a limited time period, Notepad++.org was accessed followed by access to github.com and then to objects.githubusercontent.com. 283 00:32:39,800 --> 00:32:49,860 If that access to the final domain downloads a file with an approximate size as we expect for the installer, then we can determine that it's actually the installer. 284 00:32:50,980 --> 00:32:56,400 To conclude, this is how we define the new man-in-the-middle technique that we created. 285 00:32:56,400 --> 00:33:06,620 We start by creating a mapping between domain paths to executables that match these domain paths and their sizes. 286 00:33:06,880 --> 00:33:16,500 Then we wait until the victim hits a certain domain path in a limited time frame and we start counting the downloaded data. 287 00:33:17,040 --> 00:33:25,720 Finally, we check if the size of the downloaded data is equal or a bit bigger than the installer that matches this domain path. 288 00:33:26,020 --> 00:33:32,540 If it does, then we are safe to determine that the expected installer was indeed the one that was downloaded. 289 00:33:33,600 --> 00:33:38,460 And so we change another link to our RCE chain. 290 00:33:38,460 --> 00:33:43,860 Now we can also detect the name of an executable that is downloaded by a victim. 291 00:33:44,960 --> 00:33:52,160 That being said, for an RCE, we still need the ability to override files as we mentioned before. 292 00:33:52,740 --> 00:33:55,260 And we did not have it yet. 293 00:33:56,060 --> 00:34:02,840 But it doesn't have to be a generic ability to override files using our vulnerabilities in Quick Share. 294 00:34:02,840 --> 00:34:10,340 It could be an ability that allows to override files only in our very specific situation when files are being downloaded. 295 00:34:10,480 --> 00:34:17,520 So what we're trying to do is to override Google Chrome's download while it's still ongoing. 296 00:34:17,840 --> 00:34:21,640 So first let's understand Chrome's basic download process. 297 00:34:21,860 --> 00:34:29,640 When Chrome downloads a file, no matter which file it is, it starts by checking if the file name already exists. 298 00:34:29,660 --> 00:34:35,340 If it does, it adds a number surrounded by parentheses to the file name for the download. 299 00:34:35,520 --> 00:34:38,280 If it doesn't, it keeps the original name. 300 00:34:39,200 --> 00:34:47,620 Then it starts downloading the file but into a temporary file with a CR download extension. 301 00:34:48,920 --> 00:35:02,320 Once the download is fully complete and we got all the contents of the file and only then Chrome renames the temporary file to the actual name of the downloaded file and the download is then really complete. 302 00:35:02,900 --> 00:35:21,920 But since Chrome checks whether the name already exists and decides on the final name for the downloaded file, only when it starts the download, we thought that there is good potential to create confusion if we send the file with the same name in the middle of this process. 303 00:35:21,920 --> 00:35:29,820 That will be after the name for the uh final downloaded file will already be final and has been decided on. 304 00:35:31,200 --> 00:35:43,060 We thought it might leave Chrome to fail in renaming the downloaded file, the temporary file, to the final name for the file, leaving our file in place. 305 00:35:43,060 --> 00:35:49,620 But how can we know the name of the downloaded file and still send it before the download is complete? 306 00:35:49,840 --> 00:36:01,740 We must wait for the final TCP packet to be sent from the server in order to determine the approximate size of the file and then as a result of it, determine its name. 307 00:36:02,200 --> 00:36:12,760 In order to prevent the download from being finished in Chrome , what we do is that we hold this last packet as the man in the middle and do not forward it to the client. 308 00:36:14,420 --> 00:36:29,920 So we try to send a file with the exact same name right before the download is finished, hoping Chrome might be confused and will fail to rename the temporary file leaving our file as the presumably downloaded file. 309 00:36:31,220 --> 00:36:34,580 But unfortunately this did not work. 310 00:36:34,580 --> 00:36:43,340 As a result, Chrome just overwrote the file that we sent, finishing its download successfully, deleting our malicious file. 311 00:36:43,340 --> 00:36:45,920 But this was not the end of it. 312 00:36:45,920 --> 00:36:51,300 We understood that we need to find a way to prevent Chrome from overriding our file. 313 00:36:51,340 --> 00:36:58,420 Then it was not long until we figured out that we maybe already have this ability. 314 00:36:59,260 --> 00:37:19,140 If you remember from before, one of the reproducible uh uh timeouts that the father found um was uh a vulnerability that allowed us to bring QuickShare into a state where it continuously opens and closes any file that we want from the downloads folder of the victim. 315 00:37:19,420 --> 00:37:24,560 We thought that we can utilize this vulnerability just right for this case. 316 00:37:24,840 --> 00:37:36,140 What we hoped for is that maybe if the file is endlessly opened and closed, the file that we sent, then this will fail Chrome in overwriting it. 317 00:37:36,700 --> 00:37:46,180 So the result was that our hopes actually became reality and Chrome actually failed in overwriting our file. 318 00:37:46,520 --> 00:37:50,200 It was actually the best scenario that we hoped for. 319 00:37:50,200 --> 00:38:05,680 Once Chrome finishes the download, the result is that it deletes the temporary CR download file, it fails to overwrite our malicious file, and it's user interface, Chrome reports that the download was finished successfully. 320 00:38:05,680 --> 00:38:13,320 And clicking on the downloaded file in Chrome's downloads window actually runs our malicious file. 321 00:38:17,020 --> 00:38:18,800 Thank you. 322 00:38:19,140 --> 00:38:21,080 Yeah I know it's cool. 323 00:38:21,320 --> 00:38:32,920 Okay so uh and so another two links were added to our RCE chain completing it into the RCE chain attack that we were aiming for from the beginning. 324 00:38:33,820 --> 00:38:43,760 And finally we prepared a demonstration video presenting the entire quick show RCE attack chain for you to see it in action. 325 00:38:43,760 --> 00:39:09,200 So let's watch it and before we do, I'll mention that the video starts um uh when the video starts we'll see the attacker's computer, we'll see that the attacker enabled a mobile hotspot on his Windows computer, and then we'll move on to the victim computer where we'll see quick share installed. 326 00:39:09,420 --> 00:39:18,940 Um and we'll start by seeing how the attacker forces the victim into connecting to the wifi hotspot that the attacker created. 327 00:39:18,940 --> 00:39:21,000 Okay so let's begin. 328 00:39:21,160 --> 00:39:28,800 So we can see that the hotspot is enabled and we can see just the IP address on that hotspot. 329 00:39:29,240 --> 00:39:34,620 Now we run our tool and we find nearby victims. 330 00:39:34,620 --> 00:39:36,280 One of them is called test machine. 331 00:39:36,280 --> 00:39:37,320 We choose test machine. 332 00:39:37,320 --> 00:39:38,780 This is test machine. 333 00:39:38,780 --> 00:39:51,540 And now it's connected to safe breach but we force it into connecting to our test AP and crash creature to make it um to make the wifi connection last and now we see all the domains that the victim accesses. 334 00:39:51,540 --> 00:39:58,600 Now the victim goes into the Spotify website to download the Spotify for Windows installer. 335 00:39:58,860 --> 00:40:02,660 We can see that the downloads folder is just empty, there's nothing inside. 336 00:40:03,860 --> 00:40:06,600 Now the victim downloads the file. 337 00:40:06,620 --> 00:40:09,340 Let's see what happens uh with the download. 338 00:40:09,340 --> 00:40:10,720 It's now complete. 339 00:40:10,720 --> 00:40:14,720 We click it and our malware runs instead. 340 00:40:14,940 --> 00:40:17,460 Now, thank you. 341 00:40:18,500 --> 00:40:21,320 Now let's do the same with Notepad++. 342 00:40:21,320 --> 00:40:27,700 We go into it's website, download the newest version of Notepad++ for Windows. 343 00:40:27,700 --> 00:40:29,780 The victim downloads the file. 344 00:40:29,780 --> 00:40:31,160 The download starts. 345 00:40:31,160 --> 00:40:35,460 You can see that we can do that for many installers. 346 00:40:35,460 --> 00:40:38,560 So the download is now finished. 347 00:40:38,560 --> 00:40:43,960 And the victim runs it and it's again our malicious executable. 348 00:40:45,060 --> 00:40:46,420 Okay. 349 00:40:48,100 --> 00:40:49,900 Thank you. 350 00:40:50,140 --> 00:40:50,600 Now let's see what happens when we run the vulnerability. 351 00:40:50,600 --> 00:40:51,860 Pretty cool, right? 352 00:40:53,900 --> 00:41:03,300 So I know it might seem like we found exactly the vulnerabilities that we needed to build this RCE chain but in reality it was a bit different. 353 00:41:03,300 --> 00:41:06,100 In fact we discovered two additional vulnerabilities. 354 00:41:06,100 --> 00:41:18,500 One allowed us to send file to the parent folder of downloads folder and other let us crash quick share by leveraging some of the findings from all magic dot research that he presented last April. 355 00:41:18,500 --> 00:41:27,280 However this vulnerability weren't used, were not used in the RCE chain and could not be exploited for remote code execution. 356 00:41:27,280 --> 00:41:33,220 We'll share more details about them in our upcoming blog post that will be published after this talk. 357 00:41:33,320 --> 00:41:39,240 Overall we identified ten distinct vulnerabilities along with additional bug in Chrome. 358 00:41:39,960 --> 00:41:45,060 We ported all of these vulnerabilities to Google at the end of January this year. 359 00:41:45,060 --> 00:41:50,080 They've confirmed, they've confirmed they fixed every one of them, every one of them. 360 00:41:50,560 --> 00:41:54,700 Google decided to issue two CVEs for these ten vulnerabilities. 361 00:41:54,700 --> 00:42:02,080 The first CVE addresses how two of the vulnerabilities can combine, can force a persistent Wi-Fi connection. 362 00:42:02,080 --> 00:42:07,260 The second CVE deals with bypassing the file approval dialogue in Windows. 363 00:42:08,060 --> 00:42:14,820 Google was very responsive throughout the process confirming and reproducing each of the vulnerability reported. 364 00:42:14,820 --> 00:42:20,200 We wanted to thank them for their collaboration and for addressing these issues. 365 00:42:20,200 --> 00:42:22,120 Here's the official response. 366 00:42:22,120 --> 00:42:28,800 You can take a moment to read it now but of course it will be included in the published presentation. 367 00:42:29,460 --> 00:42:31,320 Give you a few seconds. 368 00:42:34,160 --> 00:42:42,700 So we've covered pretty much everything about technical flow and now it's time to talk about the takeaways which are just as important. 369 00:42:43,020 --> 00:42:49,480 Our first and most significant takeaway is that standard stones may sometimes be forged into deadly drones. 370 00:42:49,480 --> 00:42:55,280 What we mean by that is that as a hacker you often have limited tools at your disposal. 371 00:42:55,280 --> 00:42:59,020 You might achieve something but it's not exactly what you are aiming for. 372 00:42:59,020 --> 00:43:11,340 Reflecting on our research we believe that even a seamlessly basic or unimpressive abilities can sometime be transformed into much much greater uh much more powerful uh capabilities. 373 00:43:11,380 --> 00:43:20,160 We're all familiar with the typical chains of vulnerabilities that addresses non-issue like bypassing stack cookies or other memory corruption mitigations. 374 00:43:20,160 --> 00:43:22,520 But it's not always so straightforward. 375 00:43:22,520 --> 00:43:28,920 Sometimes you might have unconventional abilities like forcing an endless loop that repeatedly opens a file . 376 00:43:28,920 --> 00:43:32,000 For real, who thought this ability might be helpful? 377 00:43:32,420 --> 00:43:39,500 So this can use to create a very unconventional flows that still allow you to achieve your ultimate goal. 378 00:43:40,020 --> 00:43:43,020 The next takeaway shifts to the defensive side. 379 00:43:43,020 --> 00:43:48,320 Many products leave non-issue and bugs unfixed due to prioritization. 380 00:43:48,340 --> 00:43:55,660 Often this issue seems to pose no security risk or only minor ones that doesn't require immediate attention. 381 00:43:55,660 --> 00:44:05,840 However, addressing these non-issue bugs or minor security risk can sometime be crucial for mitigating much greater risk that you might not be aware of. 382 00:44:05,840 --> 00:44:19,820 For example, if we didn't have the DOS vulnerability that allows QuickShare to crash, we wouldn't be able to have a established stable Wi-Fi connection and this would have completely disabled our RC chain. 383 00:44:19,860 --> 00:44:30,420 Lastly, it's crucial for organizations to develop software and develop software to focus not only on specific programming mistakes like memory corruption bugs. 384 00:44:30,420 --> 00:44:42,180 When evaluating a program's security, it's important to take a broader perspective and consider whether a simple logic or intended behavior might also introduce security risk. 385 00:44:42,980 --> 00:44:44,100 That's pretty much it. 386 00:44:44,100 --> 00:44:46,680 Here's the QR code for our repository. 387 00:44:46,680 --> 00:44:47,920 Feel free to take a picture. 388 00:44:47,920 --> 00:44:51,440 It has a lot of tools to play with QuickShare. 389 00:44:51,440 --> 00:44:55,740 You can also find the contact details for all and myself. 390 00:44:55,740 --> 00:44:59,600 And we'd like to thank everyone for joining to our session. 391 00:44:59,600 --> 00:45:01,100 We hope you enjoyed it. 392 00:45:01,100 --> 00:45:02,120 Thank you. 393 00:45:02,120 --> 00:45:03,000 Thank you, everyone. 394 00:45:04,280 --> 00:45:05,140 Thank you. 395 00:45:05,140 --> 00:45:06,400 It was really fun.