WEBVTT

00:00.000 --> 00:02.080
I'd like to introduce Or and Shmuel.

00:02.600 --> 00:04.300
Here we go.

00:04.300 --> 00:05.740
And away we go.

00:11.890 --> 00:14.310
Okay, hi everyone.

00:14.370 --> 00:17.070
Today we will present Quickshare.

00:17.070 --> 00:22.250
Sharing is caring about an RC attack chain on Quickshare.

00:22.610 --> 00:28.630
So, my name is Or Yair, I'm the security research team lead at Safe Breach.

00:28.630 --> 00:32.450
I have more than 6 years of experience in security research.

00:32.450 --> 00:40.790
My past research included some research on Linux environments, embedded devices, Android devices and more.

00:41.010 --> 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.

00:51.440 --> 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.

00:58.620 --> 01:04.500
A little bit about myself, I have 6 years of experience in the cyber security industry.

01:04.500 --> 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.

01:19.980 --> 01:24.200
Okay, so let's see what we're going to talk about today.

01:24.520 --> 01:32.080
We'll start with what is Quickshare and why we chose it as our primary target for this research.

01:32.080 --> 01:37.940
We'll then move on to get a brief overview about the protocol that Quickshare uses.

01:37.940 --> 01:44.260
We'll then see the first research approach that we took for this research which is fuzzing.

01:44.260 --> 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.

01:58.740 --> 02:08.200
Then we'll see how we managed to assemble a very unconventional and creative RCE attack chain from these vulnerabilities.

02:08.380 --> 02:16.100
And we'll conclude with takeaways and a link to the GitHub repository of all the tools that we created.

02:16.240 --> 02:19.520
So, what is Quickshare?

02:20.040 --> 02:26.420
Quickshare is Google's nearby file transfer solution for Android just like Apple's AirDrop.

02:27.060 --> 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.

02:40.680 --> 02:45.920
So, we know what the talk is about, but why did we even choose to target Quickshare?

02:46.820 --> 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.

02:58.300 --> 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.

03:16.720 --> 03:22.180
Moreover, Quickshare performs file transfers using several communication methods.

03:22.180 --> 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.

03:32.080 --> 03:39.440
As far as we knew, Quickshare was Google's first Windows app to use all these communication methods.

03:39.520 --> 03:45.440
In general, most of Google's services that are used on Windows are in the browser.

03:45.620 --> 03:50.960
This was a first of a kind for Google and thus chances for mistakes were higher.

03:52.040 --> 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.

04:02.160 --> 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.

04:12.120 --> 04:16.160
And Quickshare and NearbyShare didn't even exist back then.

04:16.160 --> 04:19.620
It was just an API for third party applications.

04:19.760 --> 04:24.880
The Windows app did not exist also of course.

04:26.160 --> 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.

04:33.580 --> 04:36.900
It was not all of it, but some of it at least.

04:37.200 --> 04:44.240
And in addition, we just could not find any CVEs related to Quickshare.

04:44.840 --> 04:52.640
Concluding all of these facts together led us to evaluate Quickshare as a valuable and likely to be breached target.

04:53.340 --> 05:00.080
Our final goal was to achieve something that was never achieved using Quickshare.

05:00.080 --> 05:03.580
And that was remote code execution.

05:05.200 --> 05:09.900
Starting our journey, we needed to understand Quickshare's protocol of course.

05:10.460 --> 05:19.120
Therefore, the first thing we did was to find the most basic functions that Quickshare uses to send and receive packets.

05:19.460 --> 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.

05:33.580 --> 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.

05:42.320 --> 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.

05:50.820 --> 05:57.200
That is because each packet that was received was parsed into an offline frame object.

05:57.200 --> 06:06.220
But the offline frame object was not a normal object as its class was generated by protobuf.

06:06.520 --> 06:11.180
In here we can see the protobuf definition of offline frame.

06:11.180 --> 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.

06:25.180 --> 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.

06:44.640 --> 06:49.520
And so, our first tool for this research was born pretty fast.

06:49.560 --> 06:53.600
We needed a tool that will provide us abilities to watch the communication.

06:53.620 --> 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.

07:02.980 --> 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.

07:09.480 --> 07:12.200
Thank you all.

07:14.520 --> 07:15.280
Cool.

07:15.280 --> 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.

07:21.320 --> 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.

07:34.040 --> 07:37.920
QuickShare uses the Nearby Connections API with its own implementation.

07:38.780 --> 07:42.560
Let's start with reviewing the Nearby Connections API.

07:42.560 --> 07:46.420
So it's based on protobuf which is used to serialize structure data.

07:46.560 --> 07:47.900
It's mostly encrypted.

07:47.900 --> 07:51.720
The encryption is handled using Google's UK2 library.

07:51.720 --> 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.

08:00.360 --> 08:05.800
It has multiple connections strategies such as peer-to-peer, star and cluster.

08:06.500 --> 08:11.420
We will focus on the peer-to-peer strategy because it's the one used by QuickShare.

08:11.900 --> 08:17.860
In this strategy there's initiator and the responder functioning much like a client and server.

08:17.940 --> 08:24.700
In our protocol overview we will examine packets that send during a file transfer from a phone to a PC.

08:25.120 --> 08:29.260
The first stage of communication is a connection request packet.

08:29.260 --> 08:33.320
Following that the initiator start with encryption handshake.

08:33.320 --> 08:38.980
The encryption handshake starts by sending a UK client init packet to the responder.

08:39.540 --> 08:48.580
Then the responder replies with a UK server initialization packet and finally the initiator responds with a UK client finish packet.

08:48.800 --> 08:56.240
At this point the UK encryption handshake is successfully completed ensuring that all subsequent packets will be encrypted.

08:56.500 --> 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.

09:06.280 --> 09:09.400
At this point QuickShare proprietary communication begins.

09:09.400 --> 09:15.200
This proprietary communication uses various types of packets provided by the nearby connections API.

09:15.200 --> 09:17.460
Let's review some of those packets.

09:17.800 --> 09:22.440
So these packets as all mentioned are called offline frames.

09:22.440 --> 09:26.820
Here you can see all types of packets that can be used within the protocol.

09:27.380 --> 09:32.760
So far we've seen two types, the connection request and the connection response.

09:34.180 --> 09:39.860
In our talk we will focus on two types, payload transfer and bandwidth upgrade negotiation.

09:40.480 --> 09:45.240
Now let's explore how QuickShare manages the connections at this stage.

09:45.440 --> 09:51.480
Just a quick reminder, this is where we stopped earlier, just when the proprietary communication begins.

09:52.280 --> 09:57.820
The next sequence of packets were payload transfer, which both sides send to each other.

09:58.300 --> 10:01.280
Using our sniffer, let's examine those packets.

10:01.500 --> 10:09.360
As shown in the image, the payload transfer packet contains binary data, which was initially unclear to us.

10:09.760 --> 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.

10:25.720 --> 10:33.540
So both sides exchanged this paired key encryption packet, followed by a paired key result packet.

10:33.600 --> 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.

10:43.700 --> 10:47.660
These modes allow the user to control who can send data to them.

10:47.660 --> 10:53.280
For example, the user can choose that only their contact will be able to send data to them.

10:54.180 --> 11:00.360
After this stage is done, the initiator that wants to send the file sends an introduction packet.

11:00.920 --> 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.

11:09.600 --> 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.

11:20.900 --> 11:26.100
After the responder accepts, the initiator sends the file using a payload transfer packet.

11:26.100 --> 11:27.260
And that's it.

11:27.280 --> 11:30.580
After this stage is completed, the file will be sent.

11:30.620 --> 11:33.240
Let's see a short demo of this overview.

11:33.880 --> 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.

11:46.240 --> 11:52.740
So choosing the target device, the phone gets prompted with an accept or decline dialogue.

11:52.740 --> 11:56.700
The phone chooses to accept and the file is on the phone.

11:57.040 --> 11:59.280
It's very simple, right?

12:00.120 --> 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.

12:12.660 --> 12:19.440
We chose the most straightforward infrastructure for fuzzing in Windows, which is WinAFL of course.

12:19.740 --> 12:28.840
For instrumentation we used Dynamario and since Protobuf is being used everywhere, we wanted a solution that supports Protobuf as well.

12:29.040 --> 12:35.080
Google developed a Leap Protobuf mutator that can be used with WinAFL.

12:35.080 --> 12:41.560
Combining these solutions together helped us a lot in the fuzzing process and let's now discuss our approach.

12:41.560 --> 12:48.460
So our goal is to fuzz an entire session of file sending rather than just individual packets.

12:48.460 --> 12:51.860
However, there might be a potential issue with this approach.

12:51.860 --> 12:53.080
Can you guess what?

12:54.180 --> 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.

13:01.280 --> 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.

13:17.980 --> 13:23.520
So we started to look for a way to accept automatically every file that is being sent.

13:23.520 --> 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.

13:30.360 --> 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.

13:39.760 --> 13:44.420
So we just needed to patch this if statement to make it work all the time.

13:44.540 --> 13:46.080
And that's exactly what we did.

13:46.080 --> 13:50.320
We located the relevant binary and we patched it.

13:50.320 --> 13:55.560
Now our fuzzing target automatically accept every file every time.

13:56.020 --> 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.

14:05.960 --> 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.

14:15.140 --> 14:18.080
The structure we decided was straightforward.

14:18.100 --> 14:22.840
Four bytes for length followed by a serialized offline frame of that length.

14:23.680 --> 14:27.500
At this stage, we were ready to start fuzzing QuickShare for Windows.

14:27.500 --> 14:31.800
However, as you can see on the screen, this process was quite slow.

14:32.820 --> 14:36.140
So we started to check again what makes us slow.

14:36.140 --> 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.

14:44.680 --> 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.

14:53.340 --> 14:58.160
Meaning it's closing sockets, it's opening new ones, and those things take time.

14:58.660 --> 15:03.140
On top of that, another function is called with the name remove endpoint.

15:03.140 --> 15:06.300
And it has 500 milliseconds flip at the end.

15:06.300 --> 15:07.240
Think about it.

15:07.240 --> 15:12.820
After each file is being sent, there's half of a second slip time.

15:12.820 --> 15:15.660
That's huge when you're talking about fuzzing speed.

15:15.660 --> 15:20.140
So again, we patched the relevant models and prevented this behavior.

15:21.220 --> 15:23.580
Those patches help us a lot as you can see.

15:23.580 --> 15:25.880
Made our fuzzing process much faster.

15:25.880 --> 15:27.360
About ten times.

15:29.160 --> 15:32.940
Unfortunately, the speed improvement created a persistent issue for us.

15:32.940 --> 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.

15:45.620 --> 15:51.980
As a result, we received numerous crashes report and we were unable to reproduce.

15:52.120 --> 15:59.100
Therefore, we made a decision to abandon this approach and revert back to the original functionality of QuickShare.

15:59.280 --> 16:07.620
Despite it's been slower performance over time, the fuzzer did yield several positive uh several positive positive results.

16:07.620 --> 16:09.020
Let's discuss that.

16:09.460 --> 16:12.580
Overall, there were four reproducible crashes.

16:12.580 --> 16:18.720
We attempted to explore further the exploitation of those crashes, but they are unlikely to be exploited.

16:18.720 --> 16:25.500
But now we have the ability to crush QuickShare and who knows, that ability might be handy in the future.

16:26.300 --> 16:31.460
Another very interesting uh finding by the fuzzer was a reproducible timeout.

16:31.460 --> 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.

16:40.300 --> 16:45.280
If the file opens successfully, this indicates that the file is already exist.

16:45.280 --> 16:49.760
In response, QuickShare appends an index number suffix to the file name.

16:49.760 --> 16:53.420
It's very similar to what browsers do when you download the file.

16:54.960 --> 17:00.440
So, QuickShare tries to add um the suffix before the file extension.

17:00.440 --> 17:04.860
As you can see on the screen, that's why it splits the name into two parts.

17:04.860 --> 17:06.880
The name and the extension.

17:07.100 --> 17:12.820
But what happens if the name before the extension has a null terminator in it?

17:13.580 --> 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.

17:21.920 --> 17:25.420
It reads the string up only to the null terminator.

17:25.420 --> 17:28.980
This causes QuickShare to get stuck in an endless loop.

17:29.140 --> 17:35.840
Continuously incrementing indexes while mistakenly thinking it's searching for available index.

17:35.980 --> 17:40.900
When in fact, it's trying to open the same files open over and over again.

17:41.520 --> 17:43.740
So, to sum things up.

17:43.740 --> 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.

17:51.780 --> 17:57.060
Even when we identified some crashes, it wasn't necessarily always exploitable.

17:57.540 --> 18:02.540
So, we thought it was time to review what we achieved and consider our next steps.

18:02.820 --> 18:10.340
We felt confident enough with the QuickShare and the protocol, and to start searching for logical vulnerabilities.

18:10.340 --> 18:12.900
And we certainly found some gold there.

18:13.940 --> 18:19.520
And one observation that we made is the code is extremely generic.

18:19.520 --> 18:21.460
With the handler class for each packet type.

18:21.460 --> 18:26.500
Additionally, the code is filled with threads and async methods all over the place.

18:26.500 --> 18:30.860
Those specs made us think it will be a good place to find vulnerability in it.

18:31.820 --> 18:37.660
So, the first logical vulnerability that we'll introduce is a file acceptance bypass.

18:38.440 --> 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.

18:46.760 --> 18:51.660
After that, the initiator will send a payload transfer packet containing our file.

18:51.680 --> 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?

18:59.740 --> 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.

19:09.040 --> 19:13.720
To make things even better, we discovered that this approach works for any discovery mode.

19:13.720 --> 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.

19:27.600 --> 19:34.000
It's on, also important to note that this visibility mode doesn't grant a file transfer capability.

19:34.000 --> 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.

19:44.320 --> 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.

19:53.640 --> 19:55.140
Let's see a demo of it.

19:55.880 --> 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.

20:04.760 --> 20:06.880
Now, let's see the quick share folder.

20:06.880 --> 20:09.660
We can see that it's empty on the phone.

20:09.720 --> 20:12.300
And now, let's see our attacker, uh, machine.

20:12.580 --> 20:15.920
We used our tools, send files with bypass.

20:16.240 --> 20:21.580
And a few seconds after it, you could see that nothing happened on the phone, but our file is there.

20:21.660 --> 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.

20:32.760 --> 20:34.060
Pretty awesome, right?

20:35.000 --> 20:36.140
Thank you.

20:39.340 --> 20:42.740
So, let's continue with our next logical vulnerability.

20:42.740 --> 20:47.400
Forcing victim device to connect to a rogue Wi-Fi access point.

20:48.140 --> 20:54.560
In the context of data transfer, a medium refers to a channel through which information is transmitted.

20:54.560 --> 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.

21:01.780 --> 21:04.840
For example, upgrade from Bluetooth to Wi-Fi.

21:04.840 --> 21:08.440
As shown on the slide, there are various possible upgrades connections.

21:09.240 --> 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.

21:19.540 --> 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.

21:27.520 --> 21:32.100
This attack lasted maximum of 30 seconds and hence been mitigated by Google.

21:32.100 --> 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.

21:43.160 --> 21:45.020
But what about Windows?

21:45.020 --> 21:50.640
We have noticed that, uh, one of the upgrade methods is through Wi-Fi hotspot access point.

21:50.640 --> 21:58.120
Basically doing transfer, the initiator creates a temporary hotspot and send the responder the credentials to connect to this hotspot.

21:58.120 --> 22:02.100
By the way, this process can be initiated from the responder side as well.

22:02.140 --> 22:06.000
When the transfer is completed, this hotspot is getting closed.

22:06.320 --> 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.

22:15.620 --> 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.

22:25.100 --> 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.

22:31.640 --> 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.

22:37.660 --> 22:41.300
Now, I will continue and explain what we can be done next.

22:44.680 --> 22:45.720
Cool.

22:46.140 --> 22:49.980
Okay, yeah, so, uh, that was pretty awesome.

22:50.080 --> 22:56.740
Forcing any Windows device with quick share to connect to our rogue Wi-Fi AP.

22:56.740 --> 23:02.260
Um, but let's see what we managed to uh, find so far.

23:02.260 --> 23:06.320
So, so far we found eight vulnerabilities in total.

23:06.320 --> 23:13.140
The most critical vulnerability in our opinion was the one that allowed us to send a file without approval.

23:13.560 --> 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.

23:23.660 --> 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.

23:37.980 --> 23:44.380
So, so far we had four primary abilities using these eight vulnerabilities.

23:44.380 --> 23:51.240
We could create files in the victim's downloads folder without any requirement for acceptance or authorization.

23:51.280 --> 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.

24:04.240 --> 24:09.800
Um, we could also crash quick share in multiple ways that we found using the fuzzer.

24:09.800 --> 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.

24:28.520 --> 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,

24:47.400 --> 24:58.360
so manipulating the traffic in 30 seconds to achieve an RCE is not likely to succeed except in very specific situations.

24:59.220 --> 25:05.120
However, we then had a crucial insight and I want you to remember that.

25:05.120 --> 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.

25:21.840 --> 25:24.460
This led us to an idea.

25:24.600 --> 25:32.500
What if we could overwrite an executable that was downloaded into the downloads folder before it runs?

25:32.500 --> 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.

25:50.680 --> 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.

25:58.880 --> 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.

26:14.460 --> 26:20.840
Now of course we still did not have uh sorry, yeah, okay.

26:20.840 --> 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.

26:35.240 --> 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.

26:46.060 --> 26:49.200
Then, a very simple solution came up.

26:49.200 --> 26:55.640
Crashing QuickShare right after the Wi-Fi connection to our road Wi-Fi AP was established.

26:56.280 --> 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.

27:17.980 --> 27:26.560
As regards to the crash, the fear of it preventing us from continuing to exploit the app did not exist.

27:26.560 --> 27:27.100
Why?

27:27.100 --> 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.

27:36.600 --> 27:41.600
So we don't really lose the ability to further exploit QuickShare.

27:41.880 --> 27:45.980
And actually, we will continue to exploit QuickShare.

27:45.980 --> 27:51.840
And this is why these two links are only the first part of our RCE attack chain.

27:52.060 --> 27:59.460
So far, we established a lasting Wi-Fi connection that we expect to come in handy for identifying downloaded file.

27:59.880 --> 28:05.300
Now, let's understand the reason for why it was actually so helpful for doing that.

28:05.800 --> 28:08.420
And the reason, and this is the reason.

28:08.420 --> 28:10.380
Metadata matters.

28:10.520 --> 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.

28:18.240 --> 28:24.100
Uh, we thought that it explains exactly how we leveraged the Wi-Fi connection.

28:24.200 --> 28:32.200
It was indeed true that files are normally downloaded over HTTPS, meaning that the traffic is encrypted.

28:32.260 --> 28:39.020
However, there were still two very important elements in the metadata of an HTTPS session.

28:39.200 --> 28:42.960
The first one is the server's domain.

28:43.040 --> 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.

28:54.740 --> 29:05.020
Normally, a server name indication extension is being added to this message, which indicates the domain of the server.

29:05.140 --> 29:13.360
That means that if you are exposed to victim's traffic, you can determine the domains that they communicate with.

29:14.140 --> 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.

29:25.620 --> 29:33.240
When a file is being downloaded over HTTPS, it's normally downloaded in one TCP session.

29:33.440 --> 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.

29:48.240 --> 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.

30:03.160 --> 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.

30:22.420 --> 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.

30:38.900 --> 30:44.580
Think of the most popular installers for software that you use, like VS Code, for example.

30:44.660 --> 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.

30:55.180 --> 31:03.520
This installer has the size of 95 megabytes, which is larger than any other resource in the website.

31:03.700 --> 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.

31:13.020 --> 31:19.480
Most websites that offer such installers have really only one relevant file.

31:20.300 --> 31:26.780
And so we framed and defined our new man-in-the-middle technique more specifically.

31:26.960 --> 31:34.240
In order to be as precise as possible, we understood that we need to define what we call domain paths.

31:34.420 --> 31:42.720
A domain path is a sequence of domains to which we expect the victim to access until the download starts.

31:42.720 --> 31:46.080
Let's look at Notepad++ for example.

31:46.500 --> 31:55.540
Clicking on the download button in its website does not download the executable from the Notepad++.org domain.

31:55.580 --> 31:59.260
Instead it references github.com.

31:59.260 --> 32:05.280
Then github.com actually redirects a request to another domain and this is the final domain.

32:05.280 --> 32:08.960
It's objects.githubusercontent.com.

32:09.120 --> 32:11.600
And the file is downloaded from there.

32:11.600 --> 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++.

32:19.900 --> 32:25.040
However, what we can do is to follow access to previous domains.

32:25.540 --> 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.

32:39.800 --> 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.

32:50.980 --> 32:56.400
To conclude, this is how we define the new man-in-the-middle technique that we created.

32:56.400 --> 33:06.620
We start by creating a mapping between domain paths to executables that match these domain paths and their sizes.

33:06.880 --> 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.

33:17.040 --> 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.

33:26.020 --> 33:32.540
If it does, then we are safe to determine that the expected installer was indeed the one that was downloaded.

33:33.600 --> 33:38.460
And so we change another link to our RCE chain.

33:38.460 --> 33:43.860
Now we can also detect the name of an executable that is downloaded by a victim.

33:44.960 --> 33:52.160
That being said, for an RCE, we still need the ability to override files as we mentioned before.

33:52.740 --> 33:55.260
And we did not have it yet.

33:56.060 --> 34:02.840
But it doesn't have to be a generic ability to override files using our vulnerabilities in Quick Share.

34:02.840 --> 34:10.340
It could be an ability that allows to override files only in our very specific situation when files are being downloaded.

34:10.480 --> 34:17.520
So what we're trying to do is to override Google Chrome's download while it's still ongoing.

34:17.840 --> 34:21.640
So first let's understand Chrome's basic download process.

34:21.860 --> 34:29.640
When Chrome downloads a file, no matter which file it is, it starts by checking if the file name already exists.

34:29.660 --> 34:35.340
If it does, it adds a number surrounded by parentheses to the file name for the download.

34:35.520 --> 34:38.280
If it doesn't, it keeps the original name.

34:39.200 --> 34:47.620
Then it starts downloading the file but into a temporary file with a CR download extension.

34:48.920 --> 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.

35:02.900 --> 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.

35:21.920 --> 35:29.820
That will be after the name for the uh final downloaded file will already be final and has been decided on.

35:31.200 --> 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.

35:43.060 --> 35:49.620
But how can we know the name of the downloaded file and still send it before the download is complete?

35:49.840 --> 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.

36:02.200 --> 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.

36:14.420 --> 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.

36:31.220 --> 36:34.580
But unfortunately this did not work.

36:34.580 --> 36:43.340
As a result, Chrome just overwrote the file that we sent, finishing its download successfully, deleting our malicious file.

36:43.340 --> 36:45.920
But this was not the end of it.

36:45.920 --> 36:51.300
We understood that we need to find a way to prevent Chrome from overriding our file.

36:51.340 --> 36:58.420
Then it was not long until we figured out that we maybe already have this ability.

36:59.260 --> 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.

37:19.420 --> 37:24.560
We thought that we can utilize this vulnerability just right for this case.

37:24.840 --> 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.

37:36.700 --> 37:46.180
So the result was that our hopes actually became reality and Chrome actually failed in overwriting our file.

37:46.520 --> 37:50.200
It was actually the best scenario that we hoped for.

37:50.200 --> 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.

38:05.680 --> 38:13.320
And clicking on the downloaded file in Chrome's downloads window actually runs our malicious file.

38:17.020 --> 38:18.800
Thank you.

38:19.140 --> 38:21.080
Yeah I know it's cool.

38:21.320 --> 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.

38:33.820 --> 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.

38:43.760 --> 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.

39:09.420 --> 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.

39:18.940 --> 39:21.000
Okay so let's begin.

39:21.160 --> 39:28.800
So we can see that the hotspot is enabled and we can see just the IP address on that hotspot.

39:29.240 --> 39:34.620
Now we run our tool and we find nearby victims.

39:34.620 --> 39:36.280
One of them is called test machine.

39:36.280 --> 39:37.320
We choose test machine.

39:37.320 --> 39:38.780
This is test machine.

39:38.780 --> 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.

39:51.540 --> 39:58.600
Now the victim goes into the Spotify website to download the Spotify for Windows installer.

39:58.860 --> 40:02.660
We can see that the downloads folder is just empty, there's nothing inside.

40:03.860 --> 40:06.600
Now the victim downloads the file.

40:06.620 --> 40:09.340
Let's see what happens uh with the download.

40:09.340 --> 40:10.720
It's now complete.

40:10.720 --> 40:14.720
We click it and our malware runs instead.

40:14.940 --> 40:17.460
Now, thank you.

40:18.500 --> 40:21.320
Now let's do the same with Notepad++.

40:21.320 --> 40:27.700
We go into it's website, download the newest version of Notepad++ for Windows.

40:27.700 --> 40:29.780
The victim downloads the file.

40:29.780 --> 40:31.160
The download starts.

40:31.160 --> 40:35.460
You can see that we can do that for many installers.

40:35.460 --> 40:38.560
So the download is now finished.

40:38.560 --> 40:43.960
And the victim runs it and it's again our malicious executable.

40:45.060 --> 40:46.420
Okay.

40:48.100 --> 40:49.900
Thank you.

40:50.140 --> 40:50.600
Now let's see what happens when we run the vulnerability.

40:50.600 --> 40:51.860
Pretty cool, right?

40:53.900 --> 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.

41:03.300 --> 41:06.100
In fact we discovered two additional vulnerabilities.

41:06.100 --> 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.

41:18.500 --> 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.

41:27.280 --> 41:33.220
We'll share more details about them in our upcoming blog post that will be published after this talk.

41:33.320 --> 41:39.240
Overall we identified ten distinct vulnerabilities along with additional bug in Chrome.

41:39.960 --> 41:45.060
We ported all of these vulnerabilities to Google at the end of January this year.

41:45.060 --> 41:50.080
They've confirmed, they've confirmed they fixed every one of them, every one of them.

41:50.560 --> 41:54.700
Google decided to issue two CVEs for these ten vulnerabilities.

41:54.700 --> 42:02.080
The first CVE addresses how two of the vulnerabilities can combine, can force a persistent Wi-Fi connection.

42:02.080 --> 42:07.260
The second CVE deals with bypassing the file approval dialogue in Windows.

42:08.060 --> 42:14.820
Google was very responsive throughout the process confirming and reproducing each of the vulnerability reported.

42:14.820 --> 42:20.200
We wanted to thank them for their collaboration and for addressing these issues.

42:20.200 --> 42:22.120
Here's the official response.

42:22.120 --> 42:28.800
You can take a moment to read it now but of course it will be included in the published presentation.

42:29.460 --> 42:31.320
Give you a few seconds.

42:34.160 --> 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.

42:43.020 --> 42:49.480
Our first and most significant takeaway is that standard stones may sometimes be forged into deadly drones.

42:49.480 --> 42:55.280
What we mean by that is that as a hacker you often have limited tools at your disposal.

42:55.280 --> 42:59.020
You might achieve something but it's not exactly what you are aiming for.

42:59.020 --> 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.

43:11.380 --> 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.

43:20.160 --> 43:22.520
But it's not always so straightforward.

43:22.520 --> 43:28.920
Sometimes you might have unconventional abilities like forcing an endless loop that repeatedly opens a file .

43:28.920 --> 43:32.000
For real, who thought this ability might be helpful?

43:32.420 --> 43:39.500
So this can use to create a very unconventional flows that still allow you to achieve your ultimate goal.

43:40.020 --> 43:43.020
The next takeaway shifts to the defensive side.

43:43.020 --> 43:48.320
Many products leave non-issue and bugs unfixed due to prioritization.

43:48.340 --> 43:55.660
Often this issue seems to pose no security risk or only minor ones that doesn't require immediate attention.

43:55.660 --> 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.

44:05.840 --> 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.

44:19.860 --> 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.

44:30.420 --> 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.

44:42.980 --> 44:44.100
That's pretty much it.

44:44.100 --> 44:46.680
Here's the QR code for our repository.

44:46.680 --> 44:47.920
Feel free to take a picture.

44:47.920 --> 44:51.440
It has a lot of tools to play with QuickShare.

44:51.440 --> 44:55.740
You can also find the contact details for all and myself.

44:55.740 --> 44:59.600
And we'd like to thank everyone for joining to our session.

44:59.600 --> 45:01.100
We hope you enjoyed it.

45:01.100 --> 45:02.120
Thank you.

45:02.120 --> 45:03.000
Thank you, everyone.

45:04.280 --> 45:05.140
Thank you.

45:05.140 --> 45:06.400
It was really fun.

