start	end	text
0	5740	I'd like to introduce Or and Shmuel. Here we go. And away we go.
11890	19850	Okay, hi everyone. Today we will present Quickshare. Sharing is caring about an RC attack
19850	27950	chain on Quickshare. So, my name is Or Yair, I'm the security research team lead at Safe
27950	33390	Breach. I have more than 6 years of experience in security research. My past research
33390	41130	included some research on Linux environments, embedded devices, Android devices and more. And
41130	46170	for more than 3 years now my main focus lies in vulnerability research in a Windows operating
46170	53900	system and third party apps that run on it. Hi everyone, my name is Shmuel Cohen and I'm
53900	59260	excited to be here today and present the finding of our recent research. A little bit about
59260	65660	myself, I have 6 years of experience in the cyber security industry. Previously I conducted
65660	71220	APT malware research within the checkpoint research group and currently I'm part of the
71220	75680	Safe Breach original research team where I focus primarily on vulnerability research on
75680	85840	various products. Okay, so let's see what we're going to talk about today. We'll start with
85840	92400	what is Quickshare and why we chose it as our primary target for this research. We'll then
92400	99820	move on to get a brief overview about the protocol that Quickshare uses. We'll then see the
99820	105140	first research approach that we took for this research which is fuzzing. We'll see the
105140	110420	research approach shift um that we took that led us to other vulnerabilities and we'll see the
110420	116180	vulnerability discovery that um that we had, vulnerability discoveries that we had um
116180	122300	based on these two approaches. Then we'll see how we managed to assemble a very
122300	129680	unconventional and creative RCE attack chain from these vulnerabilities. And we'll conclude
129680	138020	with takeaways and a link to the GitHub repository of all the tools that we created. So, what
138020	144760	is Quickshare? Quickshare is Google's nearby file transfer solution for Android just like
144760	152260	Apple's AirDrop. Quickshare was formerly known as NearbyShare and then last January at CES,
152260	158760	Google and Samsung decided to combine their file sharing solutions into a single one and call it
158760	165200	Quickshare. So, we know what the talk is about, but why did we even choose to target
165200	171620	Quickshare? Last July, Google has officially released a Windows version of Quickshare for
171620	176720	Windows, allowing to share files between Windows computers to any other device with
176720	183160	Quickshare. An interesting fact from Google's announcement about Quickshare at CES is that
183160	188860	they are working with leading PC manufacturers, just like LG, to expand Quickshare to Windows
188860	194860	PCs as a pre-installed app, making Quickshare for Windows a much more attractive target.
196720	202380	Moreover, Quickshare performs file transfers using several communication methods. It
202380	208840	supports WebRTC, Bluetooth, Wi-Fi, NFC, Wi-Fi direct and even sending files over a Wi-Fi
208840	216500	hotspot of one of the devices. As far as we knew, Quickshare was Google's first Windows app
216500	222620	to use all these communication methods. In general, most of Google's services that are used
222620	229240	on Windows are in the browser. This was a first of a kind for Google and thus chances for
229240	236160	mistakes were higher. Looking for past research, the only one that we could really find was a
236160	240720	research called Nearby Threats, reversing, analyzing and attacking Google's nearby
240720	246240	connections on Android. The research analyzed Google's Nearby Connections API, that is the
246240	253480	API that NearbyShare and later on Quickshare use in their implementations. And Quickshare and
253480	259940	NearbyShare didn't even exist back then. It was just an API for third party applications. The
259940	269100	Windows app did not exist also of course. Another interesting fact was that we saw that most of
269100	274560	the applications code can be found in open source repositories by Google. It was not all of
274560	282880	it, but some of it at least. And in addition, we just could not find any CVEs related to
282880	289520	Quickshare. Concluding all of these facts together led us to evaluate Quickshare as a valuable
289520	298380	and likely to be breached target. Our final goal was to achieve something that was never achieved
298380	306960	using Quickshare. And that was remote code execution. Starting our journey, we needed to
306960	313660	understand Quickshare's protocol of course. Therefore, the first thing we did was to find the
313660	320540	most basic functions that Quickshare uses to send and receive packets. Once we find such
320540	325460	functions, if they are generic and are used for all communication methods, then we'll be able
325460	332120	to get a clear view of all packets that are being sent and received by the app in their binary
332120	338440	form. Then, just as we needed, we found the read and write functions as part of a base class
338440	344380	that was called base endpoint channel. Deeper inside the read function, we were able to
344380	349300	understand that the packets that are being sent and received are packets of a type called
349300	355380	offline frame. That is because each packet that was received was parsed into an
355380	362980	offline frame object. But the offline frame object was not a normal object as its class was
362980	371760	generated by protobuf. In here we can see the protobuf definition of offline frame. And using
371760	379140	protobuf, this proto file is being compiled into CPP files that define the offline frame and
379140	386400	provide functions to serialize it to bytes and deserialize it from bytes. But don't be
386400	392540	alarmed by the name offline frame too much because offline frame is the base type for almost
392540	398680	all packet types that we are going to discuss in this talk and so from now on we will just
398680	407140	mostly call them packets instead of offline frames. And so, our first tool for this
407140	412460	research was born pretty fast. We needed a tool that will provide us abilities to watch the
412460	418060	communication. So we wrote a DLL that hooks the read and write functions and textually logs
418060	423920	each packet that is being sent and received with all of its fields. This tool allowed us to
423920	429480	understand the protocol much better and Shmuel will be the one to elaborate on what we learned.
429480	438460	Thank you all. Cool. So now that we can sniff QuickShare packets, it's time to take a deep
438460	445360	dive of the protocol used by QuickShare. So there's an API called Nearby Connections API and
445360	451900	it's used to discover, connect and exchange data with nearby devices in real time regardless
451900	457000	of network connectivity. QuickShare uses the Nearby Connections API with its own
457000	463480	implementation. Let's start with reviewing the Nearby Connections API. So it's based on
463480	468580	protobuf which is used to serialize structure data. It's mostly encrypted. The encryption is
468580	474540	handled using Google's UK2 library. Each app is uniquely identified within the Nearby
474540	481220	Connections API by a service ID that is provided by the app's developers. It has multiple
481220	487660	connections strategies such as peer-to-peer, star and cluster. We will focus on the
487660	493080	peer-to-peer strategy because it's the one used by QuickShare. In this strategy there's
493080	498780	initiator and the responder functioning much like a client and server. In our protocol
498780	505720	overview we will examine packets that send during a file transfer from a phone to a PC. The
505720	510720	first stage of communication is a connection request packet. Following that the initiator
510720	516920	start with encryption handshake. The encryption handshake starts by sending a UK client init
516920	523680	packet to the responder. Then the responder replies with a UK server initialization packet
523680	530020	and finally the initiator responds with a UK client finish packet. At this point the UK
530020	535120	encryption handshake is successfully completed ensuring that all subsequent packets will be
535120	540840	encrypted. Next the responder sends a connection response packet indicating that it's
540840	547000	accepted the connection and the initiator responds with a similar packet back. At this point
547000	551540	QuickShare proprietary communication begins. This proprietary communication uses various
551540	557460	types of packets provided by the nearby connections API. Let's review some of those packets.
557800	563960	So these packets as all mentioned are called offline frames. Here you can see all types of
563960	570320	packets that can be used within the protocol. So far we've seen two types, the connection
570320	577100	request and the connection response. In our talk we will focus on two types, payload transfer
577100	583760	and bandwidth upgrade negotiation. Now let's explore how QuickShare manages the connections
583760	589440	at this stage. Just a quick reminder, this is where we stopped earlier, just when the
589440	595420	proprietary communication begins. The next sequence of packets were payload transfer, which
595420	602220	both sides send to each other. Using our sniffer, let's examine those packets. As shown in the
602220	609360	image, the payload transfer packet contains binary data, which was initially unclear to us.
609760	614240	However, with the help of another portable file that we found in the Chromium open source
614240	620320	project, we were able to decode this binary data and we discovered that the payload transfer
620320	629660	packet contained another packet called paired key encryption. So both sides exchanged this paired
629660	634960	key encryption packet, followed by a paired key result packet. We want to understand the
634960	639860	purpose of these packets and with the help of our sniffer, we observed that they used among
639860	646460	other things to enforce device visibility modes. These modes allow the user to control who can
646460	652000	send data to them. For example, the user can choose that only their contact will be able to
652000	658840	send data to them. After this stage is done, the initiator that wants to send the file sends an
658840	664140	introduction packet. As a result, the responder is prompted with a file introduction
664140	670160	dialogue on the computer saying that the initiator would like to send the file. To receive
670160	676520	the file, the responder simply needs to press the accept button, which will cause QuickShare to
676520	683760	send an accept packet to the initiator. After the responder accepts, the initiator sends the
683760	689300	file using a payload transfer packet. And that's it. After this stage is completed, the file
689300	695620	will be sent. Let's see a short demo of this overview. So on the right side we have a phone
695620	701680	and on the left side we have a PC which QuickShare has installed and we'll just show how a file
701680	710140	transfer normally sent from a PC to a phone. So choosing the target device, the phone gets
710140	716180	prompted with an accept or decline dialogue. The phone chooses to accept and the file is on
716180	723780	the phone. It's very simple, right? So now that we have basic understanding of how QuickShare
723780	730760	file transfer works under the hood, we can proceed to fuzz this flow on QuickShare for
730760	737500	Windows. We chose the most straightforward infrastructure for fuzzing in Windows, which is
737500	744100	WinAFL of course. For instrumentation we used Dynamario and since Protobuf is being used
744100	750400	everywhere, we wanted a solution that supports Protobuf as well. Google developed a
750400	757060	Leap Protobuf mutator that can be used with WinAFL. Combining these solutions together
757220	763200	helped us a lot in the fuzzing process and let's now discuss our approach. So our goal is to
763200	769360	fuzz an entire session of file sending rather than just individual packets. However, there
769360	775240	might be a potential issue with this approach. Can you guess what? So as we already
775240	780080	mentioned, when a file is sent, an accept or decline buttons are being prompted in the
780080	785660	responder side. Since we want to fuzz all stages of communication, including when a file is
785660	792580	being accepted, we needed our fuzzer, our fuzzing target, sorry, to accept every file that's
792580	798560	being sent to it automatically without the need of the user to press the accept button. So we
798560	803900	started to look for a way to accept automatically every file that is being sent. Our first
803900	807960	approach was to reverse engineer the relevant models and patch it in such a way that every
807960	813920	file will be accepted automatically. But fortunately for us, within the Chromium open
813920	818600	source project, we found out that Google already implemented a built-in feature called
818600	824800	auto accept. So we just needed to patch this if statement to make it work all the time. And
824800	830840	that's exactly what we did. We located the relevant binary and we patched it. Now our
830840	839140	fuzzing target automatically accept every file every time. Next, we needed to implement a
839140	844540	harness that could handle an entire session during each fuzzing iteration rather than just
844540	850000	sending single packets. To achieve that, we created a simple binary format to encapsulate all
850000	856040	packets for an entire session which would be sent each fuzzing iteration. The structure we
856040	861720	decided was straightforward. Four bytes for length followed by a serialized offline frame of
861720	868320	that length. At this stage, we were ready to start fuzzing QuickShare for Windows. However, as
868320	874960	you can see on the screen, this process was quite slow. So we started to check again what
874960	880560	makes us slow. And with the help of QuickShare logs, we found that after each file is being
880560	886660	transferred, the stop advertising function is getting called. And as the name suggests, this
886660	892220	function used to stop the advertising of the device and later on it's starting advertising
892220	898160	back again. Meaning it's closing sockets, it's opening new ones, and those things take time.
898660	904500	On top of that, another function is called with the name remove endpoint. And it has 500
904500	911860	milliseconds flip at the end. Think about it. After each file is being sent, there's half of a
911860	917700	second slip time. That's huge when you're talking about fuzzing speed. So again, we patched the
917700	924080	relevant models and prevented this behavior. Those patches help us a lot as you can see. Made
924080	930940	our fuzzing process much faster. About ten times. Unfortunately, the speed improvement
930940	936340	created a persistent issue for us. The combination of instrumentation, which significantly
936340	942040	slows down the fuzzing target, and our patch to increase the file transfer speed, led to an
942040	947580	unheld race condition that was too complex to manage. As a result, we received numerous
947580	954520	crashes report and we were unable to reproduce. Therefore, we made a decision to abandon this
954520	960120	approach and revert back to the original functionality of QuickShare. Despite it's been
960120	965380	slower performance over time, the fuzzer did yield several positive uh several positive
965380	972800	positive results. Let's discuss that. Overall, there were four reproducible crashes. We
972800	977760	attempted to explore further the exploitation of those crashes, but they are unlikely to be
977760	983880	exploited. But now we have the ability to crush QuickShare and who knows, that ability might
983880	989760	be handy in the future. Another very interesting uh finding by the fuzzer was a
989760	995800	reproducible timeout. You see, when QuickShare receives a file, it first check the
995800	1001140	existence of a file with the same name by attempting to open it. If the file opens
1001140	1006400	successfully, this indicates that the file is already exist. In response, QuickShare
1006400	1012060	appends an index number suffix to the file name. It's very similar to what browsers do when
1012060	1019640	you download the file. So, QuickShare tries to add um the suffix before the file
1019640	1025060	extension. As you can see on the screen, that's why it splits the name into two parts. The
1025060	1031380	name and the extension. But what happens if the name before the extension has a null
1031380	1038280	terminator in it? The result is that anything added after the null terminator is irrelevant
1038820	1044760	when the file name is passed to the open function. It reads the string up only to the null
1044760	1049800	terminator. This causes QuickShare to get stuck in an endless loop. Continuously
1049800	1056220	incrementing indexes while mistakenly thinking it's searching for available index. When
1056220	1063900	in fact, it's trying to open the same files open over and over again. So, to sum things up. We
1063900	1069160	managed to get um the fuzzer working constantly, but each fuzzing iteration took too much
1069160	1074660	time, making the process quite slow. Even when we identified some crashes, it wasn't
1074660	1080880	necessarily always exploitable. So, we thought it was time to review what we achieved and
1080880	1087560	consider our next steps. We felt confident enough with the QuickShare and the protocol, and
1087560	1094540	to start searching for logical vulnerabilities. And we certainly found some gold there. And
1094540	1100580	one observation that we made is the code is extremely generic. With the handler class for
1100580	1105720	each packet type. Additionally, the code is filled with threads and async methods all over
1105720	1112720	the place. Those specs made us think it will be a good place to find vulnerability in it. So,
1112720	1118820	the first logical vulnerability that we'll introduce is a file acceptance bypass. As
1118820	1123500	mentioned earlier, to send a file, the initiator first need to send an introduction packet
1123500	1129000	and wait for an accept packet from the responder. After that, the initiator will send a
1129000	1134960	payload transfer packet containing our file. We thought to ourself, wait, what happen if we
1134960	1140400	skip the introduction and accept packets and send the payload transfer packet directly? We
1140400	1145940	found out that the file will be sent anyway, resulting a complete bypass of the acceptance
1145940	1150700	of the, of the, of the file from the responder side. To make things even better, we
1150700	1155460	discovered that this approach works for any discovery mode. So, even if your device is
1155460	1161260	configured to accept files from your context, for example, we could still be able to send
1161260	1167780	files to your device without requiring your acceptance and without any notification. It's
1167780	1172920	on, also important to note that this visibility mode doesn't grant a file transfer
1172920	1178100	capability. Even if someone else can see your device for some reason in the quick share app,
1178100	1183480	they won't be able to send files if your device is set to accept files only from your
1183480	1188580	context. This is because the protocol includes a verification step at the beginning to
1188580	1196660	ensure the sender is authorized to send files to the receiver. Let's see a demo of it. So, we
1196660	1201800	have our phone here and we can see that I configured the phone to allow, um, files
1201800	1207460	acceptance only from your device. Now, let's see the quick share folder. We can see that
1207460	1213440	it's empty on the phone. And now, let's see our attacker, uh, machine. We used our
1213440	1218740	tools, send files with bypass. And a few seconds after it, you could see that nothing
1218740	1223500	happened on the phone, but our file is there. So, we implement the file in the phone
1223500	1229000	without any notification on any Android device that has quick share and we can do it, um,
1229000	1235480	even on any, any Windows device that has quick share in it. Pretty awesome, right? Thank
1235480	1244440	you. So, let's continue with our next logical vulnerability. Forcing victim device to
1244440	1252060	connect to a rogue Wi-Fi access point. In the context of data transfer, a medium refers to a
1252060	1256900	channel through which information is transmitted. When sending a file, quick share checks
1256900	1261920	whether there's a need to upgrade the medium and to achieve better transmission, uh, speed.
1261920	1266460	For example, upgrade from Bluetooth to Wi-Fi. As shown on the slide, there are various
1266460	1272600	possible upgrades connections. When discussing, um, bandwidth upgrades negotiation, uh,
1272600	1277080	bandwidth upgrade negotiations, sorry, it's important to reference previous research that
1277080	1282320	highlighted a specific attack scenario. In that study, researchers forced an Android device
1282320	1288280	to connect to a rogue Wi-Fi network to carry out a man in the middle attack. This attack
1288280	1293080	lasted maximum of 30 seconds and hence been mitigated by Google. Today, if your Android
1293080	1298040	device receive an, uh, bandwidth upgrade negotiation packet via quick share, other
1298040	1304140	internet connections, uh, will not be redirected to that Wi-Fi network. But what about
1304140	1310020	Windows? We have noticed that, uh, one of the upgrade methods is through Wi-Fi hotspot access
1310020	1315180	point. Basically doing transfer, the initiator creates a temporary hotspot and send the
1315180	1319520	responder the credentials to connect to this hotspot. By the way, this process can be
1319520	1324740	initiated from the responder side as well. When the transfer is completed, this hotspot is
1324740	1330340	getting closed. But we've noticed that during this time, the internet connection of the
1330340	1336220	responder device is still working, even though it's connected to our hotspot. We started to
1336220	1340980	sniff the network packets from the initiator device and we found out that all the traffic
1340980	1346860	from the responder side is going through our device. Meaning that we can get a man in the
1346860	1352420	middle for the time of the transfer and sniff the entire responder traffic. So, I can
1352420	1356920	connect every phone that has a quick share to my hotspot and create a man in the middle
1356920	1367900	attack. Now, I will continue and explain what we can be done next. Cool. Okay, yeah, so, uh,
1367900	1374240	that was pretty awesome. Forcing any Windows device with quick share to connect to our
1374760	1383740	rogue Wi-Fi AP. Um, but let's see what we managed to uh, find so far. So, so far we found
1383740	1389620	eight vulnerabilities in total. The most critical vulnerability in our opinion was the one
1389620	1396080	that allowed us to send a file without approval. But we were looking really for the holy
1396080	1402360	grail as I mentioned at the beginning, which was an RCE vulnerability that we still did not
1402360	1410740	have. Thus, just like turning standard stones into deadly drones, that sounds pretty much
1410740	1419260	impossible, we decided that we are going to chain these vulnerabilities into an RCE. So, so
1419260	1425900	far we had four primary abilities using these eight vulnerabilities. We could create files
1425900	1431460	in the victim's downloads folder without any requirement for acceptance or authorization. We
1431460	1436900	could force the target device, the target Windows device, into connecting to a different Wi-Fi
1436900	1445060	network and um, connect to the internet through it, but only for about 30 seconds. Um, we
1445060	1451980	could also crash quick share in multiple ways that we found using the fuzzer. And finally, um,
1451980	1457360	we could also reproduce the reproducible timeout that we saw in, that uh, the fuzzer found,
1457360	1464000	which um, can force quick share into an endless loop continuously opening a file that we
1464000	1471760	choose from the victim's download folder. Talking about the men, the Wi-Fi men in the middle
1471760	1477820	vulnerability, as um, uh, as I mentioned, it allows us to see all the Wi-Fi traffic of the
1477820	1484440	victim for about 30 seconds and, but with that being said, as you all know, encryption is a
1484440	1490880	standard for today's application layer, so manipulating the traffic in 30 seconds to
1490880	1500780	achieve an RCE is not likely to succeed except in very specific situations. However, we then
1500780	1506700	had a crucial insight and I want you to remember that. The insight was that the downloads
1506700	1513500	folder to which we can write any file that we want using our exploits on quick share for
1513500	1523320	Windows, is the same folder where browsers place their downloaded files. This led us to an
1523320	1530120	idea. What if we could overwrite an executable that was downloaded into the downloads
1530120	1536880	folder before it runs? If being a man in the middle can somehow help us know which
1536880	1543940	executable files are downloaded by the browser to the downloads folder, and if we can
1543940	1551180	somehow overwrite them using our abilities, then this would lead to an RCE. That is
1551180	1555940	because we'll be able to replace the executable with our malicious one and then the user
1555940	1562540	will run our executable. The simplest example would be a victim that downloads the VS code
1562540	1568340	installer for instance and then we overwrite it with one of our vulnerabilities right after it
1568340	1575060	was downloaded and then the victim runs our executable instead of the VS code installer. Now
1575060	1582260	of course we still did not have uh sorry, yeah, okay. Now of course we still did not have
1582260	1588380	the exact abilities we needed but since being a man in the middle might help us anyway, we
1588380	1593960	decided to start with making the Wi-Fi connection last longer as it was only active for about 30
1593960	1601080	seconds. To do that, we tried to think of a way to prevent QuickShare from returning to its
1601080	1608200	original Wi-Fi network once a file sending session was over. Then, a very simple solution
1608200	1614560	came up. Crashing QuickShare right after the Wi-Fi connection to our road Wi-Fi AP was
1614560	1621080	established. The result was that if we force a Windows computer with QuickShare to connect to
1621080	1627380	our Wi-Fi network, to our malicious Wi-Fi network, and then instantly crash the app with one
1627380	1633240	of our denial of service vulnerabilities that a fuzzer found, we get a forever lasting Wi-Fi
1633240	1642820	connection to our Wi-Fi hotspot. As regards to the crash, the fear of it preventing us from
1642820	1649320	continuing to exploit the app did not exist. Why? Because when QuickShare is installed, it
1649320	1655840	creates a scheduled task that runs every 15 minutes and runs QuickShare if it's not already
1655840	1663660	running. So we don't really lose the ability to further exploit QuickShare. And actually, we
1663660	1668980	will continue to exploit QuickShare. And this is why these two links are only the first part
1668980	1675640	of our RCE attack chain. So far, we established a lasting Wi-Fi connection that we expect to
1675640	1682380	come in handy for identifying downloaded file. Now, let's understand the reason for why it
1682380	1688980	was actually so helpful for doing that. And the reason, and this is the reason. Metadata
1688980	1695520	matters. Seeing this tweet by Talberry, which by the way, had a different picture that we
1695520	1701820	changed, but can still be found in Tal's feed. Uh, we thought that it explains exactly how we
1701820	1707700	leveraged the Wi-Fi connection. It was indeed true that files are normally downloaded over
1707700	1715060	HTTPS, meaning that the traffic is encrypted. However, there were still two very important
1715060	1723220	elements in the metadata of an HTTPS session. The first one is the server's domain. The
1723220	1728640	encryption of HTTPS is performed using the TLS protocol, of course, and the TLS session
1728640	1736580	starts with an unencrypted client hello message that is sent by the client. Normally, a
1736580	1743820	server name indication extension is being added to this message, which indicates the domain
1743820	1750840	of the server. That means that if you are exposed to victim's traffic, you can determine the
1750840	1757340	domains that they communicate with. The second element that is present of part of the
1757340	1764480	metadata of an HTTPS session is the approximate size of data that is being transferred in the
1764480	1771980	session. When a file is being downloaded over HTTPS, it's normally downloaded in one TCP
1771980	1778460	session. Even though encryption might add some random padding, the amount of data that is
1778460	1784760	being transferred from the server to the client during a file download of the same file
1785420	1791820	stays relatively the same. In addition, the size of an executable file is usually much
1791820	1799800	bigger than the size of other pages or resources that may be transferred from a website to a
1799800	1807440	client in an HTTPS session. The conclusion is that if we know the domain that the client
1807440	1813720	communicated with, and we know that there is a large file that is being downloaded along with
1813720	1821100	its approximate size, then that means that we can also very accurately guess the name of the
1821100	1828780	downloaded file. For instance, if we know that 95 megabytes were downloaded from code.visual
1828780	1836320	studio.com, then we can confidently say that the latest VS Code installer was probably
1836320	1843440	downloaded. Think of the most popular installers for software that you use, like VS Code, for
1843440	1849760	example. Entering the VS Code download page leads you to a single download button for a single
1849760	1858280	VS Code version that matches your OS and is the newest one. This installer has the size of 95
1858280	1865820	megabytes, which is larger than any other resource in the website. And so this really narrows down
1865820	1873280	the options and makes it much easier to detect a download of the latest VS Code installer. Most
1873280	1882820	websites that offer such installers have really only one relevant file. And so we framed and
1882820	1888920	defined our new man-in-the-middle technique more specifically. In order to be as precise as
1888920	1895800	possible, we understood that we need to define what we call domain paths. A domain path is a
1895800	1903260	sequence of domains to which we expect the victim to access until the download starts. Let's
1903260	1910140	look at Notepad++ for example. Clicking on the download button in its website does not
1910140	1919640	download the executable from the Notepad++.org domain. Instead it references github.com. Then
1919640	1925700	github.com actually redirects a request to another domain and this is the final domain. It's
1925700	1933060	objects.githubusercontent.com. And the file is downloaded from there. If we just look at this
1933060	1938320	final domain, we won't be able to determine that the downloaded file is the installer of
1938320	1946700	Notepad++. However, what we can do is to follow access to previous domains. Basically what we
1946700	1954380	need to do is to see that in a limited time period, Notepad++.org was accessed followed by
1954380	1961040	access to github.com and then to objects.githubusercontent.com. If that access to the
1961040	1967320	final domain downloads a file with an approximate size as we expect for the installer, then we
1967320	1974280	can determine that it's actually the installer. To conclude, this is how we define the new
1974280	1980120	man-in-the-middle technique that we created. We start by creating a mapping between domain
1980120	1988720	paths to executables that match these domain paths and their sizes. Then we wait until the
1988720	1994840	victim hits a certain domain path in a limited time frame and we start counting the
1994840	2001700	downloaded data. Finally, we check if the size of the downloaded data is equal or a bit
2001700	2007700	bigger than the installer that matches this domain path. If it does, then we are safe to
2007700	2015160	determine that the expected installer was indeed the one that was downloaded. And so we
2015160	2021840	change another link to our RCE chain. Now we can also detect the name of an executable that
2021840	2029140	is downloaded by a victim. That being said, for an RCE, we still need the ability to
2029140	2037680	override files as we mentioned before. And we did not have it yet. But it doesn't have to be
2037920	2043600	a generic ability to override files using our vulnerabilities in Quick Share. It could be an
2043600	2048960	ability that allows to override files only in our very specific situation when files are
2048960	2055660	being downloaded. So what we're trying to do is to override Google Chrome's download while
2055660	2062700	it's still ongoing. So first let's understand Chrome's basic download process. When Chrome
2062700	2068460	downloads a file, no matter which file it is, it starts by checking if the file name already
2068460	2074360	exists. If it does, it adds a number surrounded by parentheses to the file name for the
2074360	2082600	download. If it doesn't, it keeps the original name. Then it starts downloading the file but
2082600	2091360	into a temporary file with a CR download extension. Once the download is fully complete and
2091360	2096680	we got all the contents of the file and only then Chrome renames the temporary file to the
2096680	2104240	actual name of the downloaded file and the download is then really complete. But since Chrome
2104240	2110720	checks whether the name already exists and decides on the final name for the downloaded file,
2110720	2116760	only when it starts the download, we thought that there is good potential to create confusion
2116760	2123200	if we send the file with the same name in the middle of this process. That will be after the
2123200	2132240	name for the uh final downloaded file will already be final and has been decided on. We thought it
2132240	2139140	might leave Chrome to fail in renaming the downloaded file, the temporary file, to the final
2139140	2145520	name for the file, leaving our file in place. But how can we know the name of the downloaded
2145520	2152920	file and still send it before the download is complete? We must wait for the final TCP packet
2152920	2159660	to be sent from the server in order to determine the approximate size of the file and then as a
2159660	2165900	result of it, determine its name. In order to prevent the download from being finished in
2165900	2171120	Chrome, what we do is that we hold this last packet as the man in the middle and do not forward
2171120	2179520	it to the client. So we try to send a file with the exact same name right before the download is
2179520	2186160	finished, hoping Chrome might be confused and will fail to rename the temporary file leaving our
2186160	2195700	file as the presumably downloaded file. But unfortunately this did not work. As a result, Chrome
2195700	2201740	just overwrote the file that we sent, finishing its download successfully, deleting our
2201740	2208100	malicious file. But this was not the end of it. We understood that we need to find a way to
2208100	2215220	prevent Chrome from overriding our file. Then it was not long until we figured out that we
2215220	2225300	maybe already have this ability. If you remember from before, one of the reproducible uh uh
2225700	2231220	timeouts that the father found um was uh a vulnerability that allowed us to bring
2231220	2236960	QuickShare into a state where it continuously opens and closes any file that we want from the
2236960	2243280	downloads folder of the victim. We thought that we can utilize this vulnerability just right
2243280	2251220	for this case. What we hoped for is that maybe if the file is endlessly opened and closed, the
2251220	2259580	file that we sent, then this will fail Chrome in overwriting it. So the result was that our
2259580	2267020	hopes actually became reality and Chrome actually failed in overwriting our file. It was
2267020	2273260	actually the best scenario that we hoped for. Once Chrome finishes the download, the result is
2273260	2279940	that it deletes the temporary CR download file, it fails to overwrite our malicious file, and
2279940	2286060	it's user interface, Chrome reports that the download was finished successfully. And
2286060	2292080	clicking on the downloaded file in Chrome's downloads window actually runs our malicious
2292080	2306260	file. Thank you. Yeah I know it's cool. Okay so uh and so another two links were added to our
2306260	2311880	RCE chain completing it into the RCE chain attack that we were aiming for from the
2311880	2319640	beginning. And finally we prepared a demonstration video presenting the entire quick show
2319640	2327620	RCE attack chain for you to see it in action. So let's watch it and before we do, I'll mention
2327620	2334720	that the video starts um uh when the video starts we'll see the attacker's computer, we'll
2334720	2344060	see that the attacker enabled a mobile hotspot on his Windows computer, and then we'll move
2344060	2351100	on to the victim computer where we'll see quick share installed. Um and we'll start by
2351100	2357540	seeing how the attacker forces the victim into connecting to the wifi hotspot that the
2357540	2364700	attacker created. Okay so let's begin. So we can see that the hotspot is enabled and we can
2364720	2374900	see just the IP address on that hotspot. Now we run our tool and we find nearby victims. One of
2374900	2379260	them is called test machine. We choose test machine. This is test machine. And now it's
2379260	2385420	connected to safe breach but we force it into connecting to our test AP and crash creature to
2385420	2390480	make it um to make the wifi connection last and now we see all the domains that the victim
2390480	2397480	accesses. Now the victim goes into the Spotify website to download the Spotify for Windows
2397480	2404460	installer. We can see that the downloads folder is just empty, there's nothing inside. Now
2404460	2409720	the victim downloads the file. Let's see what happens uh with the download. It's now
2409720	2420160	complete. We click it and our malware runs instead. Now, thank you. Now let's do the same with
2420160	2427980	Notepad++. We go into it's website, download the newest version of Notepad++ for Windows. The
2427980	2434060	victim downloads the file. The download starts. You can see that we can do that for many
2434060	2441900	installers. So the download is now finished. And the victim runs it and it's again our
2441900	2450140	malicious executable. Okay. Thank you. Now let's see what happens when we run the
2450160	2457600	vulnerability. Pretty cool, right? So I know it might seem like we found exactly the
2457600	2462600	vulnerabilities that we needed to build this RCE chain but in reality it was a bit
2462600	2467260	different. In fact we discovered two additional vulnerabilities. One allowed us to send
2467260	2472620	file to the parent folder of downloads folder and other let us crash quick share by
2472620	2478500	leveraging some of the findings from all magic dot research that he presented last April.
2478500	2484720	However this vulnerability weren't used, were not used in the RCE chain and could not be
2484720	2490140	exploited for remote code execution. We'll share more details about them in our upcoming
2490140	2495300	blog post that will be published after this talk. Overall we identified ten distinct
2495300	2502000	vulnerabilities along with additional bug in Chrome. We ported all of these vulnerabilities
2502000	2507420	to Google at the end of January this year. They've confirmed, they've confirmed they fixed
2507420	2513920	every one of them, every one of them. Google decided to issue two CVEs for these ten
2513920	2519420	vulnerabilities. The first CVE addresses how two of the vulnerabilities can combine, can
2519420	2525240	force a persistent Wi-Fi connection. The second CVE deals with bypassing the file approval
2525240	2532060	dialogue in Windows. Google was very responsive throughout the process confirming and
2532060	2536560	reproducing each of the vulnerability reported. We wanted to thank them for their
2536560	2542940	collaboration and for addressing these issues. Here's the official response. You can take a
2542940	2549980	moment to read it now but of course it will be included in the published presentation. Give
2550100	2558580	you a few seconds. So we've covered pretty much everything about technical flow and now it's
2558580	2564180	time to talk about the takeaways which are just as important. Our first and most
2564180	2569620	significant takeaway is that standard stones may sometimes be forged into deadly drones. What
2569620	2575840	we mean by that is that as a hacker you often have limited tools at your disposal. You might
2575840	2580880	achieve something but it's not exactly what you are aiming for. Reflecting on our research we
2580880	2586400	believe that even a seamlessly basic or unimpressive abilities can sometime be transformed
2586400	2592840	into much much greater uh much more powerful uh capabilities. We're all familiar with the
2592840	2598100	typical chains of vulnerabilities that addresses non-issue like bypassing stack cookies or
2598100	2603100	other memory corruption mitigations. But it's not always so straightforward. Sometimes you
2603100	2608580	might have unconventional abilities like forcing an endless loop that repeatedly opens a
2608580	2615180	file. For real, who thought this ability might be helpful? So this can use to create a very
2615800	2621140	unconventional flows that still allow you to achieve your ultimate goal. The next takeaway
2621140	2626860	shifts to the defensive side. Many products leave non-issue and bugs unfixed due to
2626860	2633500	prioritization. Often this issue seems to pose no security risk or only minor ones that
2633500	2638640	doesn't require immediate attention. However, addressing these non-issue bugs or minor
2638640	2644600	security risk can sometime be crucial for mitigating much greater risk that you might not
2644600	2649700	be aware of. For example, if we didn't have the DOS vulnerability that allows QuickShare to
2649700	2656620	crash, we wouldn't be able to have a established stable Wi-Fi connection and this would
2656620	2662900	have completely disabled our RC chain. Lastly, it's crucial for organizations to develop
2662900	2669320	software and develop software to focus not only on specific programming mistakes like memory
2669320	2674320	corruption bugs. When evaluating a program's security, it's important to take a broader
2674320	2680620	perspective and consider whether a simple logic or intended behavior might also introduce
2680620	2687260	security risk. That's pretty much it. Here's the QR code for our repository. Feel free to
2687260	2693140	take a picture. It has a lot of tools to play with QuickShare. You can also find the
2693140	2699080	contact details for all and myself. And we'd like to thank everyone for joining to our
2699080	2702120	session. We hope you enjoyed it. Thank you.
2702120	2703000	Thank you, everyone.
2704280	2706400	Thank you. It was really fun.
