WEBVTT

00:02.820 --> 00:04.540
Alright, hello!

00:07.600 --> 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.

00:15.540 --> 00:24.380
This is Xiaomi the money, our Toronto Pwn2Own 2023 exploit and behind the scenes story.

00:24.740 --> 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.

00:37.460 --> 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.

00:54.080 --> 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,

01:11.900 --> 01:14.460
this is a lot of stuff for this guy right here.

01:15.720 --> 01:24.420
So a little bit about us, so it was in 2022, no 2023 of last year, it was around May.

01:24.540 --> 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.

01:41.180 --> 01:46.820
And so he started researching previous vulnerabilities, previous competitions to see what that was like.

01:47.100 --> 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.

01:59.240 --> 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.

02:05.840 --> 02:10.400
And we decided to hack the Samsung Galaxy S23.

02:10.980 --> 02:14.680
So that was as of May last, oh it's, hi Will, I didn't see you there.

02:14.720 --> 02:16.820
So that was May of last year.

02:16.880 --> 02:23.260
And then July of last year, ZDI announces their list of devices.

02:23.260 --> 02:27.560
And as you can see on the screen, it includes the Xiaomi 13 Pro.

02:27.700 --> 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.

02:36.840 --> 02:43.120
And him and I got together again and we're like, oh, this sounds interesting.

02:43.120 --> 02:49.060
Maybe we should try to hack this new device or we should try to stick with Samsung Galaxy S23.

02:49.720 --> 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.

02:57.720 --> 03:08.300
And as I said, we were thinking about Samsung Galaxy S23, but I have a history with Samsung at this point.

03:08.300 --> 03:17.840
A lot of traumatic experiences with Samsung, including a failed Pwn2Own attempt in 2021, because I am a very shitty programmer.

03:18.220 --> 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.

03:26.100 --> 03:28.100
Something new, something fresh.

03:28.120 --> 03:32.000
We we just thought, you know, something that we both can learn together.

03:32.000 --> 03:34.380
What could possibly fucking go wrong, right?

03:34.380 --> 03:35.780
This is gonna be awesome.

03:36.480 --> 03:40.000
So let's talk about the Xiaomi 13 Pro.

03:40.320 --> 03:43.560
There's essentially two versions of this device.

03:43.560 --> 03:46.440
The global variant and the China variant.

03:46.460 --> 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.

03:55.860 --> 03:58.700
At a hardware level, they're exactly the same thing.

03:58.700 --> 04:02.420
Same camera, same processor, same board, same chip set.

04:02.420 --> 04:10.740
The only minor difference between these two models is the type of firmware that can be installed on each device.

04:10.740 --> 04:19.040
Uh, the China model can have the China firmware as well as what's called the global variant firmware.

04:19.040 --> 04:23.880
Whereas the global model can only install the global variant firmware.

04:24.140 --> 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.

04:34.680 --> 04:43.620
Like for example, in Europe, in India and in Taiwan, they have their own Taiwan, India and Europe firmware.

04:43.620 --> 04:51.640
Or you can tell the global mother one to emulate a different region and it will become that region.

04:51.760 --> 04:57.580
Why this is important is because certain regions have certain apps enabled or disabled.

04:57.640 --> 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.

05:10.820 --> 05:16.380
Whereas if you were to set it to United States region, the get apps store is disabled.

05:16.480 --> 05:17.960
And this is just one example.

05:17.960 --> 05:24.880
Another one is that if you set the region to Russia, then the Yandex browser becomes enabled on the device.

05:24.880 --> 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.

05:35.980 --> 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.

05:50.560 --> 05:56.240
So at this point, we have multiple different regions, multiple apps being enabled, multiple apps being disabled.

05:56.340 --> 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.

06:08.700 --> 06:12.220
Except that's a really fucking bad idea because that's a lot of applications.

06:12.220 --> 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.

06:22.860 --> 06:29.600
And so then 22 days later, we had 3 exploits for the GetApps application.

06:29.600 --> 06:32.220
And this is where Elias is going to talk about them real quick.

06:32.340 --> 06:33.540
Hey everyone.

06:33.540 --> 06:36.840
I'm going to be talking about the app we exploited.

06:37.420 --> 06:42.140
So we found 3 different exploits in the GetApps application.

06:42.480 --> 06:47.660
This application is also what the, what we ended up exploiting at point one.

06:47.740 --> 06:52.040
So we found 3 different ways to force install application.

06:52.040 --> 06:54.580
And the attack scenario is the following.

06:54.880 --> 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.

07:06.940 --> 07:10.620
Two of the methods were unfortunately patched before the competition.

07:10.680 --> 07:15.520
And I'm going to show here the exploit code of those 2 patch exploits.

07:15.520 --> 07:17.480
So here's the first one.

07:17.480 --> 07:21.300
Um, that was used to install WhatsApp automatically.

07:21.300 --> 07:25.680
On the first screenshot, you can see the browsable intent code.

07:25.680 --> 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.

07:34.320 --> 07:40.320
And there is an ID equal com.whatsapp parameter in there.

07:40.320 --> 07:46.180
And that's what could be used to install any application available in GetApps.

07:47.700 --> 07:50.980
Here's the second patch exploit.

07:50.980 --> 07:54.140
On the left, you can see the browsable intent code.

07:54.140 --> 07:59.640
And again, on the right, you can see the Java code which does the exact same thing.

07:59.640 --> 08:02.420
It's a lot chunkier as you can see.

08:02.460 --> 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.

08:12.240 --> 08:21.380
Before we can get into the third exploit, we need to talk a little bit about WebView in GetApps.

08:21.380 --> 08:26.300
Um, GetApps had a WebView which contained a JavaScript interface.

08:26.300 --> 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.

08:36.220 --> 08:39.880
It's defined in the JavaScript interface class.

08:39.920 --> 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.

08:53.860 --> 08:58.640
But there are two interesting functions there for us, for point one.

08:58.640 --> 09:06.280
The install function, which installs any application available on the GetApps store without user consent.

09:06.280 --> 09:13.880
And the open app functions, which opens any specific application, again, without user consent.

09:14.520 --> 09:19.180
And this WebView is obviously dangerous, and Xiaomi knows it.

09:19.180 --> 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.

09:30.660 --> 09:39.480
And one of those protection was that whatever URL being loaded in the WebView, must be a valid URL.

09:39.480 --> 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.

09:53.220 --> 09:55.840
All of them were owned by Xiaomi.

09:55.860 --> 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.

10:07.300 --> 10:18.040
A GetApps private directory, um, names was always web hyphen raise, I hyphen some random numbers.

10:18.940 --> 10:22.020
So now, we have a new plan.

10:22.060 --> 10:26.880
First, we can launch the WebView and load a valid URL.

10:26.880 --> 10:33.820
Second, inject, inject some custom JavaScript code into the WebView, possibly through cross-site scripting.

10:34.080 --> 10:40.540
Third, having the JavaScript code execute the two JavaScript interface functions mentioned before.

10:40.540 --> 10:44.180
And fourth, got, get remote code execution.

10:45.340 --> 10:47.060
Okay, step one.

10:47.060 --> 10:51.540
To launch the WebView, we use the activity called join activity.

10:51.700 --> 10:55.500
This activity could be launched via browsable intent.

10:55.500 --> 11:01.260
Again, this means that this activity could be launched via hyperlink in a website.

11:01.280 --> 11:07.140
And it was also really simple to tell join activity what URL we wanted to load in the WebView.

11:07.140 --> 11:09.920
It was just a get parameter called URL.

11:11.540 --> 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.

11:24.460 --> 11:28.820
That detail dot html is pretty blank, as you can see on the screenshot.

11:28.820 --> 11:34.000
Um, but that's just because we didn't give him the application's data to use.

11:35.020 --> 11:37.000
So now step one is done.

11:37.000 --> 11:38.760
Let's move on to step two.

11:39.660 --> 11:43.600
We had two options to inject custom JavaScript.

11:43.680 --> 11:51.760
We could either load a show me domain URL and then print this dot URL and look for usable vulnerabilities.

11:51.780 --> 11:58.740
Or, we can analyze the file in the private folder and look for user input vulnerabilities.

11:59.100 --> 12:02.120
We choose the second option.

12:02.640 --> 12:07.740
And now this research just became a JavaScript source code review job.

12:07.880 --> 12:15.340
And as you can see on the picture, this was my reaction when I realized what was going on.

12:15.900 --> 12:21.080
Um, point one will make you do stuff you really don't want to do, but we still did it.

12:21.980 --> 12:28.520
Um, in, in the, uh, the web hyphen res folder, um, you can see the folder .

12:28.520 --> 12:33.400
We had like HTML file and JavaScript file with similar names.

12:33.400 --> 12:42.400
As an example, we had the detail dot HTML file and this file would load the detail dot chunk dot JS.

12:42.420 --> 12:47.420
Some JavaScript file would accept user input via get parameters.

12:47.720 --> 12:56.420
But also, all of those JavaScript file had a building function to filter out any cross-scripting payloads.

12:56.420 --> 12:57.740
Well, except for this one.

12:57.760 --> 13:00.200
One that we found.

13:00.240 --> 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.

13:10.960 --> 13:15.960
So, let's try to get a dumb XSS payload working in this file.

13:16.340 --> 13:20.080
This was the initial payload that was used for testing.

13:20.080 --> 13:23.820
On the right, you can see the decoded version of it.

13:23.820 --> 13:27.580
So, we had different inputs and we had different payloads.

13:27.580 --> 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.

13:38.600 --> 13:43.600
And those characters were double quote symbol and the less than symbol.

13:45.040 --> 13:49.980
On the left is what the web view looked like with the payloads.

13:49.980 --> 13:53.740
And on the right is a debugging window in Chrome.

13:53.920 --> 14:02.040
Our less than symbol character was unfiltered in one of the area, specifically the XSS test 2.

14:02.040 --> 14:06.220
All the others were filtered, filtered the right way.

14:06.660 --> 14:15.060
So, now , with this XSS test 2 payload, we can try to just pop a simple alert box.

14:15.440 --> 14:17.620
And then, what the hell?

14:17.620 --> 14:19.220
We got some errors.

14:19.360 --> 14:25.660
Locat was showing us disabled XSS text, XSS errors, um, errors.

14:25.660 --> 14:27.800
So, let's dig into that.

14:27.940 --> 14:31.480
Remember the protection against the web view that we mentioned earlier?

14:31.480 --> 14:33.860
There was another one, unfortunately.

14:34.200 --> 14:40.180
The GitOps application had a built in XSS filter in the Java code itself.

14:40.500 --> 14:44.800
And it looked for XSS payload in the URL.

14:45.060 --> 14:51.620
So, if the URL had any XSS payload found, then the URL would fail to load.

14:52.320 --> 14:57.120
And here is the list of the XSS filter.

14:57.120 --> 15:03.400
And as you can see, it detected our forward slash script string in our payload.

15:03.660 --> 15:09.040
At this point, we decided that maybe we shouldn't be using script string at all.

15:09.640 --> 15:13.360
Maybe because there might be other filters we haven't found yet.

15:13.360 --> 15:17.820
And also, script is just too obvious for an XSS payload.

15:18.740 --> 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.

15:29.960 --> 15:38.380
So, we thought, what if we could encode, um, a less than symbol, um, a character in one of those payloads.

15:38.380 --> 15:41.900
Such as, the less than symbol SVG.

15:42.540 --> 15:44.360
So, that's what we tried.

15:44.360 --> 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.

15:54.720 --> 15:57.240
And boom, it worked.

15:57.240 --> 16:00.280
We finally have an XSS in the web view now.

16:01.400 --> 16:03.340
So, step two is done.

16:03.340 --> 16:04.960
Let's move on to step three.

16:04.960 --> 16:05.980
Oops, sorry.

16:06.800 --> 16:12.200
Now, let's try to call the, those JavaScript interface function mentioned earlier.

16:12.480 --> 16:19.220
To test, we tested our payload just to see if we could run the show toast function.

16:19.220 --> 16:23.700
And on the screen shot on the right, you can see that we managed to do that.

16:24.760 --> 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.

16:35.540 --> 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.

16:54.160 --> 16:56.920
So now, there is just one problem.

16:57.140 --> 16:59.600
We didn't know what to install.

17:00.480 --> 17:03.580
So now, what application should we install?

17:03.600 --> 17:10.580
Ideally, we want some malware that we can control in the application store, store somewhere.

17:10.600 --> 17:14.000
And I'm going to let Ken talk about his baby now.

17:15.840 --> 17:22.720
So, for those of you that don't know, I'm also an active contributor for this Android tool Drozer.

17:22.740 --> 17:23.220
Yay!

17:23.220 --> 17:25.620
For those of you that know what Drozer is, yay!

17:25.620 --> 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.

17:44.500 --> 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.

17:52.080 --> 17:53.340
That was fun.

17:53.440 --> 17:56.120
So, we had a new payload.

17:56.120 --> 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.

18:05.880 --> 18:09.820
So, alright, all the pieces, all the puzzle pieces are in place.

18:10.520 --> 18:13.560
Let's uh, let's watch it do its thing real quick.

18:13.560 --> 18:15.400
We open up Google Chrome.

18:15.540 --> 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.

18:20.300 --> 18:26.480
We browse to the web server I had at my house, uh, over HTTP because I'm lazy.

18:26.580 --> 18:32.920
But eventually what's going to happen is I will load the website and there's a yay POC hyperlink.

18:32.920 --> 18:34.780
Click that one link.

18:34.780 --> 18:40.440
This appears and then Sunfish gets installed and boom, Sunfish is now installed.

18:40.440 --> 18:42.440
The server has started as well.

18:42.440 --> 18:44.080
I put the phone down.

18:44.080 --> 18:50.120
At this point, I have the IP address of the phone that reached out to my web server as well.

18:50.160 --> 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.

19:01.260 --> 19:07.780
And then for, per the rules of Pwn2Own, as long as you get RCE on the device, that is good enough.

19:08.020 --> 19:11.680
Including just RCE as a single application.

19:11.680 --> 19:14.960
So, in this case, I'm running ID and who am I as Sunfish?

19:15.240 --> 19:16.200
There we go.

19:16.200 --> 19:17.960
One click to, one click to RCE.

19:18.060 --> 19:19.220
Yay!

19:20.960 --> 19:23.100
So, we got RCE.

19:23.120 --> 19:24.800
All the steps are done.

19:24.800 --> 19:28.380
And like I said, that was only 22 days later.

19:28.380 --> 19:30.200
We had 22 days of research time.

19:30.200 --> 19:34.960
We had 77 more days to go to to do whatever the fuck we wanted.

19:35.000 --> 19:36.420
Everything was awesome.

19:36.420 --> 19:39.060
Nothing could have possibly gone wrong.

19:39.420 --> 19:41.660
Let's discuss what went wrong.

19:42.160 --> 19:48.300
So, late August of 2023, Xiaomi released Xiaomi made changes to their get app server.

19:48.300 --> 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.

20:01.620 --> 20:04.720
Our payload was now chonky as fuck.

20:04.820 --> 20:07.280
But wait, there's more.

20:07.360 --> 20:12.840
You see, this payload did not work in all parts of the world.

20:12.900 --> 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.

20:21.960 --> 20:28.560
And this new chonky install payload would work in Japan and the United Kingdom.

20:28.560 --> 20:31.400
Thanks to Ilias here being based in the United Kingdom.

20:31.560 --> 20:35.380
But it fucking wouldn't work in the Philippines for some reason.

20:35.900 --> 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.

20:49.480 --> 20:51.520
Not the IP address.

20:51.900 --> 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.

21:01.260 --> 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.

21:14.220 --> 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.

21:26.040 --> 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.

21:37.860 --> 21:43.360
And so then during a factory reset process, the cell phone tower, the cell phone signal antenna is enabled.

21:43.360 --> 21:44.920
So we wanted to mimic that.

21:44.920 --> 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.

21:55.700 --> 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.

22:09.820 --> 22:15.820
Uh, for example, get apps was not launched in the US, UK and Japan.

22:15.820 --> 22:19.620
But it was launched in the Philippines.

22:20.600 --> 22:26.920
Now I don't have definitive proof, but this is literally the only thing I could think of at the moment.

22:26.920 --> 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.

22:39.280 --> 22:47.580
Now, thankfully, cause we are awesome, eventually we found a way for the payload to work in the Philippines.

22:47.760 --> 22:51.440
But that payload would only work in the Philippines.

22:51.440 --> 22:54.640
It would not work in US, UK or Japan.

22:55.140 --> 22:57.020
We didn't know what to do.

22:57.020 --> 23:03.220
Because another issue came up, Pwn2Own that we were going to takes place in Canada.

23:03.520 --> 23:06.260
Do we have a payload that works in Canada?

23:06.420 --> 23:11.480
We, I like, it's a theory , this whole like launch not launch thing is just a theory.

23:11.480 --> 23:15.580
And technically, get apps was not launched in Canada.

23:15.580 --> 23:20.480
So maybe, maybe our get apps or non-launch payload would work in Canada .

23:20.480 --> 23:21.680
We're not entirely sure.

23:21.680 --> 23:23.400
It'd be nice to confirm.

23:23.880 --> 23:27.060
Well, NCC group is a global company.

23:27.160 --> 23:29.160
And we have offices in Canada.

23:29.160 --> 23:33.180
So surely we can just, no, no, we're not, we're not working with the Canada office for this talk.

23:33.240 --> 23:37.880
Because you cannot get the Xiaomi 13 Pro in Canada.

23:38.160 --> 23:42.960
So, if you try to get the Xiaomi 13 Pro here in the US, you're going to go through eBay.

23:42.960 --> 23:47.200
You're going to go through a, a seller on eBay or on Amazon or something to get the phone.

23:47.300 --> 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.

23:57.580 --> 24:01.040
I could not procure the Xiaomi 13 Pro in Canada.

24:01.040 --> 24:06.220
eBay Canada, Amazon Canada, none of the cell phone providers in Canada, like I could not get it in Canada.

24:07.160 --> 24:10.700
So, you know, I'm in North America, I might as well just send my phone to Canada.

24:10.700 --> 24:13.400
No, no, I'm not sending my phone to Canada.

24:14.040 --> 24:17.080
Because another issue came up with my schedule specifically.

24:17.080 --> 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.

24:27.480 --> 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.

24:35.240 --> 24:37.200
Uh, fun fact, I'm still in the Philippines.

24:37.440 --> 24:45.440
So, because of this, I had a very, very weird travel schedule last year.

24:45.660 --> 24:49.680
Because as I said earlier, I went on a vacation, right?

24:49.780 --> 24:53.120
I come back from vacation on September 10th.

24:53.120 --> 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.

25:02.660 --> 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.

25:09.320 --> 25:11.840
And then again, 18th through 20, I'm at home.

25:11.840 --> 25:15.460
And then the 21st of September, I fly to the Philippines.

25:15.460 --> 25:20.260
That leaves only seven business days where I am in the U.S.

25:20.500 --> 25:22.180
So that's the schedule.

25:22.340 --> 25:25.920
Uh, it's a little bit hectic, but it gets more hectic, I promise.

25:25.920 --> 25:31.420
But first, we want to, I want to talk about why those seven days sucks.

25:31.480 --> 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.

25:40.920 --> 25:42.960
import taxes all in seven days.

25:43.320 --> 25:45.340
That is not going to happen.

25:46.180 --> 25:51.160
Well, what if I just send my phone to Canada and keep it there?

25:51.500 --> 25:55.880
Well, I, I, the Philippines has a lot of Xiaomi stores.

25:55.880 --> 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.

26:00.480 --> 26:03.420
And they were selling Xiaomi 13 Pros for 1,000 U.S.

26:03.420 --> 26:03.900
dollars.

26:03.900 --> 26:07.320
I can just go to the Philippines and get a new phone, right?

26:08.120 --> 26:11.900
Well, the problem is that now we're dealing with three different time zones.

26:11.900 --> 26:17.860
If I'm in the Philippines, he's in the U.K., and the Canada consultants are in Eastern Standard Time.

26:17.860 --> 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.

26:26.620 --> 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.

26:37.420 --> 26:44.160
On top of that, the biggest issue, the biggest threat to any pawn to own competition are the patches.

26:44.420 --> 26:50.060
So, at this point, we had a good idea as to how the patches worked.

26:50.120 --> 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.

27:03.860 --> 27:08.000
With that firmware update comes a new GetApps update.

27:08.000 --> 27:11.320
Every single month, there is a new update for GetApps.

27:11.760 --> 27:19.140
So, the real schedule now is that after I fly back to the Philippines, no one is in the U.S.

27:19.140 --> 27:23.660
to test the exploit, or no one's in North America to test the exploit a...

27:27.910 --> 27:29.890
Hey, you know what?

27:51.180 --> 27:54.880
If I try to shut... Alright.

27:55.120 --> 27:56.760
No one's in North America.

27:56.760 --> 27:57.620
Hey, we're back.

27:57.620 --> 27:58.400
Yay.

27:58.920 --> 27:59.740
Alright.

27:59.740 --> 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?

28:11.240 --> 28:13.880
I really, really want to test this theory though.

28:14.200 --> 28:15.300
I really, really do.

28:15.420 --> 28:17.680
Because, here's the thing.

28:17.920 --> 28:21.500
We think that Canada is a non-launched region, right?

28:21.500 --> 28:22.800
Just like with U.K.

28:22.800 --> 28:23.540
or U.K.

28:23.540 --> 28:24.660
and U.S.

28:24.760 --> 28:26.320
uh, and Japan.

28:26.400 --> 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?

28:42.580 --> 28:48.280
All we would need is Ilyas here to test his U.K., uh, his exploit in the U.K.

28:48.280 --> 28:56.240
And if it works, then in theory it should work in the U.S., in Japan and in Canada.

28:57.440 --> 29:02.760
So, earlier I mentioned that it costs 1,000 U.S.

29:02.760 --> 29:05.820
dollars to buy a new phone.

29:06.380 --> 29:08.120
Another thing that costs 1,000 U.S.

29:08.120 --> 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.

29:18.660 --> 29:20.320
And then fly back the next day.

29:20.720 --> 29:22.540
So that's what I did.

29:22.900 --> 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.

29:37.440 --> 29:39.580
So many miles.

29:40.180 --> 29:44.500
And like a, and after a few hours in Toronto, it was confirmed.

29:44.500 --> 29:45.420
We did it.

29:45.420 --> 29:49.300
We, we confirmed that this was a non-launched region.

29:49.400 --> 29:57.060
And so now, if our, if October rolls around, our exploit works in the U.K., we should be good.

29:57.060 --> 29:58.820
Everything is awesome.

29:58.820 --> 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.

30:06.340 --> 30:07.220
Right Elias?

30:07.220 --> 30:08.240
Yeah!

30:09.240 --> 30:12.640
So, October rolls around.

30:12.640 --> 30:17.220
As expected, get apps releases their, their update in October.

30:17.220 --> 30:18.880
It's literally October 9th.

30:18.880 --> 30:24.620
I have it marked down in my calendar and we confirm that the exploit works.

30:24.700 --> 30:27.240
We have our books flight for September 20th.

30:27.240 --> 30:30.480
I'm flying from the Philippines, he's flying from the U.K.

30:30.480 --> 30:31.880
We, all this is good to go.

30:31.880 --> 30:33.380
We're going to fucking do this.

30:33.380 --> 30:34.840
No, hold on.

30:36.080 --> 30:43.840
One week before phone to own, Xiaomi releases an out of band update to get apps.

30:44.100 --> 30:49.140
Which happened to fucking remove the file that we were going to exploit.

30:50.200 --> 30:54.900
Specifically, the file was removed from the APK file itself.

30:54.900 --> 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.

31:01.360 --> 31:03.120
It was no longer there.

31:04.420 --> 31:07.880
But thankfully they are, Xiaomi also has shitty programmers.

31:08.860 --> 31:14.280
Because they forgot to remove the file from the device if it was already there.

31:15.100 --> 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.

31:21.860 --> 31:30.960
And like I said earlier, uh, uh, ZDI usually factory resets the target device per, uh, competition.

31:30.960 --> 31:32.660
They usually have multiple devices.

31:32.760 --> 31:38.540
So, as long as we could hack one of the initial devices before they factory reset it again.

31:38.540 --> 31:41.800
Again, it's a dice roll, but there's still a chance.

31:41.960 --> 31:43.500
We still follow through.

31:43.500 --> 31:46.300
We still decide, okay, this is not that big a deal.

31:46.300 --> 31:47.960
Let's fucking do this.

31:47.960 --> 31:49.500
So, we fly out to Canada.

31:49.500 --> 31:51.240
It is now October 20th.

31:51.240 --> 31:53.000
Him and I are both on our flights.

31:53.900 --> 31:56.260
Literally while I'm on the plane.

31:56.300 --> 32:00.980
And the Saturday before phone to own, there is another get apps update.

32:01.260 --> 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.

32:12.520 --> 32:14.680
Which is really, really cool.

32:14.920 --> 32:18.840
And for some reason they pushed our file back to the device.

32:19.180 --> 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.

32:26.700 --> 32:28.240
That's so fucking convenient.

32:28.240 --> 32:29.560
Thank you, Xiaomi.

32:30.120 --> 32:32.640
Except they added one more thing.

32:32.860 --> 32:38.640
So, we were going to exploit the activity, join activity, as we, as Ilya said.

32:38.920 --> 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.

33:02.320 --> 33:04.380
What the fuck, Xiaomi?

33:04.440 --> 33:08.520
As you all saw in my video earlier, we use specifically Google Chrome.

33:08.520 --> 33:12.420
We can't, there's no other browsers on this phone that we can use.

33:13.960 --> 33:16.060
Except there is.

33:16.820 --> 33:23.700
Because if you set the region to Spain, the Opera browser is enabled on the phone.

33:24.600 --> 33:30.660
So technically we had an exploit for the country of Spain specifically.

33:31.180 --> 33:35.680
Which is still technically a zero day, because now it's a zero day in Spain.

33:36.420 --> 33:38.200
So we told ZDI this.

33:38.200 --> 33:43.600
We told them, hey, Xiaomi is doing some shitty stuff, but Spain.

33:43.740 --> 33:46.700
And ZDI goes, Spain.

33:46.760 --> 33:47.900
And we're good to go.

33:47.900 --> 33:48.680
And we're good to go.

33:48.680 --> 33:49.420
Alright.

33:49.420 --> 33:50.820
We dodged another bullet.

33:50.820 --> 33:52.220
We can now, we can do this.

33:52.220 --> 33:54.140
We can hack a Xiaomi 13 Pro.

33:54.140 --> 34:04.100
The first day of the competition, Xiaomi starts disabling the ability to install apps from their app store.

34:05.300 --> 34:08.800
Now, I don't know if this was a global thing.

34:08.800 --> 34:09.920
I genuinely don't know.

34:09.920 --> 34:12.600
I don't talk to many Xiaomi users after this.

34:12.600 --> 34:13.920
I don't want to.

34:14.920 --> 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.

34:24.700 --> 34:26.920
They all saw the same issue that we saw.

34:26.920 --> 34:30.080
It was a hit or miss, whether an application wouldn't install.

34:30.080 --> 34:34.680
It was like a 20% chance that we could install an application.

34:35.600 --> 34:37.660
And they killed my boy.

34:39.860 --> 34:42.900
This, this really genuinely hurts.

34:43.040 --> 34:46.000
That I could not install Sunfish at all.

34:46.000 --> 34:48.340
It was a 0% success rate.

34:49.060 --> 34:55.880
So, on that day, there was 2 teams that were supposed to go and hack the Xiaomi 13 Pro.

34:55.880 --> 35:02.140
Uh, it was us at NCC group and it was, uh, the awesome people at Team Viettel.

35:02.140 --> 35:05.000
Uh, Team Viettel went first, we went second.

35:05.060 --> 35:11.580
Uh, we discussed with ZDI what happened and we're like, what the fuck do we do?

35:11.580 --> 35:15.300
Oh wait, can we please just install one random app from the app store?

35:15.300 --> 35:17.220
And they go, okay.

35:18.640 --> 35:19.860
And we did.

35:20.600 --> 35:21.640
We did it.

35:21.640 --> 35:27.560
Technically that works because we showed ZDI that we had malware up on the app store.

35:27.780 --> 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.

35:36.640 --> 35:45.520
So, Team Viettel managed to install Discord and I, we installed no pics color by number and pixel.

35:45.520 --> 35:47.000
Yeah, it was that app.

35:47.000 --> 35:50.660
I literally just found another random app on the app store and we installed it.

35:50.680 --> 35:52.580
And we did it!

35:52.860 --> 35:54.920
We got a win!

35:54.940 --> 35:56.040
Yay!

35:56.420 --> 36:04.780
Except that's not the end of the story because the next day, Xiaomi releases another update.

36:04.780 --> 36:11.400
First, they removed the file that we exploited and now nothing installs from the app store.

36:11.400 --> 36:12.100
Period.

36:12.100 --> 36:16.560
The day before, those that got 20 percent success rate on installing something, no.

36:16.560 --> 36:18.740
The next day, nothing gets installed.

36:18.740 --> 36:19.660
Period.

36:20.060 --> 36:24.540
And on top of that, they added code to block Yandex and Opera.

36:27.960 --> 36:30.140
You can't make this shit up.

36:30.480 --> 36:35.740
So, the rest of the week, it was just failure after failure after failure after failure.

36:35.740 --> 36:39.460
Unfortunately, it's pretty obvious why nothing would install.

36:39.460 --> 36:42.280
They removed a bunch of other stuff from the app.

36:42.600 --> 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.

36:51.620 --> 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.

37:02.220 --> 37:06.840
There is one more side to this story that I think everyone here should check out eventually.

37:06.860 --> 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.

37:23.440 --> 37:26.440
Not because you actually care about fixing things.

37:26.660 --> 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.

37:33.220 --> 37:35.120
I do recommend you all check it out.

37:35.120 --> 37:36.720
It's also a fun time.

37:37.140 --> 37:39.540
So, after Pwn2Own, what happened?

37:39.540 --> 37:47.700
The browser blocking code got removed for some reason and applications can install just like normal.

37:47.700 --> 37:48.540
Everything works.

37:48.540 --> 37:50.600
Everything is back to normal.

37:51.180 --> 37:55.900
Now, both us and team Vietel never got credit from Xiaomi.

37:55.900 --> 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.

38:02.640 --> 38:06.080
No, they said fuck you, we don't, we don't want to acknowledge you.

38:06.120 --> 38:10.260
So, Zero Day Initiative had to be the one to give us CVE numbers.

38:10.460 --> 38:17.140
And they said something in their posting that was possibly my favorite quote of this entire time.

38:17.140 --> 38:22.880
Xiaomi informed ZDI they would assign a CVE but never followed through.

38:24.300 --> 38:30.180
Except they did, specifically to team Vietel a few days later.

38:30.980 --> 38:32.920
But not us.

38:33.660 --> 38:36.440
Where's my fucking CVE Xiaomi?

38:37.460 --> 38:39.120
And that's it.

38:39.120 --> 38:40.300
That's the end of our story.

38:40.300 --> 38:41.220
Yay!

38:41.560 --> 38:44.820
I hope they get the worst vendor response at Pony Awards.

38:44.820 --> 38:45.840
Yay!

38:46.920 --> 38:53.100
Uh, we're also very introverted so we're gonna take questions out there instead of up here.

38:53.100 --> 38:54.620
If you guys don't mind, alright?

38:54.960 --> 38:56.280
Alright, thank you for coming!

38:56.280 --> 38:57.100
Yay!

