[00:02.820 --> 00:12.500] Alright, hello! I'm not used to a mic so sensitive so I'm going to talk like back here and if [00:12.500 --> 00:20.960] that doesn't work then I'll adjust, whatever. This is Xiaomi the money, our Toronto Pwn2Own [00:20.960 --> 00:28.760] 2023 exploit and behind the scenes story. What this talk is about is our hack against [00:28.760 --> 00:34.940] the Xiaomi 13 Pro which includes the full exploit chain that we used and also issues [00:34.940 --> 00:40.400] encountered during the research itself. And then we're going to cover what happened during [00:40.400 --> 00:46.480] the Pwn2Own competition itself and for a little bit of background on who we are, I'm Ken [00:46.480 --> 00:52.580] Gannon, I'm a principal security consultant at NCC group and I usually focus on hacking [00:52.580 --> 01:00.380] mobile shit. This is Ilyas, at the time of the competition he was also part of NCC group, he [01:00.380 --> 01:06.940] is a veteran Android malware reverse engineer and this was his first time competing at Pwn2Own [01:06.940 --> 01:12.700] so we got first time Pwn2Own, first time Defcon, this is his first time in the US, this is a [01:12.700 --> 01:22.440] lot of stuff for this guy right here. So a little bit about us, so it was in 2022, no 2023 [01:22.440 --> 01:27.680] of last year, it was around May. Ilyas was looking to do Pwn2Own, for those of you that don't [01:27.680 --> 01:33.200] know what Pwn2Own is, it is a zero day competition where you try to hack some devices and [01:33.200 --> 01:40.340] some prize money involved and Ilyas was looking to do Pwn2Own this year, last year for his [01:40.340 --> 01:45.540] first time. And so he started researching previous vulnerabilities, previous competitions to [01:45.540 --> 01:51.540] see what that was like. And then he came across my name because I've done exploits, I've [01:51.540 --> 01:57.160] done previous attempts at Pwn2Own and he realized, oh shit, I work at the same company as Ken [01:57.160 --> 02:02.420] Gannon, I'm gonna reach out to him. So it was like May of last year, we get together, we talk [02:02.420 --> 02:10.400] over teams and we discuss what we want to hack. And we decided to hack the Samsung Galaxy S23. [02:10.980 --> 02:16.000] So that was as of May last, oh it's, hi Will, I didn't see you there. So that was May of last [02:16.000 --> 02:24.460] year. And then July of last year, ZDI announces their list of devices. And as you can see on the [02:24.460 --> 02:30.580] screen, it includes the Xiaomi 13 Pro. So the thing about the Xiaomi 13 Pro though is that the [02:30.580 --> 02:38.340] Xiaomi devices has not been a target of Pwn2Own since 2020, the COVID pandemic. And him and I [02:38.340 --> 02:44.120] got together again and we're like, oh, this sounds interesting. Maybe we should try to [02:44.120 --> 02:50.980] hack this new device or we should try to stick with Samsung Galaxy S23. And the thing about [02:51.540 --> 02:56.380] our discussions at the time is that we were discussing this on July 13th of last year, when [02:56.380 --> 03:03.380] the devices were announced. And as I said, we were thinking about Samsung Galaxy S23, but I [03:03.380 --> 03:10.800] have a history with Samsung at this point. A lot of traumatic experiences with Samsung, [03:10.800 --> 03:19.180] including a failed Pwn2Own attempt in 2021, because I am a very shitty programmer. So because [03:19.180 --> 03:25.600] of that, and we decided that maybe we should just go for the Samsung, for the Xiaomi 13 Pro [03:25.600 --> 03:30.800] instead. Something new, something fresh. We we just thought, you know, something that we both [03:30.800 --> 03:36.960] can learn together. What could possibly fucking go wrong, right? This is gonna be awesome. So [03:37.700 --> 03:43.720] let's talk about the Xiaomi 13 Pro. There's essentially two versions of this device. The [03:43.720 --> 03:49.700] global variant and the China variant. The global variant is available worldwide, wherever [03:49.700 --> 03:56.680] you can get a Xiaomi device, whereas the China variant is typically only found in China. At a [03:56.680 --> 04:01.180] hardware level, they're exactly the same thing. Same camera, same processor, same board, [04:01.180 --> 04:07.660] same chip set. The only minor difference between these two models is the type of firmware [04:07.660 --> 04:15.540] that can be installed on each device. Uh, the China model can have the China firmware as [04:15.540 --> 04:21.340] well as what's called the global variant firmware. Whereas the global model can only [04:21.340 --> 04:27.780] install the global variant firmware. Now, the unique part about the global firmware though, [04:27.780 --> 04:36.060] is that depending on the settings, you can have it emulate different regions. Like for example, [04:36.060 --> 04:44.040] in Europe, in India and in Taiwan, they have their own Taiwan, India and Europe firmware. Or [04:44.040 --> 04:50.500] you can tell the global mother one to emulate a different region and it will become that [04:50.500 --> 04:56.660] region. Why this is important is because certain regions have certain apps enabled or [04:56.660 --> 05:03.500] disabled. For example, if you set the region to United Kingdom, the get apps application, [05:03.500 --> 05:09.600] which is the Xiaomi uh application store, will be enabled if the phone is set to the UK [05:09.600 --> 05:15.400] region. Whereas if you were to set it to United States region, the get apps store is [05:15.400 --> 05:20.960] disabled. And this is just one example. Another one is that if you set the region to Russia, [05:20.960 --> 05:26.580] then the Yandex browser becomes enabled on the device. Keep in mind that this browser, [05:26.580 --> 05:31.720] the APK file, is in the firmware already, it's just that it gets enabled or disabled [05:31.720 --> 05:37.940] depending on what region the firmware is set to. Another example is that with the Spain [05:37.940 --> 05:46.000] region, the Opera browser becomes enabled and one more example, and one more example, the [05:46.000 --> 05:51.640] Indonesia region, the WhatsApp uh app becomes enabled or disabled. So at this point, we [05:51.640 --> 05:55.140] have multiple different regions, multiple apps being enabled, multiple apps being [05:55.140 --> 06:02.380] disabled. So we thought, well, why don't we determine what each region does, download all [06:02.380 --> 06:06.540] 400 plus applications from the phone, and start reverse engineering every single [06:06.540 --> 06:12.220] application. Except that's a really fucking bad idea because that's a lot of applications. [06:12.220 --> 06:18.200] So instead, we decided to just prioritize the Xiaomi developed applications, [06:18.200 --> 06:24.300] specifically the ones that were developed by Xiaomi for that phone. And so then 22 days [06:24.300 --> 06:30.640] later, we had 3 exploits for the GetApps application. And this is where Elias is going to [06:30.640 --> 06:32.220] talk about them real quick. [06:32.340 --> 06:39.260] Hey everyone. I'm going to be talking about the app we exploited. So we found 3 different [06:39.260 --> 06:45.600] exploits in the GetApps application. This application is also what the, what we ended up [06:45.600 --> 06:52.460] exploiting at point one. So we found 3 different ways to force install application. And the [06:52.460 --> 06:58.900] attack scenario is the following. Tapping a malicious hyperlink in a web browser would [06:58.900 --> 07:05.460] result in automatically install any application available on the GetApps store without user [07:05.460 --> 07:11.560] consent. Two of the methods were unfortunately patched before the competition. And I'm [07:11.560 --> 07:18.460] going to show here the exploit code of those 2 patch exploits. So here's the first one. Um, [07:18.460 --> 07:23.580] that was used to install WhatsApp automatically. On the first screenshot, you can see the [07:23.580 --> 07:30.020] browsable intent code. And if you've never created a browsable intent hyperlink before, we've [07:30.020 --> 07:39.060] also put the Java code which does the exact same thing. And there is an ID equal com.whatsapp [07:39.060 --> 07:45.100] parameter in there. And that's what could be used to install any application available in [07:45.100 --> 07:54.140] GetApps. Here's the second patch exploit. On the left, you can see the browsable intent code. [07:54.140 --> 08:00.120] And again, on the right, you can see the Java code which does the exact same thing. It's a [08:00.120 --> 08:07.900] lot chunkier as you can see. And if you base 64 decode that string, you'll be able to see the [08:07.900 --> 08:15.080] WhatsApp packet name, package name in there. Before we can get into the third exploit, we [08:15.960 --> 08:23.640] need to talk a little bit about WebView in GetApps. Um, GetApps had a WebView which [08:23.640 --> 08:30.300] contained a JavaScript interface. And for non-Android people, this means that JavaScript could [08:30.300 --> 08:37.300] be used to execute a set of Java function defined in the application. It's defined in the [08:37.300 --> 08:45.020] JavaScript interface class. And some of those JavaScript interface function were benign, like [08:45.100 --> 08:51.980] show toast function, for show toast functions, um, which literally just shows a toast, as you [08:51.980 --> 08:57.900] can see in the screenshot. But there are two interesting functions there for us, for point [08:57.900 --> 09:04.000] one. The install function, which installs any application available on the GetApps store [09:04.000 --> 09:11.580] without user consent. And the open app functions, which opens any specific application, again, [09:11.580 --> 09:19.980] without user consent. And this WebView is obviously dangerous, and Xiaomi knows it. So, they [09:19.980 --> 09:26.580] implemented some protection to ensure that attackers cannot obviously open this WebView and [09:26.580 --> 09:33.460] execute any of those JavaScript interface functions. And one of those protection was that [09:33.460 --> 09:41.560] whatever URL being loaded in the WebView, must be a valid URL. And by valid, I mean that [09:41.580 --> 09:50.420] it either starts with the HTTPS protocol, and the domain should belong to a defined set of, [09:50.420 --> 09:59.480] um, uh, white listed domains. All of them were owned by Xiaomi. And the other valid URL, um, [09:59.480 --> 10:05.920] should start with the file protocol, and the file should be located in the GetApps private [10:05.920 --> 10:16.440] directory. A GetApps private directory, um, names was always web hyphen raise, I hyphen some [10:16.440 --> 10:25.820] random numbers. So now, we have a new plan. First, we can launch the WebView and load a valid [10:25.820 --> 10:32.060] URL. Second, inject, inject some custom JavaScript code into the WebView, possibly through [10:32.060 --> 10:38.020] cross-site scripting. Third, having the JavaScript code execute the two JavaScript [10:38.020 --> 10:46.200] interface functions mentioned before. And fourth, got, get remote code execution. Okay, step [10:46.200 --> 10:53.020] one. To launch the WebView, we use the activity called join activity. This activity could be [10:53.020 --> 10:58.840] launched via browsable intent. Again, this means that this activity could be launched via [10:58.840 --> 11:05.480] hyperlink in a website. And it was also really simple to tell join activity what URL we wanted [11:05.480 --> 11:13.740] to load in the WebView. It was just a get parameter called URL. This is the proof of concept, [11:13.740 --> 11:22.680] uh, which launched join activity and loaded the file detail dot html that was in the GetApps [11:22.680 --> 11:28.820] private folder. That detail dot html is pretty blank, as you can see on the screenshot. Um, [11:28.840 --> 11:36.540] but that's just because we didn't give him the application's data to use. So now step one is [11:36.540 --> 11:43.820] done. Let's move on to step two. We had two options to inject custom JavaScript. We could [11:43.820 --> 11:50.380] either load a show me domain URL and then print this dot URL and look for usable [11:50.380 --> 11:57.760] vulnerabilities. Or, we can analyze the file in the private folder and look for user input [11:57.760 --> 12:05.580] vulnerabilities. We choose the second option. And now this research just became a JavaScript [12:05.580 --> 12:13.740] source code review job. And as you can see on the picture, this was my reaction when I realized [12:13.740 --> 12:19.940] what was going on. Um, point one will make you do stuff you really don't want to do, but we [12:19.940 --> 12:27.740] still did it. Um, in, in the, uh, the web hyphen res folder, um, you can see the [12:27.760 --> 12:34.900] folder. We had like HTML file and JavaScript file with similar names. As an example, we had [12:34.900 --> 12:43.240] the detail dot HTML file and this file would load the detail dot chunk dot JS. Some JavaScript [12:43.240 --> 12:51.600] file would accept user input via get parameters. But also, all of those JavaScript file had a [12:51.600 --> 12:57.740] building function to filter out any cross-scripting payloads. Well, except for this one. [12:57.760 --> 13:06.100] One that we found. There was a file called integral dialogue page dot chunk dot JS which failed [13:06.100 --> 13:13.380] to sanitize cross-scripting payloads in one specific area. So, let's try to get a dumb XSS [13:13.860 --> 13:20.440] payload working in this file. This was the initial payload that was used for testing. On the [13:20.440 --> 13:26.980] right, you can see the decoded version of it. So, we had different inputs and we had different [13:26.980 --> 13:35.660] payloads. All of them started with XSS test, 1, 2, 3, 4, 5, and they all ended with, um, two [13:36.320 --> 13:42.540] characters that was encoded. And those characters were double quote symbol and the less than [13:42.540 --> 13:51.460] symbol. On the left is what the web view looked like with the payloads. And on the right is a [13:51.460 --> 13:58.480] debugging window in Chrome. Our less than symbol character was unfiltered in one of the [13:58.480 --> 14:07.620] area, specifically the XSS test 2. All the others were filtered, filtered the right way. So, [14:07.620 --> 14:16.920] now, with this XSS test 2 payload, we can try to just pop a simple alert box. And then, what [14:16.920 --> 14:25.660] the hell? We got some errors. Locat was showing us disabled XSS text, XSS errors, um, errors. [14:25.660 --> 14:30.440] So, let's dig into that. Remember the protection against the web view that we mentioned [14:30.440 --> 14:37.260] earlier? There was another one, unfortunately. The GitOps application had a built in XSS [14:37.260 --> 14:46.760] filter in the Java code itself. And it looked for XSS payload in the URL. So, if the URL [14:46.760 --> 14:55.860] had any XSS payload found, then the URL would fail to load. And here is the list of the XSS [14:55.860 --> 15:04.000] filter. And as you can see, it detected our forward slash script string in our payload. At [15:04.000 --> 15:10.620] this point, we decided that maybe we shouldn't be using script string at all. Maybe because [15:10.620 --> 15:16.400] there might be other filters we haven't found yet. And also, script is just too obvious for an [15:16.400 --> 15:24.020] XSS payload. Okay, so going through the list and thinking about what could we use now, we [15:24.020 --> 15:31.640] realized that the Java XSS filter was just looking for string matches. So, we thought, what [15:31.640 --> 15:38.660] if we could encode, um, a less than symbol, um, a character in one of those payloads. Such [15:38.660 --> 15:46.380] as, the less than symbol SVG. So, that's what we tried. And we used, um, we used a [15:46.400 --> 15:55.240] SVG unload to run the JavaScript alert box and that, that said, yeah, dumb XSS here. And [15:55.240 --> 16:03.680] boom, it worked. We finally have an XSS in the web view now. So, step two is done. Let's move [16:03.680 --> 16:10.360] on to step three. Oops, sorry. Now, let's try to call the, those JavaScript interface [16:10.360 --> 16:17.540] function mentioned earlier. To test, we tested our payload just to see if we could run the [16:17.540 --> 16:22.860] show toast function. And on the screen shot on the right, you can see that we managed to do [16:22.860 --> 16:31.840] that. So now, after some time, we did some reverse engineering and we came up with this lovely [16:31.840 --> 16:37.760] JavaScript payload to install any application. On the screen shot, you can see that we first [16:37.760 --> 16:43.480] called the install with the package name of the application we want to install and then we run [16:43.660 --> 16:50.660] a loop, um, and wait for the, the application to install and then we use the open app with the [16:50.660 --> 16:58.180] package name again to open the application. So now, there is just one problem. We didn't know [16:58.180 --> 17:05.860] what to install. So now, what application should we install? Ideally, we want some malware [17:05.860 --> 17:12.400] that we can control in the application store, store somewhere. And I'm going to let Ken talk [17:12.400 --> 17:20.540] about his baby now. So, for those of you that don't know, I'm also an active contributor for [17:20.540 --> 17:26.920] this Android tool Drozer. Yay! For those of you that know what Drozer is, yay! Uh, and [17:26.920 --> 17:33.320] because I'm an active contributor, I know how to reskin it into an application called Sunfish [17:33.320 --> 17:40.040] which does literally the same exact thing as Drozer except it starts a bind shell on boot as [17:40.040 --> 17:46.940] well and then I uploaded it to this Xiaomi app store. So, for a little bit on the Xiaomi app [17:46.940 --> 17:54.340] store, there was a, a copy of Drozer called Sunfish up on the app store. That was fun. So, we [17:54.340 --> 18:00.960] had a new payload. In this case, the payload is going to step one, install Sunfish and then [18:00.960 --> 18:08.020] step two, open it after Sunfish is installed on the device. So, alright, all the pieces, all [18:08.020 --> 18:14.200] the puzzle pieces are in place. Let's uh, let's watch it do its thing real quick. We open up [18:14.200 --> 18:19.040] Google Chrome. Uh, in this case, we're going to, as you can see, it's a new copy of Chrome [18:19.040 --> 18:25.440] with all those popups. We browse to the web server I had at my house, uh, over HTTP because [18:25.440 --> 18:31.620] I'm lazy. But eventually what's going to happen is I will load the website and there's a [18:31.620 --> 18:39.180] yay POC hyperlink. Click that one link. This appears and then Sunfish gets installed and boom, [18:39.180 --> 18:45.080] Sunfish is now installed. The server has started as well. I put the phone down. At this [18:45.080 --> 18:50.700] point, I have the IP address of the phone that reached out to my web server as well. And so, [18:50.700 --> 18:57.000] to put the bind shell open, all I had to do was use my re-skinned Drozer console thingy [18:57.000 --> 19:02.820] whatever to connect to the Drozer application installed on the phone. And then for, per the [19:02.820 --> 19:09.520] rules of Pwn2Own, as long as you get RCE on the device, that is good enough. Including just [19:09.520 --> 19:15.700] RCE as a single application. So, in this case, I'm running ID and who am I as Sunfish? There [19:15.700 --> 19:25.220] we go. One click to, one click to RCE. Yay! So, we got RCE. All the steps are done. And like I [19:25.220 --> 19:32.140] said, that was only 22 days later. We had 22 days of research time. We had 77 more days to [19:32.140 --> 19:37.140] go to to do whatever the fuck we wanted. Everything was awesome. Nothing could have [19:37.140 --> 19:45.680] possibly gone wrong. Let's discuss what went wrong. So, late August of 2023, Xiaomi released [19:45.700 --> 19:50.700] Xiaomi made changes to their get app server. Uh, specifically, one of the changes that they [19:50.700 --> 19:59.480] made was that the install parameter, the install function that we were using, now required a [19:59.480 --> 20:09.980] shit ton more code. Our payload was now chonky as fuck. But wait, there's more. You see, this [20:09.980 --> 20:15.440] payload did not work in all parts of the world. So, for a little bit of background, last year and [20:15.440 --> 20:22.940] around August, late August 2023, I went on vacation to Japan and the Philippines. And this new [20:22.940 --> 20:29.820] chonky install payload would work in Japan and the United Kingdom. Thanks to Ilias here being [20:29.820 --> 20:34.400] based in the United Kingdom. But it fucking wouldn't work in the Philippines for some [20:34.400 --> 20:43.920] reason. And while in uh, Japan and the Philippines, I noticed that the get apps application was [20:43.920 --> 20:51.520] showing different content based on the physical location of the phone. Not the IP address. [20:51.900 --> 20:56.520] I'm talking about doing a factory reset and you, you know, you go, factory reset, you go [20:56.520 --> 21:00.160] through the whole setup, the cell phone towers are, the cell phone signal is now enabled on [21:00.160 --> 21:05.320] the phone. And for some reason, after you do a factory reset and you go through the initial [21:05.320 --> 21:13.320] setup, there was stuff on the uh, in the get app store that was exclusive to that one region. [21:14.220 --> 21:19.540] And what I also realized at the time, or as we were doing like research, like figuring out [21:19.540 --> 21:28.980] what is going on, uh, VPN did not affect this. The reason I was talking about factory reset is [21:28.980 --> 21:35.200] because during Pwn2Own specifically, uh, they typically factory reset their phone before [21:35.200 --> 21:40.700] every single uh, entry goes up. And so then during a factory reset process, the cell phone [21:40.700 --> 21:46.020] tower, the cell phone signal antenna is enabled. So we wanted to mimic that. And we realized [21:46.020 --> 21:52.420] that just really weird stuff was happening with the get app store depending on where I was in [21:52.420 --> 21:58.640] Japan and the Philippines. And so then after looking at the developer documentation and [21:58.640 --> 22:04.260] looking at uh, the, the developer portal I had access to since I uploaded Sunfish to their app [22:04.260 --> 22:11.720] store, I realized that there were some places that were launched. Uh, for example, get apps was [22:11.720 --> 22:21.840] not launched in the US, UK and Japan. But it was launched in the Philippines. Now I don't have [22:21.840 --> 22:28.500] definitive proof, but this is literally the only thing I could think of at the moment. Maybe we [22:28.500 --> 22:33.440] were seeing different behavior in the Philippines because the get app store was not, was [22:33.440 --> 22:40.340] launched in the Philippines but was not launched anywhere else that we've been to. Now, [22:40.340 --> 22:46.520] thankfully, cause we are awesome, eventually we found a way for the payload to work in the [22:46.520 --> 22:53.240] Philippines. But that payload would only work in the Philippines. It would not work in US, UK [22:53.240 --> 23:01.220] or Japan. We didn't know what to do. Because another issue came up, Pwn2Own that we were [23:01.220 --> 23:08.000] going to takes place in Canada. Do we have a payload that works in Canada? We, I like, it's a [23:08.000 --> 23:13.820] theory, this whole like launch not launch thing is just a theory. And technically, get apps was [23:13.820 --> 23:20.300] not launched in Canada. So maybe, maybe our get apps or non-launch payload would work in [23:20.300 --> 23:26.180] Canada. We're not entirely sure. It'd be nice to confirm. Well, NCC group is a global [23:26.180 --> 23:31.520] company. And we have offices in Canada. So surely we can just, no, no, we're not, we're not [23:31.520 --> 23:37.160] working with the Canada office for this talk. Because you cannot get the Xiaomi 13 Pro in [23:37.160 --> 23:42.520] Canada. So, if you try to get the Xiaomi 13 Pro here in the US, you're going to go through [23:42.520 --> 23:46.580] eBay. You're going to go through a, a seller on eBay or on Amazon or something to get the [23:46.580 --> 23:54.140] phone. Uh, in fact, my phone, I know for a fact, what, was a China model imported here from [23:54.140 --> 24:01.040] China, sold by a, a Chinese guy on eBay. I could not procure the Xiaomi 13 Pro in Canada. [24:01.040 --> 24:05.280] eBay Canada, Amazon Canada, none of the cell phone providers in Canada, like I could not get it [24:05.280 --> 24:10.700] in Canada. So, you know, I'm in North America, I might as well just send my phone to Canada. [24:10.700 --> 24:16.240] No, no, I'm not sending my phone to Canada. Because another issue came up with my schedule [24:16.240 --> 24:24.320] specifically. You see, in August of 2023, uh, or 20, 2023 in general, NCC announced that they [24:24.320 --> 24:31.080] were going to open an office in the Philippines. And I was chosen to go out to Manila to spend [24:31.080 --> 24:36.600] the rest of 2023 in the Philippines to help set it up. Uh, fun fact, I'm still in the [24:36.600 --> 24:46.220] Philippines. So, because of this, I had a very, very weird travel schedule last year. Because [24:46.240 --> 24:53.300] as I said earlier, I went on a vacation, right? I come back from vacation on September 10th. And [24:53.300 --> 24:58.340] then on September 11th through 14th, I'm at my house, I'm like packing, I'm like trying to get [24:58.340 --> 25:04.180] ready because I'm going to be spending the rest of the year in the Philippines. Uh, and then on [25:04.180 --> 25:09.320] Friday the 15th, and, and I do this thing in Vermont for like a race, I come back on the 17th. [25:09.320 --> 25:14.700] And then again, 18th through 20, I'm at home. And then the 21st of September, I fly to the [25:14.700 --> 25:21.340] Philippines. That leaves only seven business days where I am in the U.S. So that's the [25:21.340 --> 25:27.200] schedule. Uh, it's a little bit hectic, but it gets more hectic, I promise. But first, we [25:27.200 --> 25:34.460] want to, I want to talk about why those seven days sucks. Because it is too risky to send a [25:34.460 --> 25:38.920] phone to Canada, pay Canada import taxes, test and develop an exploit, send the phone back to [25:38.920 --> 25:47.680] U.S., and then pay U.S. import taxes all in seven days. That is not going to happen. Well, what [25:47.680 --> 25:55.120] if I just send my phone to Canada and keep it there? Well, I, I, the Philippines has a lot of [25:55.120 --> 25:58.980] Xiaomi stores. That's, there's literally a picture of a Xiaomi store that I sent to Italy, that's [25:58.980 --> 26:04.340] when I found my first one. And they were selling Xiaomi 13 Pros for 1,000 U.S. dollars. I can [26:04.340 --> 26:10.400] just go to the Philippines and get a new phone, right? Well, the problem is that now we're [26:10.400 --> 26:14.880] dealing with three different time zones. If I'm in the Philippines, he's in the U.K., and the [26:14.880 --> 26:20.220] Canada consultants are in Eastern Standard Time. Uh, for those of you that don't know, half of [26:20.220 --> 26:25.080] the time of the year, the Eastern Standard Time and the Philippines are literally 12 hours, 12 [26:25.080 --> 26:31.000] hour difference. And trying to manage those time zones on top of the consultants in Canada [26:31.000 --> 26:39.240] being available, that sounds like way too much fucking stress for a theory. On top of that, the [26:39.240 --> 26:46.020] biggest issue, the biggest threat to any pawn to own competition are the patches. So, at this [26:46.020 --> 26:53.320] point, we had a good idea as to how the patches worked. Uh, first, during the first week of, of [26:53.320 --> 26:59.680] every month, a firmware gets updated to the beta channel and in, and as, after that first week in [26:59.680 --> 27:05.140] the beta channel, the firmware also gets put in the stable channel. With that firmware update [27:05.140 --> 27:13.600] comes a new GetApps update. Every single month, there is a new update for GetApps. So, the real [27:13.600 --> 27:19.760] schedule now is that after I fly back to the Philippines, no one is in the U.S. to test the [27:19.760 --> 27:52.040] exploit, or no one's in North America to test the exploit a... Hey, you know what? If I try [27:52.040 --> 28:00.220] to shut... Alright. No one's in North America. Hey, we're back. Yay. Alright. Yeah, like I [28:00.220 --> 28:04.480] said, no one's back in, no one's in here in North America to test stuff and we have a new patch [28:04.480 --> 28:13.160] coming out sometime, supposedly October 9th, right? I really, really want to test this theory [28:13.160 --> 28:20.620] though. I really, really do. Because, here's the thing. We think that Canada is a non-launched [28:20.620 --> 28:28.720] region, right? Just like with U.K. or U.K. and U.S. uh, and Japan. If we can group, and this is [28:28.720 --> 28:34.480] just a theory we had at the moment, if we could group Canada into that non-launched region and [28:34.480 --> 28:40.680] test and make sure that we, that, that theory is true, then let's say that October rolls around [28:40.680 --> 28:47.160] and they release their patch, right? All we would need is Ilyas here to test his U.K., uh, his [28:47.160 --> 28:55.160] exploit in the U.K. And if it works, then in theory it should work in the U.S., in Japan and in [28:55.160 --> 29:06.700] Canada. So, earlier I mentioned that it costs 1,000 U.S. dollars to buy a new phone. Another [29:06.700 --> 29:13.000] thing that costs 1,000 U.S. dollars is to go to Canada, literally for a day, literally hang [29:13.000 --> 29:19.560] out in the Marriott Hotel at Toronto Airport and test the exploit. And then fly back the next [29:19.560 --> 29:26.740] day. So that's what I did. On, let's see, on September 17th I fly back from my race, on [29:26.740 --> 29:34.160] September 18th I fly back to Toronto to test the exploit, on September 19th uh, I fly back home [29:34.160 --> 29:42.400] and then on September 21st I fly to Manila. So many miles. And like a, and after a few hours in [29:42.400 --> 29:49.920] Toronto, it was confirmed. We did it. We, we confirmed that this was a non-launched region. And [29:49.920 --> 29:57.060] so now, if our, if October rolls around, our exploit works in the U.K., we should be good. [29:57.060 --> 30:04.000] Everything is awesome. Uh, we are, uh, we are so excited for everything to happen and we are [30:04.000 --> 30:11.760] going to get our, uh, get our first phone to own wind. Right Elias? Yeah! So, October rolls [30:11.760 --> 30:17.860] around. As expected, get apps releases their, their update in October. It's literally [30:17.860 --> 30:24.860] October 9th. I have it marked down in my calendar and we confirm that the exploit works. We [30:24.860 --> 30:29.420] have our books flight for September 20th. I'm flying from the Philippines, he's flying from [30:29.420 --> 30:36.980] the U.K. We, all this is good to go. We're going to fucking do this. No, hold on. One week [30:36.980 --> 30:45.280] before phone to own, Xiaomi releases an out of band update to get apps. Which happened to [30:45.280 --> 30:52.460] fucking remove the file that we were going to exploit. Specifically, the file was removed [30:52.460 --> 30:57.780] from the APK file itself. For those of you that are on Android, uh, that means that the file [30:57.780 --> 31:04.720] was removed from the installer file of the app itself. It was no longer there. But [31:04.720 --> 31:10.800] thankfully they are, Xiaomi also has shitty programmers. Because they forgot to remove the [31:10.800 --> 31:18.320] file from the device if it was already there. So, in theory, assuming that we show up to [31:18.320 --> 31:22.480] phone to own and we're one of the first few people to hack the phone. And like I said [31:22.480 --> 31:31.060] earlier, uh, uh, ZDI usually factory resets the target device per, uh, competition. They [31:31.060 --> 31:36.260] usually have multiple devices. So, as long as we could hack one of the initial devices [31:36.260 --> 31:42.100] before they factory reset it again. Again, it's a dice roll, but there's still a chance. We [31:42.100 --> 31:47.260] still follow through. We still decide, okay, this is not that big a deal. Let's fucking do [31:47.260 --> 31:53.000] this. So, we fly out to Canada. It is now October 20th. Him and I are both on our flights. [31:53.900 --> 31:59.780] Literally while I'm on the plane. And the Saturday before phone to own, there is another get [31:59.780 --> 32:06.100] apps update. Now, this is the most interesting part because they introduced a new thing in [32:06.100 --> 32:13.180] get apps where they can modify what files are on the device using Google Firebase. Which is [32:13.180 --> 32:19.740] really, really cool. And for some reason they pushed our file back to the device. Like if [32:19.740 --> 32:23.740] you were moved, if you went in and manually removed the file that we were going to [32:23.740 --> 32:28.640] exploit, they just pushed it back for us. That's so fucking convenient. Thank you, [32:28.640 --> 32:35.960] Xiaomi. Except they added one more thing. So, we were going to exploit the activity, join [32:35.960 --> 32:45.500] activity, as we, as Ilya said. But they happened to add code to that one activity where if the [32:45.500 --> 32:52.880] intent came from any of these four browsers, the uh, Xiaomi browser, uh, the Android HTML [32:52.880 --> 33:03.120] viewer, the Android NFC, or Google fucking Chrome, then join activity will not launch. What the [33:03.120 --> 33:08.640] fuck, Xiaomi? As you all saw in my video earlier, we use specifically Google Chrome. We [33:08.640 --> 33:17.920] can't, there's no other browsers on this phone that we can use. Except there is. Because if you [33:17.920 --> 33:26.820] set the region to Spain, the Opera browser is enabled on the phone. So technically we had an [33:26.820 --> 33:33.440] exploit for the country of Spain specifically. Which is still technically a zero day, [33:33.440 --> 33:40.500] because now it's a zero day in Spain. So we told ZDI this. We told them, hey, Xiaomi is doing [33:40.500 --> 33:47.900] some shitty stuff, but Spain. And ZDI goes, Spain. And we're good to go. And we're [33:47.920 --> 33:53.040] good to go. Alright. We dodged another bullet. We can now, we can do this. We can hack a [33:53.040 --> 34:01.540] Xiaomi 13 Pro. The first day of the competition, Xiaomi starts disabling the ability to [34:01.540 --> 34:09.660] install apps from their app store. Now, I don't know if this was a global thing. I genuinely [34:09.660 --> 34:15.840] don't know. I don't talk to many Xiaomi users after this. I don't want to. But the very [34:15.840 --> 34:23.340] least, the people in Toronto area that were, that were also going to hack the Xiaomi 13 Pro, [34:23.340 --> 34:28.320] they corroborated it. They all saw the same issue that we saw. It was a hit or miss, whether [34:28.320 --> 34:33.660] an application wouldn't install. It was like a 20% chance that we could install an [34:33.660 --> 34:44.260] application. And they killed my boy. This, this really genuinely hurts. That I could not [34:44.260 --> 34:52.960] install Sunfish at all. It was a 0% success rate. So, on that day, there was 2 teams that [34:52.960 --> 34:59.680] were supposed to go and hack the Xiaomi 13 Pro. Uh, it was us at NCC group and it was, uh, [34:59.680 --> 35:05.840] the awesome people at Team Viettel. Uh, Team Viettel went first, we went second. Uh, we [35:05.840 --> 35:12.620] discussed with ZDI what happened and we're like, what the fuck do we do? Oh wait, can we [35:12.620 --> 35:21.360] please just install one random app from the app store? And they go, okay. And we did. We did [35:21.360 --> 35:27.560] it. Technically that works because we showed ZDI that we had malware up on the app store. [35:27.780 --> 35:32.940] ZDI already heard from other contestants around the area that Xiaomi was doing something [35:32.940 --> 35:38.260] very funky with their app store and they're like, fine, good enough. So, Team Viettel [35:38.260 --> 35:46.300] managed to install Discord and I, we installed no pics color by number and pixel. Yeah, it [35:46.300 --> 35:49.800] was that app. I literally just found another random app on the app store and we installed [35:49.800 --> 36:00.020] it. And we did it! We got a win! Yay! Except that's not the end of the story because the next [36:00.020 --> 36:08.220] day, Xiaomi releases another update. First, they removed the file that we exploited and [36:08.620 --> 36:14.260] now nothing installs from the app store. Period. The day before, those that got 20 percent [36:14.260 --> 36:20.520] success rate on installing something, no. The next day, nothing gets installed. Period. And [36:20.520 --> 36:31.360] on top of that, they added code to block Yandex and Opera. You can't make this shit up. So, [36:31.360 --> 36:35.740] the rest of the week, it was just failure after failure after failure after failure. [36:35.740 --> 36:40.780] Unfortunately, it's pretty obvious why nothing would install. They removed a bunch of other [36:40.780 --> 36:46.940] stuff from the app. And, you know, the lesson of this story is that during Pwn2Own [36:46.940 --> 36:53.360] specifically, Xiaomi is the most secure phone in the world. If there was one phone I would [36:53.360 --> 36:57.900] have on me during Pwn2Own specifically, especially here at DEF CON where nothing bad [36:57.900 --> 37:04.700] happens, it's a Xiaomi 13 Pro during Pwn2Own. There is one more side to this story that I [37:04.700 --> 37:09.460] think everyone here should check out eventually. Uh, my friend Maxploit, who was also a [37:09.460 --> 37:14.640] competitor last year at Pwn2Own, uh, he says, and I quote, props to the Xiaomi crew who [37:14.640 --> 37:19.800] proved you can patch RCE bugs completely remotely in only a few hours and also break your [37:19.800 --> 37:24.420] flagship device across the country as long as you're doing it to be a dick. Not because you [37:24.420 --> 37:30.280] actually care about fixing things. If you guys want, he actually talked earlier this year at [37:30.280 --> 37:34.440] OffensiveCon about his side of the story as well as his exploit. I do recommend you all [37:34.440 --> 37:40.180] check it out. It's also a fun time. So, after Pwn2Own, what happened? The browser [37:40.180 --> 37:47.700] blocking code got removed for some reason and applications can install just like normal. [37:47.700 --> 37:55.120] Everything works. Everything is back to normal. Now, both us and team Vietel never got credit [37:55.120 --> 37:59.120] from Xiaomi. Usually with a vendor they are like, hey we want to acknowledge so and so [37:59.120 --> 38:04.700] working together with, with ZDI to do so and so. No, they said fuck you, we don't, we don't [38:04.700 --> 38:10.260] want to acknowledge you. So, Zero Day Initiative had to be the one to give us CVE numbers. [38:10.460 --> 38:16.260] And they said something in their posting that was possibly my favorite quote of this entire [38:16.260 --> 38:25.620] time. Xiaomi informed ZDI they would assign a CVE but never followed through. Except they [38:25.620 --> 38:35.280] did, specifically to team Vietel a few days later. But not us. Where's my fucking CVE [38:35.280 --> 38:43.380] Xiaomi? And that's it. That's the end of our story. Yay! I hope they get the worst vendor [38:43.380 --> 38:51.320] response at Pony Awards. Yay! Uh, we're also very introverted so we're gonna take questions [38:51.320 --> 38:56.280] out there instead of up here. If you guys don't mind, alright? Alright, thank you for coming! [38:56.280 --> 38:57.100] Yay!