1 00:00:02,820 --> 00:00:04,540 Alright, hello! 2 00:00:07,600 --> 00:00:15,340 I'm not used to a mic so sensitive so I'm going to talk like back here and if that doesn't work then I'll adjust, whatever. 3 00:00:15,540 --> 00:00:24,380 This is Xiaomi the money, our Toronto Pwn2Own 2023 exploit and behind the scenes story. 4 00:00:24,740 --> 00:00:37,460 What this talk is about is our hack against the Xiaomi 13 Pro which includes the full exploit chain that we used and also issues encountered during the research itself. 5 00:00:37,460 --> 00:00:53,760 And then we're going to cover what happened during the Pwn2Own competition itself and for a little bit of background on who we are, I'm Ken Gannon, I'm a principal security consultant at NCC group and I usually focus on hacking mobile shit. 6 00:00:54,080 --> 00:01:11,900 This is Ilyas, at the time of the competition he was also part of NCC group, he is a veteran Android malware reverse engineer and this was his first time competing at Pwn2Own so we got first time Pwn2Own, first time Defcon, this is his first time in the US, 7 00:01:11,900 --> 00:01:14,460 this is a lot of stuff for this guy right here. 8 00:01:15,720 --> 00:01:24,420 So a little bit about us, so it was in 2022, no 2023 of last year, it was around May. 9 00:01:24,540 --> 00:01:40,940 Ilyas was looking to do Pwn2Own, for those of you that don't know what Pwn2Own is, it is a zero day competition where you try to hack some devices and some prize money involved and Ilyas was looking to do Pwn2Own this year, last year for his first time. 10 00:01:41,180 --> 00:01:46,820 And so he started researching previous vulnerabilities, previous competitions to see what that was like. 11 00:01:47,100 --> 00:01:59,040 And then he came across my name because I've done exploits, I've done previous attempts at Pwn2Own and he realized, oh shit, I work at the same company as Ken Gannon, I'm gonna reach out to him. 12 00:01:59,240 --> 00:02:05,740 So it was like May of last year, we get together, we talk over teams and we discuss what we want to hack. 13 00:02:05,840 --> 00:02:10,400 And we decided to hack the Samsung Galaxy S23. 14 00:02:10,980 --> 00:02:14,680 So that was as of May last, oh it's, hi Will, I didn't see you there. 15 00:02:14,720 --> 00:02:16,820 So that was May of last year. 16 00:02:16,880 --> 00:02:23,260 And then July of last year, ZDI announces their list of devices. 17 00:02:23,260 --> 00:02:27,560 And as you can see on the screen, it includes the Xiaomi 13 Pro. 18 00:02:27,700 --> 00:02:36,620 So the thing about the Xiaomi 13 Pro though is that the Xiaomi devices has not been a target of Pwn2Own since 2020, the COVID pandemic. 19 00:02:36,840 --> 00:02:43,120 And him and I got together again and we're like, oh, this sounds interesting. 20 00:02:43,120 --> 00:02:49,060 Maybe we should try to hack this new device or we should try to stick with Samsung Galaxy S23. 21 00:02:49,720 --> 00:02:57,720 And the thing about our discussions at the time is that we were discussing this on July 13th of last year, when the devices were announced. 22 00:02:57,720 --> 00:03:08,300 And as I said, we were thinking about Samsung Galaxy S23, but I have a history with Samsung at this point. 23 00:03:08,300 --> 00:03:17,840 A lot of traumatic experiences with Samsung, including a failed Pwn2Own attempt in 2021, because I am a very shitty programmer. 24 00:03:18,220 --> 00:03:26,100 So because of that, and we decided that maybe we should just go for the Samsung, for the Xiaomi 13 Pro instead. 25 00:03:26,100 --> 00:03:28,100 Something new, something fresh. 26 00:03:28,120 --> 00:03:32,000 We we just thought, you know, something that we both can learn together. 27 00:03:32,000 --> 00:03:34,380 What could possibly fucking go wrong, right? 28 00:03:34,380 --> 00:03:35,780 This is gonna be awesome. 29 00:03:36,480 --> 00:03:40,000 So let's talk about the Xiaomi 13 Pro. 30 00:03:40,320 --> 00:03:43,560 There's essentially two versions of this device. 31 00:03:43,560 --> 00:03:46,440 The global variant and the China variant. 32 00:03:46,460 --> 00:03:55,860 The global variant is available worldwide, wherever you can get a Xiaomi device, whereas the China variant is typically only found in China. 33 00:03:55,860 --> 00:03:58,700 At a hardware level, they're exactly the same thing. 34 00:03:58,700 --> 00:04:02,420 Same camera, same processor, same board, same chip set. 35 00:04:02,420 --> 00:04:10,740 The only minor difference between these two models is the type of firmware that can be installed on each device. 36 00:04:10,740 --> 00:04:19,040 Uh, the China model can have the China firmware as well as what's called the global variant firmware. 37 00:04:19,040 --> 00:04:23,880 Whereas the global model can only install the global variant firmware. 38 00:04:24,140 --> 00:04:34,680 Now, the unique part about the global firmware though, is that depending on the settings, you can have it emulate different regions. 39 00:04:34,680 --> 00:04:43,620 Like for example, in Europe, in India and in Taiwan, they have their own Taiwan, India and Europe firmware. 40 00:04:43,620 --> 00:04:51,640 Or you can tell the global mother one to emulate a different region and it will become that region. 41 00:04:51,760 --> 00:04:57,580 Why this is important is because certain regions have certain apps enabled or disabled. 42 00:04:57,640 --> 00:05:10,680 For example, if you set the region to United Kingdom, the get apps application, which is the Xiaomi uh application store, will be enabled if the phone is set to the UK region. 43 00:05:10,820 --> 00:05:16,380 Whereas if you were to set it to United States region, the get apps store is disabled. 44 00:05:16,480 --> 00:05:17,960 And this is just one example. 45 00:05:17,960 --> 00:05:24,880 Another one is that if you set the region to Russia, then the Yandex browser becomes enabled on the device. 46 00:05:24,880 --> 00:05:35,700 Keep in mind that this browser, the APK file, is in the firmware already, it's just that it gets enabled or disabled depending on what region the firmware is set to. 47 00:05:35,980 --> 00:05:50,400 Another example is that with the Spain region, the Opera browser becomes enabled and one more example, and one more example, the Indonesia region, the WhatsApp uh app becomes enabled or disabled. 48 00:05:50,560 --> 00:05:56,240 So at this point, we have multiple different regions, multiple apps being enabled, multiple apps being disabled. 49 00:05:56,340 --> 00:06:07,780 So we thought, well, why don't we determine what each region does, download all 400 plus applications from the phone, and start reverse engineering every single application. 50 00:06:08,700 --> 00:06:12,220 Except that's a really fucking bad idea because that's a lot of applications. 51 00:06:12,220 --> 00:06:22,200 So instead, we decided to just prioritize the Xiaomi developed applications, specifically the ones that were developed by Xiaomi for that phone. 52 00:06:22,860 --> 00:06:29,600 And so then 22 days later, we had 3 exploits for the GetApps application. 53 00:06:29,600 --> 00:06:32,220 And this is where Elias is going to talk about them real quick. 54 00:06:32,340 --> 00:06:33,540 Hey everyone. 55 00:06:33,540 --> 00:06:36,840 I'm going to be talking about the app we exploited. 56 00:06:37,420 --> 00:06:42,140 So we found 3 different exploits in the GetApps application. 57 00:06:42,480 --> 00:06:47,660 This application is also what the, what we ended up exploiting at point one. 58 00:06:47,740 --> 00:06:52,040 So we found 3 different ways to force install application. 59 00:06:52,040 --> 00:06:54,580 And the attack scenario is the following. 60 00:06:54,880 --> 00:07:06,700 Tapping a malicious hyperlink in a web browser would result in automatically install any application available on the GetApps store without user consent. 61 00:07:06,940 --> 00:07:10,620 Two of the methods were unfortunately patched before the competition. 62 00:07:10,680 --> 00:07:15,520 And I'm going to show here the exploit code of those 2 patch exploits. 63 00:07:15,520 --> 00:07:17,480 So here's the first one. 64 00:07:17,480 --> 00:07:21,300 Um, that was used to install WhatsApp automatically. 65 00:07:21,300 --> 00:07:25,680 On the first screenshot, you can see the browsable intent code. 66 00:07:25,680 --> 00:07:34,320 And if you've never created a browsable intent hyperlink before, we've also put the Java code which does the exact same thing. 67 00:07:34,320 --> 00:07:40,320 And there is an ID equal com.whatsapp parameter in there. 68 00:07:40,320 --> 00:07:46,180 And that's what could be used to install any application available in GetApps. 69 00:07:47,700 --> 00:07:50,980 Here's the second patch exploit. 70 00:07:50,980 --> 00:07:54,140 On the left, you can see the browsable intent code. 71 00:07:54,140 --> 00:07:59,640 And again, on the right, you can see the Java code which does the exact same thing. 72 00:07:59,640 --> 00:08:02,420 It's a lot chunkier as you can see. 73 00:08:02,460 --> 00:08:10,700 And if you base 64 decode that string, you'll be able to see the WhatsApp packet name, package name in there. 74 00:08:12,240 --> 00:08:21,380 Before we can get into the third exploit, we need to talk a little bit about WebView in GetApps. 75 00:08:21,380 --> 00:08:26,300 Um, GetApps had a WebView which contained a JavaScript interface. 76 00:08:26,300 --> 00:08:36,220 And for non-Android people, this means that JavaScript could be used to execute a set of Java function defined in the application. 77 00:08:36,220 --> 00:08:39,880 It's defined in the JavaScript interface class. 78 00:08:39,920 --> 00:08:53,520 And some of those JavaScript interface function were benign, like show toast function, for show toast functions, um, which literally just shows a toast, as you can see in the screenshot. 79 00:08:53,860 --> 00:08:58,640 But there are two interesting functions there for us, for point one. 80 00:08:58,640 --> 00:09:06,280 The install function, which installs any application available on the GetApps store without user consent. 81 00:09:06,280 --> 00:09:13,880 And the open app functions, which opens any specific application, again, without user consent. 82 00:09:14,520 --> 00:09:19,180 And this WebView is obviously dangerous, and Xiaomi knows it. 83 00:09:19,180 --> 00:09:30,660 So, they implemented some protection to ensure that attackers cannot obviously open this WebView and execute any of those JavaScript interface functions. 84 00:09:30,660 --> 00:09:39,480 And one of those protection was that whatever URL being loaded in the WebView, must be a valid URL. 85 00:09:39,480 --> 00:09:53,080 And by valid, I mean that it either starts with the HTTPS protocol, and the domain should belong to a defined set of, um, uh, white listed domains. 86 00:09:53,220 --> 00:09:55,840 All of them were owned by Xiaomi. 87 00:09:55,860 --> 00:10:07,240 And the other valid URL, um, should start with the file protocol, and the file should be located in the GetApps private directory. 88 00:10:07,300 --> 00:10:18,040 A GetApps private directory, um, names was always web hyphen raise, I hyphen some random numbers. 89 00:10:18,940 --> 00:10:22,020 So now, we have a new plan. 90 00:10:22,060 --> 00:10:26,880 First, we can launch the WebView and load a valid URL. 91 00:10:26,880 --> 00:10:33,820 Second, inject, inject some custom JavaScript code into the WebView, possibly through cross-site scripting. 92 00:10:34,080 --> 00:10:40,540 Third, having the JavaScript code execute the two JavaScript interface functions mentioned before. 93 00:10:40,540 --> 00:10:44,180 And fourth, got, get remote code execution. 94 00:10:45,340 --> 00:10:47,060 Okay, step one. 95 00:10:47,060 --> 00:10:51,540 To launch the WebView, we use the activity called join activity. 96 00:10:51,700 --> 00:10:55,500 This activity could be launched via browsable intent. 97 00:10:55,500 --> 00:11:01,260 Again, this means that this activity could be launched via hyperlink in a website. 98 00:11:01,280 --> 00:11:07,140 And it was also really simple to tell join activity what URL we wanted to load in the WebView. 99 00:11:07,140 --> 00:11:09,920 It was just a get parameter called URL. 100 00:11:11,540 --> 00:11:24,160 This is the proof of concept, uh, which launched join activity and loaded the file detail dot html that was in the GetApps private folder. 101 00:11:24,460 --> 00:11:28,820 That detail dot html is pretty blank, as you can see on the screenshot. 102 00:11:28,820 --> 00:11:34,000 Um, but that's just because we didn't give him the application's data to use. 103 00:11:35,020 --> 00:11:37,000 So now step one is done. 104 00:11:37,000 --> 00:11:38,760 Let's move on to step two. 105 00:11:39,660 --> 00:11:43,600 We had two options to inject custom JavaScript. 106 00:11:43,680 --> 00:11:51,760 We could either load a show me domain URL and then print this dot URL and look for usable vulnerabilities. 107 00:11:51,780 --> 00:11:58,740 Or, we can analyze the file in the private folder and look for user input vulnerabilities. 108 00:11:59,100 --> 00:12:02,120 We choose the second option. 109 00:12:02,640 --> 00:12:07,740 And now this research just became a JavaScript source code review job. 110 00:12:07,880 --> 00:12:15,340 And as you can see on the picture, this was my reaction when I realized what was going on. 111 00:12:15,900 --> 00:12:21,080 Um, point one will make you do stuff you really don't want to do, but we still did it. 112 00:12:21,980 --> 00:12:28,520 Um, in, in the, uh, the web hyphen res folder, um, you can see the folder . 113 00:12:28,520 --> 00:12:33,400 We had like HTML file and JavaScript file with similar names. 114 00:12:33,400 --> 00:12:42,400 As an example, we had the detail dot HTML file and this file would load the detail dot chunk dot JS. 115 00:12:42,420 --> 00:12:47,420 Some JavaScript file would accept user input via get parameters. 116 00:12:47,720 --> 00:12:56,420 But also, all of those JavaScript file had a building function to filter out any cross-scripting payloads. 117 00:12:56,420 --> 00:12:57,740 Well, except for this one. 118 00:12:57,760 --> 00:13:00,200 One that we found. 119 00:13:00,240 --> 00:13:10,960 There was a file called integral dialogue page dot chunk dot JS which failed to sanitize cross-scripting payloads in one specific area. 120 00:13:10,960 --> 00:13:15,960 So, let's try to get a dumb XSS payload working in this file. 121 00:13:16,340 --> 00:13:20,080 This was the initial payload that was used for testing. 122 00:13:20,080 --> 00:13:23,820 On the right, you can see the decoded version of it. 123 00:13:23,820 --> 00:13:27,580 So, we had different inputs and we had different payloads. 124 00:13:27,580 --> 00:13:38,600 All of them started with XSS test, 1, 2, 3, 4, 5, and they all ended with, um, two characters that was encoded. 125 00:13:38,600 --> 00:13:43,600 And those characters were double quote symbol and the less than symbol. 126 00:13:45,040 --> 00:13:49,980 On the left is what the web view looked like with the payloads. 127 00:13:49,980 --> 00:13:53,740 And on the right is a debugging window in Chrome. 128 00:13:53,920 --> 00:14:02,040 Our less than symbol character was unfiltered in one of the area, specifically the XSS test 2. 129 00:14:02,040 --> 00:14:06,220 All the others were filtered, filtered the right way. 130 00:14:06,660 --> 00:14:15,060 So, now , with this XSS test 2 payload, we can try to just pop a simple alert box. 131 00:14:15,440 --> 00:14:17,620 And then, what the hell? 132 00:14:17,620 --> 00:14:19,220 We got some errors. 133 00:14:19,360 --> 00:14:25,660 Locat was showing us disabled XSS text, XSS errors, um, errors. 134 00:14:25,660 --> 00:14:27,800 So, let's dig into that. 135 00:14:27,940 --> 00:14:31,480 Remember the protection against the web view that we mentioned earlier? 136 00:14:31,480 --> 00:14:33,860 There was another one, unfortunately. 137 00:14:34,200 --> 00:14:40,180 The GitOps application had a built in XSS filter in the Java code itself. 138 00:14:40,500 --> 00:14:44,800 And it looked for XSS payload in the URL. 139 00:14:45,060 --> 00:14:51,620 So, if the URL had any XSS payload found, then the URL would fail to load. 140 00:14:52,320 --> 00:14:57,120 And here is the list of the XSS filter. 141 00:14:57,120 --> 00:15:03,400 And as you can see, it detected our forward slash script string in our payload. 142 00:15:03,660 --> 00:15:09,040 At this point, we decided that maybe we shouldn't be using script string at all. 143 00:15:09,640 --> 00:15:13,360 Maybe because there might be other filters we haven't found yet. 144 00:15:13,360 --> 00:15:17,820 And also, script is just too obvious for an XSS payload. 145 00:15:18,740 --> 00:15:29,780 Okay, so going through the list and thinking about what could we use now, we realized that the Java XSS filter was just looking for string matches. 146 00:15:29,960 --> 00:15:38,380 So, we thought, what if we could encode, um, a less than symbol, um, a character in one of those payloads. 147 00:15:38,380 --> 00:15:41,900 Such as, the less than symbol SVG. 148 00:15:42,540 --> 00:15:44,360 So, that's what we tried. 149 00:15:44,360 --> 00:15:54,240 And we used, um, we used a SVG unload to run the JavaScript alert box and that, that said, yeah, dumb XSS here. 150 00:15:54,720 --> 00:15:57,240 And boom, it worked. 151 00:15:57,240 --> 00:16:00,280 We finally have an XSS in the web view now. 152 00:16:01,400 --> 00:16:03,340 So, step two is done. 153 00:16:03,340 --> 00:16:04,960 Let's move on to step three. 154 00:16:04,960 --> 00:16:05,980 Oops, sorry. 155 00:16:06,800 --> 00:16:12,200 Now, let's try to call the, those JavaScript interface function mentioned earlier. 156 00:16:12,480 --> 00:16:19,220 To test, we tested our payload just to see if we could run the show toast function. 157 00:16:19,220 --> 00:16:23,700 And on the screen shot on the right, you can see that we managed to do that. 158 00:16:24,760 --> 00:16:35,440 So now, after some time, we did some reverse engineering and we came up with this lovely JavaScript payload to install any application. 159 00:16:35,540 --> 00:16:53,640 On the screen shot, you can see that we first called the install with the package name of the application we want to install and then we run a loop, um, and wait for the, the application to install and then we use the open app with the package name again to open the application. 160 00:16:54,160 --> 00:16:56,920 So now, there is just one problem. 161 00:16:57,140 --> 00:16:59,600 We didn't know what to install. 162 00:17:00,480 --> 00:17:03,580 So now, what application should we install? 163 00:17:03,600 --> 00:17:10,580 Ideally, we want some malware that we can control in the application store, store somewhere. 164 00:17:10,600 --> 00:17:14,000 And I'm going to let Ken talk about his baby now. 165 00:17:15,840 --> 00:17:22,720 So, for those of you that don't know, I'm also an active contributor for this Android tool Drozer. 166 00:17:22,740 --> 00:17:23,220 Yay! 167 00:17:23,220 --> 00:17:25,620 For those of you that know what Drozer is, yay! 168 00:17:25,620 --> 00:17:43,980 Uh, and because I'm an active contributor, I know how to reskin it into an application called Sunfish which does literally the same exact thing as Drozer except it starts a bind shell on boot as well and then I uploaded it to this Xiaomi app store. 169 00:17:44,500 --> 00:17:51,900 So, for a little bit on the Xiaomi app store, there was a, a copy of Drozer called Sunfish up on the app store. 170 00:17:52,080 --> 00:17:53,340 That was fun. 171 00:17:53,440 --> 00:17:56,120 So, we had a new payload. 172 00:17:56,120 --> 00:18:05,220 In this case, the payload is going to step one, install Sunfish and then step two, open it after Sunfish is installed on the device. 173 00:18:05,880 --> 00:18:09,820 So, alright, all the pieces, all the puzzle pieces are in place. 174 00:18:10,520 --> 00:18:13,560 Let's uh, let's watch it do its thing real quick. 175 00:18:13,560 --> 00:18:15,400 We open up Google Chrome. 176 00:18:15,540 --> 00:18:20,300 Uh, in this case, we're going to, as you can see, it's a new copy of Chrome with all those popups. 177 00:18:20,300 --> 00:18:26,480 We browse to the web server I had at my house, uh, over HTTP because I'm lazy. 178 00:18:26,580 --> 00:18:32,920 But eventually what's going to happen is I will load the website and there's a yay POC hyperlink. 179 00:18:32,920 --> 00:18:34,780 Click that one link. 180 00:18:34,780 --> 00:18:40,440 This appears and then Sunfish gets installed and boom, Sunfish is now installed. 181 00:18:40,440 --> 00:18:42,440 The server has started as well. 182 00:18:42,440 --> 00:18:44,080 I put the phone down. 183 00:18:44,080 --> 00:18:50,120 At this point, I have the IP address of the phone that reached out to my web server as well. 184 00:18:50,160 --> 00:19:01,180 And so, to put the bind shell open, all I had to do was use my re-skinned Drozer console thingy whatever to connect to the Drozer application installed on the phone. 185 00:19:01,260 --> 00:19:07,780 And then for, per the rules of Pwn2Own, as long as you get RCE on the device, that is good enough. 186 00:19:08,020 --> 00:19:11,680 Including just RCE as a single application. 187 00:19:11,680 --> 00:19:14,960 So, in this case, I'm running ID and who am I as Sunfish? 188 00:19:15,240 --> 00:19:16,200 There we go. 189 00:19:16,200 --> 00:19:17,960 One click to, one click to RCE. 190 00:19:18,060 --> 00:19:19,220 Yay! 191 00:19:20,960 --> 00:19:23,100 So, we got RCE. 192 00:19:23,120 --> 00:19:24,800 All the steps are done. 193 00:19:24,800 --> 00:19:28,380 And like I said, that was only 22 days later. 194 00:19:28,380 --> 00:19:30,200 We had 22 days of research time. 195 00:19:30,200 --> 00:19:34,960 We had 77 more days to go to to do whatever the fuck we wanted. 196 00:19:35,000 --> 00:19:36,420 Everything was awesome. 197 00:19:36,420 --> 00:19:39,060 Nothing could have possibly gone wrong. 198 00:19:39,420 --> 00:19:41,660 Let's discuss what went wrong. 199 00:19:42,160 --> 00:19:48,300 So, late August of 2023, Xiaomi released Xiaomi made changes to their get app server. 200 00:19:48,300 --> 00:20:01,620 Uh, specifically, one of the changes that they made was that the install parameter, the install function that we were using, now required a shit ton more code. 201 00:20:01,620 --> 00:20:04,720 Our payload was now chonky as fuck. 202 00:20:04,820 --> 00:20:07,280 But wait, there's more. 203 00:20:07,360 --> 00:20:12,840 You see, this payload did not work in all parts of the world. 204 00:20:12,900 --> 00:20:21,960 So, for a little bit of background, last year and around August, late August 2023, I went on vacation to Japan and the Philippines. 205 00:20:21,960 --> 00:20:28,560 And this new chonky install payload would work in Japan and the United Kingdom. 206 00:20:28,560 --> 00:20:31,400 Thanks to Ilias here being based in the United Kingdom. 207 00:20:31,560 --> 00:20:35,380 But it fucking wouldn't work in the Philippines for some reason. 208 00:20:35,900 --> 00:20:49,360 And while in uh, Japan and the Philippines, I noticed that the get apps application was showing different content based on the physical location of the phone. 209 00:20:49,480 --> 00:20:51,520 Not the IP address. 210 00:20:51,900 --> 00:21:01,040 I'm talking about doing a factory reset and you, you know, you go, factory reset, you go through the whole setup, the cell phone towers are, the cell phone signal is now enabled on the phone. 211 00:21:01,260 --> 00:21:13,320 And for some reason, after you do a factory reset and you go through the initial setup, there was stuff on the uh, in the get app store that was exclusive to that one region. 212 00:21:14,220 --> 00:21:26,040 And what I also realized at the time, or as we were doing like research, like figuring out what is going on, uh, VPN did not affect this. 213 00:21:26,040 --> 00:21:37,860 The reason I was talking about factory reset is because during Pwn2Own specifically, uh, they typically factory reset their phone before every single uh, entry goes up. 214 00:21:37,860 --> 00:21:43,360 And so then during a factory reset process, the cell phone tower, the cell phone signal antenna is enabled. 215 00:21:43,360 --> 00:21:44,920 So we wanted to mimic that. 216 00:21:44,920 --> 00:21:54,200 And we realized that just really weird stuff was happening with the get app store depending on where I was in Japan and the Philippines. 217 00:21:55,700 --> 00:22:09,740 And so then after looking at the developer documentation and looking at uh, the, the developer portal I had access to since I uploaded Sunfish to their app store, I realized that there were some places that were launched. 218 00:22:09,820 --> 00:22:15,820 Uh, for example, get apps was not launched in the US, UK and Japan. 219 00:22:15,820 --> 00:22:19,620 But it was launched in the Philippines. 220 00:22:20,600 --> 00:22:26,920 Now I don't have definitive proof, but this is literally the only thing I could think of at the moment. 221 00:22:26,920 --> 00:22:38,280 Maybe we were seeing different behavior in the Philippines because the get app store was not, was launched in the Philippines but was not launched anywhere else that we've been to. 222 00:22:39,280 --> 00:22:47,580 Now, thankfully, cause we are awesome, eventually we found a way for the payload to work in the Philippines. 223 00:22:47,760 --> 00:22:51,440 But that payload would only work in the Philippines. 224 00:22:51,440 --> 00:22:54,640 It would not work in US, UK or Japan. 225 00:22:55,140 --> 00:22:57,020 We didn't know what to do. 226 00:22:57,020 --> 00:23:03,220 Because another issue came up, Pwn2Own that we were going to takes place in Canada. 227 00:23:03,520 --> 00:23:06,260 Do we have a payload that works in Canada? 228 00:23:06,420 --> 00:23:11,480 We, I like, it's a theory , this whole like launch not launch thing is just a theory. 229 00:23:11,480 --> 00:23:15,580 And technically, get apps was not launched in Canada. 230 00:23:15,580 --> 00:23:20,480 So maybe, maybe our get apps or non-launch payload would work in Canada . 231 00:23:20,480 --> 00:23:21,680 We're not entirely sure. 232 00:23:21,680 --> 00:23:23,400 It'd be nice to confirm. 233 00:23:23,880 --> 00:23:27,060 Well, NCC group is a global company. 234 00:23:27,160 --> 00:23:29,160 And we have offices in Canada. 235 00:23:29,160 --> 00:23:33,180 So surely we can just, no, no, we're not, we're not working with the Canada office for this talk. 236 00:23:33,240 --> 00:23:37,880 Because you cannot get the Xiaomi 13 Pro in Canada. 237 00:23:38,160 --> 00:23:42,960 So, if you try to get the Xiaomi 13 Pro here in the US, you're going to go through eBay. 238 00:23:42,960 --> 00:23:47,200 You're going to go through a, a seller on eBay or on Amazon or something to get the phone. 239 00:23:47,300 --> 00:23:57,240 Uh, in fact, my phone, I know for a fact, what, was a China model imported here from China, sold by a, a Chinese guy on eBay. 240 00:23:57,580 --> 00:24:01,040 I could not procure the Xiaomi 13 Pro in Canada. 241 00:24:01,040 --> 00:24:06,220 eBay Canada, Amazon Canada, none of the cell phone providers in Canada, like I could not get it in Canada. 242 00:24:07,160 --> 00:24:10,700 So, you know, I'm in North America, I might as well just send my phone to Canada. 243 00:24:10,700 --> 00:24:13,400 No, no, I'm not sending my phone to Canada. 244 00:24:14,040 --> 00:24:17,080 Because another issue came up with my schedule specifically. 245 00:24:17,080 --> 00:24:27,320 You see, in August of 2023, uh, or 20, 2023 in general, NCC announced that they were going to open an office in the Philippines. 246 00:24:27,480 --> 00:24:35,220 And I was chosen to go out to Manila to spend the rest of 2023 in the Philippines to help set it up. 247 00:24:35,240 --> 00:24:37,200 Uh, fun fact, I'm still in the Philippines. 248 00:24:37,440 --> 00:24:45,440 So, because of this, I had a very, very weird travel schedule last year. 249 00:24:45,660 --> 00:24:49,680 Because as I said earlier, I went on a vacation, right? 250 00:24:49,780 --> 00:24:53,120 I come back from vacation on September 10th. 251 00:24:53,120 --> 00:25:02,320 And then on September 11th through 14th, I'm at my house, I'm like packing, I'm like trying to get ready because I'm going to be spending the rest of the year in the Philippines. 252 00:25:02,660 --> 00:25:09,320 Uh, and then on Friday the 15th, and, and I do this thing in Vermont for like a race, I come back on the 17th. 253 00:25:09,320 --> 00:25:11,840 And then again, 18th through 20, I'm at home. 254 00:25:11,840 --> 00:25:15,460 And then the 21st of September, I fly to the Philippines. 255 00:25:15,460 --> 00:25:20,260 That leaves only seven business days where I am in the U.S. 256 00:25:20,500 --> 00:25:22,180 So that's the schedule. 257 00:25:22,340 --> 00:25:25,920 Uh, it's a little bit hectic, but it gets more hectic, I promise. 258 00:25:25,920 --> 00:25:31,420 But first, we want to, I want to talk about why those seven days sucks. 259 00:25:31,480 --> 00:25:40,920 Because it is too risky to send a phone to Canada, pay Canada import taxes, test and develop an exploit, send the phone back to U.S., and then pay U.S. 260 00:25:40,920 --> 00:25:42,960 import taxes all in seven days. 261 00:25:43,320 --> 00:25:45,340 That is not going to happen. 262 00:25:46,180 --> 00:25:51,160 Well, what if I just send my phone to Canada and keep it there? 263 00:25:51,500 --> 00:25:55,880 Well, I, I, the Philippines has a lot of Xiaomi stores. 264 00:25:55,880 --> 00:26:00,480 That's, there's literally a picture of a Xiaomi store that I sent to Italy, that's when I found my first one. 265 00:26:00,480 --> 00:26:03,420 And they were selling Xiaomi 13 Pros for 1,000 U.S. 266 00:26:03,420 --> 00:26:03,900 dollars. 267 00:26:03,900 --> 00:26:07,320 I can just go to the Philippines and get a new phone, right? 268 00:26:08,120 --> 00:26:11,900 Well, the problem is that now we're dealing with three different time zones. 269 00:26:11,900 --> 00:26:17,860 If I'm in the Philippines, he's in the U.K., and the Canada consultants are in Eastern Standard Time. 270 00:26:17,860 --> 00:26:26,200 Uh, for those of you that don't know, half of the time of the year, the Eastern Standard Time and the Philippines are literally 12 hours, 12 hour difference. 271 00:26:26,620 --> 00:26:36,900 And trying to manage those time zones on top of the consultants in Canada being available, that sounds like way too much fucking stress for a theory. 272 00:26:37,420 --> 00:26:44,160 On top of that, the biggest issue, the biggest threat to any pawn to own competition are the patches. 273 00:26:44,420 --> 00:26:50,060 So, at this point, we had a good idea as to how the patches worked. 274 00:26:50,120 --> 00:27:03,820 Uh, first, during the first week of, of every month, a firmware gets updated to the beta channel and in, and as, after that first week in the beta channel, the firmware also gets put in the stable channel. 275 00:27:03,860 --> 00:27:08,000 With that firmware update comes a new GetApps update. 276 00:27:08,000 --> 00:27:11,320 Every single month, there is a new update for GetApps. 277 00:27:11,760 --> 00:27:19,140 So, the real schedule now is that after I fly back to the Philippines, no one is in the U.S. 278 00:27:19,140 --> 00:27:23,660 to test the exploit, or no one's in North America to test the exploit a... 279 00:27:27,910 --> 00:27:29,890 Hey, you know what? 280 00:27:51,180 --> 00:27:54,880 If I try to shut... Alright. 281 00:27:55,120 --> 00:27:56,760 No one's in North America. 282 00:27:56,760 --> 00:27:57,620 Hey, we're back. 283 00:27:57,620 --> 00:27:58,400 Yay. 284 00:27:58,920 --> 00:27:59,740 Alright. 285 00:27:59,740 --> 00:28:08,360 Yeah, like I said, no one's back in, no one's in here in North America to test stuff and we have a new patch coming out sometime, supposedly October 9th, right? 286 00:28:11,240 --> 00:28:13,880 I really, really want to test this theory though. 287 00:28:14,200 --> 00:28:15,300 I really, really do. 288 00:28:15,420 --> 00:28:17,680 Because, here's the thing. 289 00:28:17,920 --> 00:28:21,500 We think that Canada is a non-launched region, right? 290 00:28:21,500 --> 00:28:22,800 Just like with U.K. 291 00:28:22,800 --> 00:28:23,540 or U.K. 292 00:28:23,540 --> 00:28:24,660 and U.S. 293 00:28:24,760 --> 00:28:26,320 uh, and Japan. 294 00:28:26,400 --> 00:28:42,580 If we can group, and this is just a theory we had at the moment, if we could group Canada into that non-launched region and test and make sure that we, that, that theory is true, then let's say that October rolls around and they release their patch, right? 295 00:28:42,580 --> 00:28:48,280 All we would need is Ilyas here to test his U.K., uh, his exploit in the U.K. 296 00:28:48,280 --> 00:28:56,240 And if it works, then in theory it should work in the U.S., in Japan and in Canada. 297 00:28:57,440 --> 00:29:02,760 So, earlier I mentioned that it costs 1,000 U.S. 298 00:29:02,760 --> 00:29:05,820 dollars to buy a new phone. 299 00:29:06,380 --> 00:29:08,120 Another thing that costs 1,000 U.S. 300 00:29:08,120 --> 00:29:18,660 dollars is to go to Canada, literally for a day, literally hang out in the Marriott Hotel at Toronto Airport and test the exploit. 301 00:29:18,660 --> 00:29:20,320 And then fly back the next day. 302 00:29:20,720 --> 00:29:22,540 So that's what I did. 303 00:29:22,900 --> 00:29:37,440 On, let's see, on September 17th I fly back from my race, on September 18th I fly back to Toronto to test the exploit, on September 19th uh, I fly back home and then on September 21st I fly to Manila. 304 00:29:37,440 --> 00:29:39,580 So many miles. 305 00:29:40,180 --> 00:29:44,500 And like a, and after a few hours in Toronto, it was confirmed. 306 00:29:44,500 --> 00:29:45,420 We did it. 307 00:29:45,420 --> 00:29:49,300 We, we confirmed that this was a non-launched region. 308 00:29:49,400 --> 00:29:57,060 And so now, if our, if October rolls around, our exploit works in the U.K., we should be good. 309 00:29:57,060 --> 00:29:58,820 Everything is awesome. 310 00:29:58,820 --> 00:30:06,340 Uh, we are, uh, we are so excited for everything to happen and we are going to get our, uh, get our first phone to own wind. 311 00:30:06,340 --> 00:30:07,220 Right Elias? 312 00:30:07,220 --> 00:30:08,240 Yeah! 313 00:30:09,240 --> 00:30:12,640 So, October rolls around. 314 00:30:12,640 --> 00:30:17,220 As expected, get apps releases their, their update in October. 315 00:30:17,220 --> 00:30:18,880 It's literally October 9th. 316 00:30:18,880 --> 00:30:24,620 I have it marked down in my calendar and we confirm that the exploit works. 317 00:30:24,700 --> 00:30:27,240 We have our books flight for September 20th. 318 00:30:27,240 --> 00:30:30,480 I'm flying from the Philippines, he's flying from the U.K. 319 00:30:30,480 --> 00:30:31,880 We, all this is good to go. 320 00:30:31,880 --> 00:30:33,380 We're going to fucking do this. 321 00:30:33,380 --> 00:30:34,840 No, hold on. 322 00:30:36,080 --> 00:30:43,840 One week before phone to own, Xiaomi releases an out of band update to get apps. 323 00:30:44,100 --> 00:30:49,140 Which happened to fucking remove the file that we were going to exploit. 324 00:30:50,200 --> 00:30:54,900 Specifically, the file was removed from the APK file itself. 325 00:30:54,900 --> 00:31:01,360 For those of you that are on Android, uh, that means that the file was removed from the installer file of the app itself. 326 00:31:01,360 --> 00:31:03,120 It was no longer there. 327 00:31:04,420 --> 00:31:07,880 But thankfully they are, Xiaomi also has shitty programmers. 328 00:31:08,860 --> 00:31:14,280 Because they forgot to remove the file from the device if it was already there. 329 00:31:15,100 --> 00:31:21,860 So, in theory, assuming that we show up to phone to own and we're one of the first few people to hack the phone. 330 00:31:21,860 --> 00:31:30,960 And like I said earlier, uh, uh, ZDI usually factory resets the target device per, uh, competition. 331 00:31:30,960 --> 00:31:32,660 They usually have multiple devices. 332 00:31:32,760 --> 00:31:38,540 So, as long as we could hack one of the initial devices before they factory reset it again. 333 00:31:38,540 --> 00:31:41,800 Again, it's a dice roll, but there's still a chance. 334 00:31:41,960 --> 00:31:43,500 We still follow through. 335 00:31:43,500 --> 00:31:46,300 We still decide, okay, this is not that big a deal. 336 00:31:46,300 --> 00:31:47,960 Let's fucking do this. 337 00:31:47,960 --> 00:31:49,500 So, we fly out to Canada. 338 00:31:49,500 --> 00:31:51,240 It is now October 20th. 339 00:31:51,240 --> 00:31:53,000 Him and I are both on our flights. 340 00:31:53,900 --> 00:31:56,260 Literally while I'm on the plane. 341 00:31:56,300 --> 00:32:00,980 And the Saturday before phone to own, there is another get apps update. 342 00:32:01,260 --> 00:32:12,180 Now, this is the most interesting part because they introduced a new thing in get apps where they can modify what files are on the device using Google Firebase. 343 00:32:12,520 --> 00:32:14,680 Which is really, really cool. 344 00:32:14,920 --> 00:32:18,840 And for some reason they pushed our file back to the device. 345 00:32:19,180 --> 00:32:26,260 Like if you were moved, if you went in and manually removed the file that we were going to exploit, they just pushed it back for us. 346 00:32:26,700 --> 00:32:28,240 That's so fucking convenient. 347 00:32:28,240 --> 00:32:29,560 Thank you, Xiaomi. 348 00:32:30,120 --> 00:32:32,640 Except they added one more thing. 349 00:32:32,860 --> 00:32:38,640 So, we were going to exploit the activity, join activity, as we, as Ilya said. 350 00:32:38,920 --> 00:33:01,820 But they happened to add code to that one activity where if the intent came from any of these four browsers, the uh, Xiaomi browser, uh, the Android HTML viewer, the Android NFC, or Google fucking Chrome, then join activity will not launch. 351 00:33:02,320 --> 00:33:04,380 What the fuck, Xiaomi? 352 00:33:04,440 --> 00:33:08,520 As you all saw in my video earlier, we use specifically Google Chrome. 353 00:33:08,520 --> 00:33:12,420 We can't, there's no other browsers on this phone that we can use. 354 00:33:13,960 --> 00:33:16,060 Except there is. 355 00:33:16,820 --> 00:33:23,700 Because if you set the region to Spain, the Opera browser is enabled on the phone. 356 00:33:24,600 --> 00:33:30,660 So technically we had an exploit for the country of Spain specifically. 357 00:33:31,180 --> 00:33:35,680 Which is still technically a zero day, because now it's a zero day in Spain. 358 00:33:36,420 --> 00:33:38,200 So we told ZDI this. 359 00:33:38,200 --> 00:33:43,600 We told them, hey, Xiaomi is doing some shitty stuff, but Spain. 360 00:33:43,740 --> 00:33:46,700 And ZDI goes, Spain. 361 00:33:46,760 --> 00:33:47,900 And we're good to go. 362 00:33:47,900 --> 00:33:48,680 And we're good to go. 363 00:33:48,680 --> 00:33:49,420 Alright. 364 00:33:49,420 --> 00:33:50,820 We dodged another bullet. 365 00:33:50,820 --> 00:33:52,220 We can now, we can do this. 366 00:33:52,220 --> 00:33:54,140 We can hack a Xiaomi 13 Pro. 367 00:33:54,140 --> 00:34:04,100 The first day of the competition, Xiaomi starts disabling the ability to install apps from their app store. 368 00:34:05,300 --> 00:34:08,800 Now, I don't know if this was a global thing. 369 00:34:08,800 --> 00:34:09,920 I genuinely don't know. 370 00:34:09,920 --> 00:34:12,600 I don't talk to many Xiaomi users after this. 371 00:34:12,600 --> 00:34:13,920 I don't want to. 372 00:34:14,920 --> 00:34:24,700 But the very least, the people in Toronto area that were, that were also going to hack the Xiaomi 13 Pro, they corroborated it. 373 00:34:24,700 --> 00:34:26,920 They all saw the same issue that we saw. 374 00:34:26,920 --> 00:34:30,080 It was a hit or miss, whether an application wouldn't install. 375 00:34:30,080 --> 00:34:34,680 It was like a 20% chance that we could install an application. 376 00:34:35,600 --> 00:34:37,660 And they killed my boy. 377 00:34:39,860 --> 00:34:42,900 This, this really genuinely hurts. 378 00:34:43,040 --> 00:34:46,000 That I could not install Sunfish at all. 379 00:34:46,000 --> 00:34:48,340 It was a 0% success rate. 380 00:34:49,060 --> 00:34:55,880 So, on that day, there was 2 teams that were supposed to go and hack the Xiaomi 13 Pro. 381 00:34:55,880 --> 00:35:02,140 Uh, it was us at NCC group and it was, uh, the awesome people at Team Viettel. 382 00:35:02,140 --> 00:35:05,000 Uh, Team Viettel went first, we went second. 383 00:35:05,060 --> 00:35:11,580 Uh, we discussed with ZDI what happened and we're like, what the fuck do we do? 384 00:35:11,580 --> 00:35:15,300 Oh wait, can we please just install one random app from the app store? 385 00:35:15,300 --> 00:35:17,220 And they go, okay. 386 00:35:18,640 --> 00:35:19,860 And we did. 387 00:35:20,600 --> 00:35:21,640 We did it. 388 00:35:21,640 --> 00:35:27,560 Technically that works because we showed ZDI that we had malware up on the app store. 389 00:35:27,780 --> 00:35:36,560 ZDI already heard from other contestants around the area that Xiaomi was doing something very funky with their app store and they're like, fine, good enough. 390 00:35:36,640 --> 00:35:45,520 So, Team Viettel managed to install Discord and I, we installed no pics color by number and pixel. 391 00:35:45,520 --> 00:35:47,000 Yeah, it was that app. 392 00:35:47,000 --> 00:35:50,660 I literally just found another random app on the app store and we installed it. 393 00:35:50,680 --> 00:35:52,580 And we did it! 394 00:35:52,860 --> 00:35:54,920 We got a win! 395 00:35:54,940 --> 00:35:56,040 Yay! 396 00:35:56,420 --> 00:36:04,780 Except that's not the end of the story because the next day, Xiaomi releases another update. 397 00:36:04,780 --> 00:36:11,400 First, they removed the file that we exploited and now nothing installs from the app store. 398 00:36:11,400 --> 00:36:12,100 Period. 399 00:36:12,100 --> 00:36:16,560 The day before, those that got 20 percent success rate on installing something, no. 400 00:36:16,560 --> 00:36:18,740 The next day, nothing gets installed. 401 00:36:18,740 --> 00:36:19,660 Period. 402 00:36:20,060 --> 00:36:24,540 And on top of that, they added code to block Yandex and Opera. 403 00:36:27,960 --> 00:36:30,140 You can't make this shit up. 404 00:36:30,480 --> 00:36:35,740 So, the rest of the week, it was just failure after failure after failure after failure. 405 00:36:35,740 --> 00:36:39,460 Unfortunately, it's pretty obvious why nothing would install. 406 00:36:39,460 --> 00:36:42,280 They removed a bunch of other stuff from the app. 407 00:36:42,600 --> 00:36:50,620 And, you know, the lesson of this story is that during Pwn2Own specifically, Xiaomi is the most secure phone in the world. 408 00:36:51,620 --> 00:37:01,020 If there was one phone I would have on me during Pwn2Own specifically, especially here at DEF CON where nothing bad happens, it's a Xiaomi 13 Pro during Pwn2Own. 409 00:37:02,220 --> 00:37:06,840 There is one more side to this story that I think everyone here should check out eventually. 410 00:37:06,860 --> 00:37:23,440 Uh, my friend Maxploit, who was also a competitor last year at Pwn2Own, uh, he says, and I quote, props to the Xiaomi crew who proved you can patch RCE bugs completely remotely in only a few hours and also break your flagship device across the country as long as you're doing it to be a dick. 411 00:37:23,440 --> 00:37:26,440 Not because you actually care about fixing things. 412 00:37:26,660 --> 00:37:33,100 If you guys want, he actually talked earlier this year at OffensiveCon about his side of the story as well as his exploit. 413 00:37:33,220 --> 00:37:35,120 I do recommend you all check it out. 414 00:37:35,120 --> 00:37:36,720 It's also a fun time. 415 00:37:37,140 --> 00:37:39,540 So, after Pwn2Own, what happened? 416 00:37:39,540 --> 00:37:47,700 The browser blocking code got removed for some reason and applications can install just like normal. 417 00:37:47,700 --> 00:37:48,540 Everything works. 418 00:37:48,540 --> 00:37:50,600 Everything is back to normal. 419 00:37:51,180 --> 00:37:55,900 Now, both us and team Vietel never got credit from Xiaomi. 420 00:37:55,900 --> 00:38:02,640 Usually with a vendor they are like, hey we want to acknowledge so and so working together with, with ZDI to do so and so. 421 00:38:02,640 --> 00:38:06,080 No, they said fuck you, we don't, we don't want to acknowledge you. 422 00:38:06,120 --> 00:38:10,260 So, Zero Day Initiative had to be the one to give us CVE numbers. 423 00:38:10,460 --> 00:38:17,140 And they said something in their posting that was possibly my favorite quote of this entire time. 424 00:38:17,140 --> 00:38:22,880 Xiaomi informed ZDI they would assign a CVE but never followed through. 425 00:38:24,300 --> 00:38:30,180 Except they did, specifically to team Vietel a few days later. 426 00:38:30,980 --> 00:38:32,920 But not us. 427 00:38:33,660 --> 00:38:36,440 Where's my fucking CVE Xiaomi? 428 00:38:37,460 --> 00:38:39,120 And that's it. 429 00:38:39,120 --> 00:38:40,300 That's the end of our story. 430 00:38:40,300 --> 00:38:41,220 Yay! 431 00:38:41,560 --> 00:38:44,820 I hope they get the worst vendor response at Pony Awards. 432 00:38:44,820 --> 00:38:45,840 Yay! 433 00:38:46,920 --> 00:38:53,100 Uh, we're also very introverted so we're gonna take questions out there instead of up here. 434 00:38:53,100 --> 00:38:54,620 If you guys don't mind, alright? 435 00:38:54,960 --> 00:38:56,280 Alright, thank you for coming! 436 00:38:56,280 --> 00:38:57,100 Yay!