WEBVTT

00:00.000 --> 00:03.060
So, thanks everyone.

00:03.380 --> 00:04.440
I'm John.

00:04.440 --> 00:10.540
So today we are starting to share about how we steal the PRT cookie on macOS.

00:10.920 --> 00:13.960
And use the PRT cookie persistent in Android.

00:14.140 --> 00:25.940
That's a very funny fact is we realize Microsoft implementation on macOS for PRT cookie is more security implementation than on Windows.

00:26.340 --> 00:30.560
So I will starting first and I will hand over to the next speaker.

00:31.340 --> 00:32.320
I'm John.

00:32.320 --> 00:34.860
I'm the director of research at Sidecraft.

00:35.020 --> 00:37.700
And I have a blogger called HackerPenisJohn.

00:37.720 --> 00:41.240
And I'm a researcher so of course I speak at several conferences.

00:41.240 --> 00:43.020
But it's my first time in DEF CON.

00:43.620 --> 00:45.940
So let's jump in on today's topic.

00:47.640 --> 00:50.760
Because macOS has a lot of different type of service.

00:50.760 --> 00:52.600
Maybe 100, 200.

00:53.460 --> 01:05.080
And if you don't want our computer asking the password again and again, we need to ask our computer single sign-on to help us single sign-on to this service.

01:05.080 --> 01:11.300
You can log in all of them using the Android ID account or we call, consumer site we call Microsoft account.

01:11.920 --> 01:14.680
So you can use this account to do a single sign-on.

01:14.680 --> 01:15.980
But how it work?

01:17.240 --> 01:22.860
This is how it work when Windows generate SSL token for your browser.

01:23.580 --> 01:29.260
I will explain about Windows part and later on Cosmo will introduce about the macOS part.

01:30.480 --> 01:35.860
There's a two component, LSAS, which is handle the authentication process.

01:35.860 --> 01:39.680
And there's inside LSAS, there's a plugin called CloudAT.

01:39.700 --> 01:44.860
CloudAT will interact with the TPN, which is trust platform module.

01:45.520 --> 01:51.640
The TPN is designed for make sure the private key and secret key never leave on this device.

01:52.460 --> 01:56.420
And then there's a two element stored in the TPNs.

01:56.740 --> 02:00.680
PRT, primary refresh token, represent the user identity.

02:00.940 --> 02:03.800
And the session key is a device identity.

02:05.800 --> 02:10.780
So if you have a PRT, we can exchange everything we want.

02:10.780 --> 02:15.720
But by the design, the PRT will not directly single out the TPN.

02:15.720 --> 02:19.700
We need to calculate the PRT to the PRT cookie.

02:19.800 --> 02:22.760
The PRT cookie only has a 50 minutes lifetime.

02:23.620 --> 02:29.420
And we can use the PRT cookie to token exchange to the refresh token and access token.

02:29.420 --> 02:31.860
The max lifetime is 24 hours.

02:32.160 --> 02:36.320
And then we can use the access token to log in the cloud service.

02:40.180 --> 02:44.800
And here is how it go in detail process in the Windows system.

02:45.040 --> 02:55.120
There's a browser like Edge, Chrome, Firefox, they can have a pass announce to the browser code which is building binary inside of Windows.

02:55.960 --> 03:03.680
And the browser code will interact with Microsoft account token provider DLL and send a request to LSATS process.

03:03.680 --> 03:08.120
LSATS process will calculate the PRT cookie sent to the browser.

03:08.540 --> 03:19.020
And in this process, there's at least three way to abuse the process and get a PRT cookie.

03:19.020 --> 03:26.080
First, the raw tools and the second is request a refresh token and the token broker.

03:26.080 --> 03:35.220
They are leveraging a different stage and abuse until today they can still can get a PRT cookie from the Windows system.

03:37.900 --> 03:42.080
The PRT cookie will contain some information very important for us.

03:42.080 --> 03:45.320
Like a user identity and the link device information.

03:46.280 --> 03:54.460
Which means if you have a PRT cookie from a device, usually we can get the MFA claim and the device claim.

03:54.460 --> 04:01.640
Which means I'm from, I'm coming from, I'm user A, I'm coming from a trust device and I comply with some requirement.

04:01.700 --> 04:05.900
This can help us pass some condition as a policy check.

04:05.900 --> 04:09.100
So it's why stealing a PRT cookie is so valuable.

04:10.900 --> 04:13.160
Here is our today's objective.

04:13.500 --> 04:20.880
We will steal the PRT cookie from macOS because Windows have already researched it but macOS are not.

04:21.540 --> 04:26.380
But a PRT cookie only has a short term lifetime so we want a long term persistence.

04:26.980 --> 04:33.160
And comply some security requirement for the condition as a policy and as a critical resource.

04:33.160 --> 04:37.120
And now I will hand it over to Kazuma to introduce macOS part.

04:41.510 --> 04:44.350
Thanks John for the great overview.

04:44.730 --> 04:48.550
And welcome everyone to the wonderful world of Apple.

04:48.730 --> 04:54.430
Today in my session I'm going to talk about how do we steal the macOS PRT cookie.

04:55.450 --> 04:58.350
Before we dive in let me introduce myself first.

04:58.350 --> 05:02.210
My name is Kazuma, but feel free to just call me Kazuma.

05:02.450 --> 05:06.850
And I'm a university student from Taiwan and also I'm a CD player.

05:07.350 --> 05:15.770
For the past few years I've been leading a pretty active team called Beef Soup and we've managed to bring home quite a few trophies along the way.

05:16.430 --> 05:21.410
Recently I'm just transitioning from the intern to researcher at Cycler Technology.

05:21.950 --> 05:28.970
So I'm still learning a lot every day and I really appreciate the chance to be here and share research with all of you.

05:29.690 --> 05:31.950
So let's dive in with one question.

05:32.690 --> 05:36.190
Why do we research steal the macOS PRT cookies?

05:36.970 --> 05:44.050
Today many organizations rely on Intune as their end-to-end solution for both Windows and macOS.

05:44.370 --> 05:52.530
And with conditional access now extending to the macOS part, zero trust policy is no longer just a Windows story.

05:53.170 --> 05:54.550
But here's the thing.

05:54.550 --> 05:58.110
Most research and detection still focus on the Windows.

05:58.230 --> 06:02.150
And macOS on the other hand remains largely unsolved.

06:02.390 --> 06:09.630
And of course Dirk Jong and Olaf's research on macOS was a huge inspiration for us and gave us a solid starting point.

06:09.670 --> 06:17.590
From there we decided to dive deeper into how macOS handles the PRT cookies and more importantly where the weaknesses are.

06:19.390 --> 06:27.810
So if we want to steal the macOS PRT cookie, we must enroll our macOS device into Entral ID first.

06:28.130 --> 06:36.510
And according to the Microsoft documentation we can see that it needs us to download and use this company portal app.

06:37.710 --> 06:40.390
And the company portal app has two main parts.

06:40.570 --> 06:44.950
On the left you can see it's interrelated part for device management.

06:45.190 --> 06:48.610
But what we really care about here is on the right.

06:48.610 --> 06:52.990
This is where even like the macOS apps and even Safari go through.

06:52.990 --> 06:55.050
It's SSL extension for it.

06:55.470 --> 06:58.310
You need to do the single sign thing to the Entral ID.

06:59.110 --> 07:05.590
And it used to be called platform SSL but as we all know Microsoft loves to rename things so it's not a good name.

07:09.240 --> 07:15.100
And now let me put out some components that are related to the SSL part in the company portal.

07:15.760 --> 07:24.100
There are two main plugins and one is the SSL extension what we mentioned earlier and it used to be called platform SSL extension.

07:24.820 --> 07:29.400
And the other one start with the autofill which we are not going to cover today.

07:29.400 --> 07:36.740
Also we can see there is a framework under the SSL extension called the authentication broker macOS.

07:37.160 --> 07:43.720
And this is the library most of performing more for the color validation checks.

07:44.320 --> 07:49.920
And a framework on the macOS is kind of like DL on the Windows.

07:49.920 --> 07:55.820
Both provide libraries but a framework on the macOS contains more bundle resources.

07:56.360 --> 07:59.000
But it's pretty much the same concept though.

08:00.040 --> 08:04.740
Also at the same time we can see there is browser core under the resources folder.

08:04.740 --> 08:08.860
Which also appear earlier in the Windows SSL floor.

08:10.500 --> 08:19.680
And earlier in John's session we can see that the browser core is playing the key role handling SSL requests from- initiated by the Google Chrome.

08:20.360 --> 08:25.900
So as we saw that company portal also has this app is cross core.

08:25.900 --> 08:32.740
We immediately suspect it might serve a similar purpose for handling SSL requests on the macOS as well.

08:34.460 --> 08:42.760
So to help visualize the comparison I put together the macOS diagram from the Windows one.

08:42.880 --> 08:47.980
We can see that Apple provide app SSL agent to do the SSL part.

08:48.020 --> 08:50.360
Handle requests from different vendors.

08:50.660 --> 08:53.120
But this diagram is a little simplifier.

08:53.120 --> 08:58.640
Actually it has authentication framework to offer API and do the front end part.

08:58.680 --> 09:01.700
And the app SSL agent is just doing the back end part.

09:01.700 --> 09:04.040
But it's easier to understand that.

09:04.860 --> 09:07.180
And macOS doesn't have LSS.

09:07.180 --> 09:14.460
So the component responsible for computing the final PID cookie is the SSL extension under the company portal.

09:15.640 --> 09:24.920
And any request passed into the company portal will go through its ID authentication framework to do the color validation checks.

09:26.900 --> 09:34.800
And after we have the basic understanding of the macOS ecosystem, now we have let's summarize what we have found.

09:34.960 --> 09:39.880
Totally we found three methods to fill the macOS PID cookie.

09:40.640 --> 09:44.560
Next I will get through each of them and explain how they work.

09:45.500 --> 09:49.220
The first one is head browser pass method.

09:49.660 --> 09:58.020
The first one is pretty straight forward but Microsoft provide us this extension called Microsoft SSL Chrome extension.

09:58.220 --> 10:03.660
And we can just initiate an SSL request and directly retrieve the output there.

10:03.660 --> 10:16.800
So when we compromise a macOS device, we can just initiate a headless browser and install this extension and then we can initiate an SSL request and get the PID cookie right away.

10:17.640 --> 10:27.500
And from the logs we can also confirm that a browser core is handling the SSL request, playing the key role in the SSL flow like the Windows one.

10:29.620 --> 10:37.220
But this method does come with some limitations is that we need the victim to be logging into their desktop session.

10:37.300 --> 10:41.000
Because headless browser doesn't mean there's no GUI dependencies.

10:41.240 --> 10:45.440
It's more like a transparent browser running in the background.

10:45.520 --> 10:49.680
So we need it to log in their session.

10:49.740 --> 10:57.540
And also there's also another limitation is that this technique only works with official Chrome and Microsoft Edge.

10:58.080 --> 11:00.840
And we'll know why when we get to the third method.

11:01.980 --> 11:11.600
So to wrap up the first method, we found that this first method has specific dependencies, but of course we won't satisfy with just that.

11:12.040 --> 11:14.880
Next we'll move to the second one.

11:16.380 --> 11:19.000
The bypass browser core's parent process check.

11:19.840 --> 11:34.700
So after some reverse engineering of the browser core, we found that whenever the browser core needs to check its coder, it will first call running application with process identifier, this function, and get the parent process info.

11:35.280 --> 11:46.840
And then it will concatenate like it can get the PID from the info and concatenate coside HDV to execute this command and get bundle ID and team ID.

11:47.540 --> 11:54.380
Also when it has this two value, it will concatenate it and hash it and check against internal wireless.

11:55.040 --> 12:05.420
And here's the fun part is that until very last our research, we found that this running application function only work with direct process.

12:05.420 --> 12:11.500
So later in our POC, you will see that we package the whole script into a direct process.

12:13.780 --> 12:20.720
And here you might find some terms that I'm familiar with, which is team ID and the bundle ID.

12:21.520 --> 12:23.300
And let me explain them quickly.

12:23.300 --> 12:29.460
The team ID is the identifier included in the certificate issued by Apple to each developer.

12:29.540 --> 12:35.840
So only the developer owns the certificate can sign the app with their own team ID.

12:36.180 --> 12:40.620
But bundle ID on the other hand is just a string for identification.

12:40.680 --> 12:42.840
It has no real security value.

12:42.840 --> 12:45.320
So we can change it to whatever we want.

12:45.940 --> 12:50.620
In short, attacker can affect the bundle ID but team ID doesn't.

12:51.500 --> 12:57.620
Also we can found that there are some similar mechanism on the Windows 4.

12:57.620 --> 13:01.720
It's called security identifier or somebody call it SID.

13:02.260 --> 13:11.140
In this flow we can see that security identifier is more like a bundle ID is just for identification.

13:11.160 --> 13:14.680
So we can also change it to whatever we want.

13:15.140 --> 13:22.640
And this is interesting because that Microsoft never implement something like the team ID on their operating system.

13:22.640 --> 13:27.080
So they check this security identifier is a bit pointless.

13:28.940 --> 13:36.600
And also we found that this SSL flow involves a lot of components and that means a lot of coders.

13:36.600 --> 13:40.000
And more coders means more coder validation checks.

13:40.000 --> 13:44.940
So let me clear things up and focus on the most two important one.

13:44.940 --> 13:47.780
The first one is the coder of the browser core.

13:48.000 --> 13:51.260
And of course as the name suggests is the browser.

13:51.260 --> 13:55.780
And in this case it can be the Google Chrome or Microsoft Edge.

13:56.420 --> 14:01.040
And also it is the parent in the parent process check in our earlier talk.

14:02.280 --> 14:08.420
And this is what we have mentioned about here in the diagram.

14:08.420 --> 14:12.320
This is the part like the Google Chrome call into the browser core.

14:14.020 --> 14:16.840
So let me read off the attack strategy.

14:16.840 --> 14:24.640
First we create a parallel binary and second we have a fake call site and put it in the slash TMP directly.

14:24.640 --> 14:30.180
And we have it use the binary ID for Google Chrome and the team ID.

14:30.520 --> 14:41.020
Also we package the whole process into a process and that the browser core can retrieve the parent process info since the running application function.

14:41.700 --> 14:50.000
And here's the real problem is that browser core runs this call site HDB function just without the absolute pass.

14:50.000 --> 14:58.260
So we can use pass in the session to change the environment variable to slash TMP to let it run the fake one instead of the real one.

15:00.200 --> 15:02.680
And here's the screen shot of our POC.

15:02.840 --> 15:09.000
And this execution is clients and so running it, showing the video will be kind of funny.

15:09.080 --> 15:12.560
But we will release this tool at the end of our talk.

15:14.360 --> 15:18.540
And here's let me share some little funny story here.

15:19.480 --> 15:27.720
At first, when we try to do the second method, we first do the pass to browser core.

15:27.720 --> 15:32.180
And when we run it from the terminal, we found it running an error.

15:32.480 --> 15:34.400
Caller is not allowed to invoke.

15:34.400 --> 15:36.680
With an error call, it's minus 6,000.

15:37.200 --> 15:41.620
So we decided to use the LDB to dynamic debug it.

15:42.160 --> 15:46.120
And to our surprise, we just get the PID cookie right here.

15:46.120 --> 15:50.000
So that led us to dig into what happened behind the scenes.

15:50.960 --> 15:57.500
And from the logs, we can see that in the fail run, it can't retrieve the bundle ID and team ID.

15:58.140 --> 16:03.320
And the component responsible for this function is app SSL agent.

16:03.420 --> 16:19.640
So later, we started to analyze it and we found that the key point is that whenever app SSL agent need to retrieve the process, team ID and the bundle ID, it will check if it has CS value flake or the CS debug flake.

16:19.920 --> 16:28.640
So this explain everything because earlier when we patched the browser core, the CS value flake became false.

16:28.640 --> 16:33.160
And when we attach it with the LDB, the CS debug flake was true.

16:36.600 --> 16:42.940
Somebody will think that maybe LDB can be one of our method to get the PID cookie.

16:42.940 --> 16:45.680
But actually, we think about that too.

16:45.680 --> 16:56.280
But it need us to disable the system integrated protection and also we need to use touch ID or the password to pass the developer tools SS prompt.

16:56.820 --> 17:02.420
So if we want to use it with LDB, we must need some extra privilege escalation.

17:02.580 --> 17:07.340
So we want to try find some method just in the browser core to get the user privilege.

17:09.020 --> 17:10.880
And here come the second caller.

17:10.880 --> 17:13.660
It's called caller of the app SSL agent.

17:13.680 --> 17:15.640
And in this case, it's browser core.

17:15.640 --> 17:19.380
Also, it can be other vendors helper tool.

17:20.040 --> 17:31.400
And whenever you are the caller to call app SSL agent, you need this CS value flake or the CS debug flake to that app SSL agent to retrieve your team ID or bundle ID.

17:32.250 --> 17:34.700
And this is why we are talking right now.

17:34.700 --> 17:39.640
Is the browser core calling to the app SSL agent part here.

17:40.800 --> 17:48.800
So to wrap up the second method, this method can run without any dependency and also it can run in the user privilege.

17:50.420 --> 18:02.020
So that little LDB twist story make us dig into the ID authentication framework and we found that this browser core method is just the tip of the iceberg.

18:03.740 --> 18:08.220
Actually, we found that there are four paths for the SSL.

18:08.380 --> 18:10.800
And that lead us to the third method.

18:12.400 --> 18:15.540
Direct SSL invocation via the Apple's API.

18:16.720 --> 18:21.100
And this SSL method, the first one is browser native message.

18:21.100 --> 18:23.740
This is the same route of the browser core.

18:23.940 --> 18:27.120
And the second one is passkey credential operation.

18:27.320 --> 18:32.420
And this two method checks bundle ID and the team ID.

18:32.420 --> 18:34.760
So there's no problem with that.

18:34.900 --> 18:39.320
But the problem is there are two paths not check the team ID at all.

18:39.320 --> 18:42.000
Is the general SSL extension request.

18:42.000 --> 18:49.120
This is mainly used by the Microsoft apps like the PowerPoint, Outlook, Teams, Excel, something like that.

18:49.220 --> 18:56.220
And there are also cookie SSL acquisition is for the third party apps like the Firefox or the Opera.

18:57.540 --> 19:04.320
And like the cookie SSL one, it also, this bundle ID is content for three subsets.

19:04.380 --> 19:10.740
It's like edge bundle IDs, third party browser bundle IDs, non-native browser bundle IDs.

19:10.740 --> 19:13.600
Totally there are 39 bundle IDs.

19:13.720 --> 19:19.920
And if it only checks the bundle IDs, what we need to do here is only pick anything we like.

19:20.760 --> 19:24.040
And just like that, we can also get a PID cookie right here.

19:24.340 --> 19:29.380
And this tool will also like the second one releasing at the end of our talk.

19:30.660 --> 19:38.900
So to wrap up the third method, we can also see that it can run without any dependencies and also run in the user privilege.

19:40.920 --> 19:47.820
So here in my session, I'm successfully make the PID cookie thief into a reality.

19:47.960 --> 19:49.740
But here's some problem.

19:51.700 --> 19:55.820
PID cookies only survives for about 15 minute-ish.

19:55.980 --> 19:59.900
And how can we achieve persistence and keep the attack going?

20:03.140 --> 20:05.840
So, how can we achieve persistence?

20:06.380 --> 20:10.940
Before we started, allow me to first introduce myself.

20:10.940 --> 20:12.240
My name is Echo.

20:12.240 --> 20:14.860
I'm also a cloud security researcher at Sidecraft.

20:14.860 --> 20:22.000
I have presented in multiple security conferences, such as RootCon and FIRST, and most of my research focus on cloud security.

20:22.760 --> 20:26.140
So back to our subject, why do we need persistence?

20:26.320 --> 20:30.820
As Kazuma said, PRT cookie is only valid for a few minutes.

20:30.820 --> 20:45.000
However, the core reason of this question is that we don't have the TPM, the PRT, and the session key is stored in the hardware, which as an adversary, we cannot access it, even we have the administrative privilege.

20:45.000 --> 20:47.100
So how do we achieve persistence?

20:47.100 --> 20:50.560
A general solution is to abuse the device during scenarios.

20:51.100 --> 21:01.740
A attacker, by registering a new device, they can have their own PRT and session key, so they can generate their own PRT cookie continuously whenever they need it.

21:01.740 --> 21:10.400
However, by registering a new device, we cannot only achieve persistence, we could also bypass some conditional access policies.

21:10.540 --> 21:25.900
However, registering a device has a requirement that it requires an access token without device ID, which means we cannot use the stolen PRT cookie from a device to register another device.

21:26.600 --> 21:30.920
And as I just said, we also want to bypass conditional access policy.

21:30.920 --> 21:35.520
And the most common conditional access policy is to require multi-factor authentication.

21:36.340 --> 21:42.660
However, token issued through passwordless authentication also contain the MFA claim.

21:42.840 --> 21:55.200
And sometimes conditional access has a stricter policy, such as it requires passwordless authentication or phishing-resistant authentication, such as Windows Holo for Business or FIDO.

21:55.200 --> 22:06.860
So we also want to register our own Windows Holo for Business key or platform credential on macOS, which is basically the same thing for MSHOP, but just a different name on different OS systems.

22:07.420 --> 22:20.420
And however, registering a new Windows Holo for Business key requires an access token that contains something called an NGC MFA claim, which stands for Next Generation Credential Multi-Factor Authentication.

22:20.420 --> 22:26.200
And to have an access token with NGC MFA claim, you have to pass the MFA authentication again.

22:26.440 --> 22:32.540
And then within the last 10 minutes, the token will be validated and you will be able to register a new Windows Holo for Business key.

22:32.540 --> 22:51.740
Well, long story short, you can consider an NGC MFA claim as something as a fresh MFA status, which prevent adversary from stealing access token containing a cache MFA status to register a new Windows Holo for Business key.

22:52.980 --> 22:58.700
And another common conditional access policy is required device to be marked as compliant.

22:58.780 --> 23:03.860
And this could be achieved by PyTune that is released last year in Black Hat Europe.

23:04.520 --> 23:07.920
And however, PyTune does not support macOS for now.

23:09.140 --> 23:12.360
Okay, so here is our persistent flows.

23:12.360 --> 23:23.380
First, we get a token without device ID, then we find a way to re-authenticate via multi-factor authentication, register a new device and make the device compliant, then register a new Windows Holo for Business key.

23:23.700 --> 23:28.740
And the step three and step five can be done by Duracron's rule tool.

23:28.800 --> 23:31.740
And the step for device compliance can be done by a U.S.

23:31.740 --> 23:33.580
Trudeau's project, PyTune.

23:33.780 --> 23:47.740
So the true difficulty of our persistent flow lies on the initial step, which we cannot use a stolen PRT cookie with a cache MFA status to get a token without device ID and a token with NGC MFA claim.

23:47.920 --> 23:55.700
And this problem does not exist in the past, since Microsoft fixed them all.

23:55.780 --> 24:04.300
And we can no longer use the single-sign-on token for device registration, and the MFA claim would not transfer to the PRT after registration.

24:04.660 --> 24:15.220
And there are some other topics we are not mentioning here, but if you are interested in this topic, feel free to... I highly recommend you to read Duracron's blog post.

24:16.120 --> 24:20.300
So how do we get a token without device ID?

24:20.460 --> 24:29.900
Well, it is easy for a legitimate user to do it, since they just need to enter their ClearTask password on a non-single-sign-on device.

24:30.740 --> 24:40.100
However, it is difficult, a challenge for our adversary, since even if we compromise the victim's device, we don't know their ClearTask password.

24:41.220 --> 24:46.700
And so, a common technique to get a token without device ID is through phishing.

24:47.120 --> 24:51.480
And the upside of phishing is that it does not require compromising a device.

24:51.860 --> 24:55.120
It just needs to convince the user to enter their credential.

24:55.600 --> 24:59.100
And the downside of it is that phishing is unreliable.

24:59.100 --> 25:09.140
So since in our scenario, we would already compromise a device, we suggest another approach, which is abusing Kerbal's Simply Single Sign-On.

25:09.140 --> 25:12.580
The upside of it is that it keeps the noise level low.

25:12.580 --> 25:16.520
You don't need to unmodify with the authentication methods.

25:16.520 --> 25:20.400
You just need a service ticket in exchange for an SS token.

25:20.460 --> 25:26.020
And the downside of it is that only less than 25% of tenants have this setting enabled.

25:26.020 --> 25:30.640
And it can only abuse on a Windows system that is hybrid joined .

25:30.640 --> 25:35.060
So we start thinking that, could we just simply reset the victim's password?

25:35.100 --> 25:36.940
And the downside of it is obvious.

25:36.940 --> 25:41.740
It could use across all operating systems, regardless of its joint type.

25:41.740 --> 25:45.880
And the downside of it is that resetting the password may trigger some alerts.

25:46.020 --> 25:52.860
But the biggest problem here is that, could we reset the password without knowing the current one?

25:53.020 --> 26:04.820
Well, if we look into the MySign service of Microsoft and try to log in with an SS token containing password and MFA claim, then we can reset the password directly without knowing the original one.

26:04.820 --> 26:09.160
And in this case, we will call the API, API password reset.

26:09.160 --> 26:15.100
However, if we log in with passwordless authentication, it only contains MFA claim.

26:15.100 --> 26:21.460
So we have to enter the current password since we don't have the password claim in our SS token.

26:21.460 --> 26:25.600
And in this case, it will call the API password change.

26:25.600 --> 26:29.600
So of course, as adversary, we tend to abuse API password reset.

26:29.600 --> 26:37.280
But it seems this abuse is limited to password authentication user, not passwordless authentication user.

26:37.280 --> 26:39.320
But this is not true.

26:40.120 --> 26:47.200
And we found out there is inconsistent logic between the front-end and back-end logic of the MySign service.

26:47.340 --> 26:51.600
Actually, calling API password reset only requires the MFA claim.

26:51.600 --> 26:53.680
The password claim is not required.

26:53.680 --> 27:00.320
So we could also reset a password on passwordless authentication user without knowing their current password.

27:01.020 --> 27:11.820
And something you need to notice is that we can always reset a password without considering the SSPR, self-service password reset is enabled or not.

27:11.820 --> 27:14.660
So we can always reset user's password.

27:15.760 --> 27:22.980
And our last approach is adding a passkey in Microsoft Authenticator or your mobile device.

27:22.980 --> 27:26.080
And the upside of it, it keeps the noise level low.

27:26.080 --> 27:30.420
You add a new authentication method without modifying the old one.

27:30.480 --> 27:37.540
And since passkey is a passwordless authentication via FIDO, you also get a token with MFA claim.

27:37.540 --> 27:49.360
The only downside of it is that it requires user interaction with your browser and your mobile device, since you need to store your passkey in your mobile device.

27:50.780 --> 28:00.780
And however you may consider that adding a passkey is some sort of MFA bypass, well, it's not entirely correct.

28:00.780 --> 28:06.100
But it's not easy to get an SS token with an MFA claim.

28:06.100 --> 28:08.300
Is there something that I didn't mention?

28:08.300 --> 28:09.860
Other requirements?

28:09.980 --> 28:15.120
Let's talk about how do we find a way to re-authenticate via multi-factor authentication.

28:15.840 --> 28:23.860
So, as we said, general solution, if we try to reset the password, we have to know the current password.

28:23.860 --> 28:28.860
But we know in the last NASDAQ, Microsoft kind of like threw up.

28:28.860 --> 28:38.320
But they did a better protection for Windows Hello for Business, as they require a fresh MFA to add a new Windows Hello for Business key.

28:39.500 --> 28:54.880
However, if we just try to register a new MFA method or a single multi-factor authentication, such as a passkey or TLTP key, we don't need a fresh MFA token, which means we could use the stolen PRT to add a new one.

28:54.880 --> 29:05.500
And that makes the NGC MFA protection useless, since a hacker can register their own MFA to bypass the NGC MFA protection.

29:05.940 --> 29:10.340
So, the NGC MFA protection is a good idea.

29:10.340 --> 29:16.320
However, its actual implement is flawed, just like this French fries in the door.

29:17.760 --> 29:25.360
So, interesting thing is we report to Microsoft with a title, MFA bypass.

29:25.360 --> 29:35.460
And the response is that they determine this is not a vulnerability and claim that MFA bypass is a hyperhole.

29:35.460 --> 29:42.440
We agree with them, since we have to have a PRT cookie with a cache MFA status.

29:42.440 --> 29:45.180
However, this is not an MFA bypass.

29:45.180 --> 29:51.500
Actually, this is a next generation credential MFA bypass, which makes it sound even worse.

29:52.980 --> 30:02.880
So, it seems to imply that Microsoft forbid us from using stolen device credential, which is our PRT cookie, to directly register a new device.

30:02.880 --> 30:12.020
However, if we multiply the authentication info first and then register a new device, Microsoft seems to be okay with it.

30:12.020 --> 30:16.700
So, we think it's unreasonable, but we accept the result.

30:17.100 --> 30:26.860
However, Microsoft changed their mind in like July 30, and after we provide them with our slide with this picture on it.

30:26.860 --> 30:37.980
So, they determined that they have to provide stronger authentication in the future, such as fresh MFA to better protect Microsoft's service.

30:38.780 --> 30:42.840
And John will talk about the detail first, but I will rather show you the demo.

30:45.930 --> 30:47.570
So, okay.

30:48.250 --> 30:50.330
Here is our attachment.

30:50.330 --> 30:57.070
We'll first request a PRT cookie directly to a single sign invocation by an Apple API.

30:57.310 --> 31:00.810
And then, we'll abuse a device join scenario.

31:00.810 --> 31:09.310
First, we'll reset the password, get a token with our device ID, register a fake new device, add MFA, and register a new Windows Hello for Business key.

31:09.570 --> 31:15.910
And we skip the device compliance part to shorten the demo.

31:16.030 --> 31:21.430
And if the device registration requires multi-factor authentication, you just need to switch the step.

31:21.530 --> 31:25.770
Just add MFA before we register the fake device.

31:25.970 --> 31:28.030
So, here is our demo.

31:29.670 --> 31:38.720
First, we need to check our compliance policy or conditional access policy.

31:38.720 --> 31:46.260
It requires our user to pass multi-factor authentication to access to our target resource.

31:46.260 --> 31:50.900
Then, we are looking at the victim's device, which is a Mac OS system.

31:52.920 --> 31:56.020
And we know our victim's name is called Adele.

31:56.280 --> 31:59.540
And we request for a PRT cookie.

31:59.580 --> 32:05.620
And then we pass the PRT cookie from Mac OS to our attacker's machine.

32:05.680 --> 32:08.680
And we exchange for a MySignService token.

32:09.200 --> 32:15.960
And since we don't know the victim's password, we need to reset it to have a new one.

32:16.840 --> 32:22.940
Now, we try to call the API password reset to get a new password.

32:27.720 --> 32:30.700
Now, the password is reset successfully.

32:39.310 --> 32:45.510
Then, we can register our new device with our new password.

32:45.730 --> 32:47.730
And that is successfully.

32:47.730 --> 32:53.670
So, we try to log into Office 365 with our new password and our username.

33:03.200 --> 33:06.140
And now we are blocked by the multi-factor authentication.

33:06.280 --> 33:12.360
So, we try to the PRT cookie again and add a new multi-factor authentication.

33:16.600 --> 33:20.200
And this time, we'll not done by direct API call.

33:20.200 --> 33:25.180
We will open up the browser so that it's more easy to understand.

33:26.960 --> 33:27.700
Okay.

33:27.700 --> 33:34.200
We log into the MySignService website and try to add a new MFA.

33:35.340 --> 33:36.620
Okay.

33:39.040 --> 33:44.980
And in this process, we'll try to add our TOTP key into the key pass.

33:46.580 --> 33:49.600
And Microsoft will ask us to verify it again.

33:58.520 --> 33:59.180
Okay.

33:59.180 --> 34:06.000
Now, we successfully add our new MFA without prompting down another authentication.

34:06.700 --> 34:12.320
Now, we'll try to register our new Windows Hello for Business key.

34:12.940 --> 34:15.480
But we need a token with NGC MFA claim.

34:15.480 --> 34:20.020
So, we need to pass the MFA again and check our access token.

34:20.040 --> 34:23.420
It actually contains NGC MFA claim.

34:24.700 --> 34:25.300
Yeah.

34:29.220 --> 34:29.860
Okay.

34:29.860 --> 34:37.980
Now, we got our own Windows Hello for Business key and we try to log in on our new device with the Windows Hello for Business key.

34:37.980 --> 34:42.640
Now, we successfully log into the Office 365 and bypass the multi-factor authentication.

34:42.640 --> 34:45.620
And finally, we check our authentication method.

34:46.740 --> 34:52.900
And we register a new Windows Hello for Business key on our demo machine, which does not physically exist.

34:53.460 --> 34:56.980
And this is all for our demo.

34:59.340 --> 35:00.340
Okay.

35:00.560 --> 35:04.020
And if you like it, feel free to give us some applause.

35:04.020 --> 35:04.460
Thank you.

35:11.110 --> 35:12.030
Okay.

35:12.030 --> 35:13.990
Thanks for the demonstration.

35:14.010 --> 35:15.970
So, let me review what I just saw.

35:15.970 --> 35:24.310
In this demonstration, actually we got a PRT and a very strong MFA just like Microsoft say, they love the Windows Hello for Business.

35:24.350 --> 35:26.130
So, you have a strong MFA.

35:26.130 --> 35:30.870
And all this element is coming from the fake device.

35:32.290 --> 35:41.250
So, we are not just accessing the cloud resource, but also if we will have a PRT, we can let them run between the NHID joint device.

35:41.250 --> 35:49.390
This is a talk in this year in Troopers has mentioned about how to let them run movement in NHID joint device .

35:49.390 --> 35:58.750
By default setting, global administrator and device owner are local admin in NHID joint device.

35:58.750 --> 36:06.670
So, you can use the PRT, exchange it to the P2P certificate and the login in NHID joint device.

36:09.780 --> 36:14.760
You just saw a demo and you might think if you are familiar with the condition as a policy .

36:14.800 --> 36:22.380
You might think, hey, why require the MFA for joint device and I require MFA for update their security information.

36:22.720 --> 36:28.440
Actually it's not enough and you might encounter some deadlock problem in this scenario.

36:28.440 --> 36:36.080
I just share with my friend this tech master and he just apply this condition as policy and he encounter some problem.

36:37.220 --> 36:43.400
If you have new employee on boarding, you just give them your password and the account name.

36:43.400 --> 36:44.700
They just log in.

36:44.700 --> 36:46.440
The first time log in, they don't have MFA.

36:46.440 --> 36:51.960
NHID asking, hey, you need the MFA, but you have to pass MFA first.

36:52.140 --> 36:53.660
So, they encounter some problem.

36:53.660 --> 36:56.320
The new employee cannot add their own MFA.

36:56.440 --> 37:01.420
So, only way to escape out is on the documentation for the Microsoft.

37:01.420 --> 37:04.800
You need to log in with the tab for the initial login.

37:04.800 --> 37:08.080
This is the only way to escape out in this deadlock situation.

37:10.340 --> 37:14.680
If you apply this condition as policy, actually it's not enough.

37:14.780 --> 37:23.060
Just in case you didn't film the video, yeah, so I prepare a diagram for the easy to understand whole attack pass.

37:23.060 --> 37:26.780
We assume we have a compromise in tune or window hollow for business device.

37:26.780 --> 37:29.660
We extract the PRT cookie with MFA.

37:30.520 --> 37:33.700
And then we have a two thing need to do.

37:33.700 --> 37:35.520
First, add a new MFA.

37:35.640 --> 37:42.420
The conditional access require us need to pass MFA first and add in the new MFA.

37:42.680 --> 37:47.440
But we already have MFA client, so we can easily satisfy this policy check.

37:47.660 --> 37:52.040
And on the reset password, we just want to add on the fake device.

37:52.080 --> 37:57.600
So, we can change the user password without we know, we don't know the current password.

37:58.260 --> 38:02.020
It's a UI inconsistency in front end and back end.

38:03.880 --> 38:09.000
We are easy to get the new MFA and control the user password.

38:09.000 --> 38:11.340
And now we can persistence in Android ID.

38:11.340 --> 38:12.880
We can reduce a new device.

38:12.880 --> 38:17.620
And then you need, we're trying to reduce device user require MFA.

38:17.620 --> 38:22.700
But we already add our own MFA, so we can easily satisfy this policy check too.

38:23.720 --> 38:27.920
And then we can upgrade our fake device to windows hollow for business.

38:27.920 --> 38:30.980
We can easily authenticate MFA in five minutes.

38:31.220 --> 38:33.600
And then persistence in Android ID.

38:35.120 --> 38:37.540
How Microsoft response us our finding?

38:37.540 --> 38:38.860
This is very interesting.

38:39.060 --> 38:43.220
Because Microsoft for the Mac OS they already fix.

38:43.220 --> 38:45.160
But for the windows side, they never fix this.

38:45.160 --> 38:47.840
It still can get the PRT cookie on windows.

38:47.840 --> 38:50.360
But now it's not on the Mac OS.

38:51.060 --> 38:58.740
And for the Android ID persistence method, the first time the response, you have to compromise someone windows.

38:58.740 --> 39:00.500
Maybe very hard, right?

39:01.140 --> 39:08.380
So, just one week ago, they know we are speaking at DEF CON, they decide to fix it.

39:08.380 --> 39:12.580
Maybe one month or one week later, they will fix it.

39:13.340 --> 39:17.300
They also have a recommendation for the make a cookie PRT safe.

39:17.300 --> 39:18.480
Just update.

39:18.640 --> 39:24.060
If you cannot update yet, you can just monitor following criteria, like a call sign.

39:24.060 --> 39:27.160
It should be always running on the user bin folder.

39:27.480 --> 39:29.500
And monitor the header browser.

39:29.660 --> 39:39.400
If there is a binary, has a bundle ID we mentioned today, but there is a binary don't have enough, just trigger the.

39:39.400 --> 39:46.280
Also, even Microsoft implement this update, but you should check your Intune's policy.

39:46.280 --> 39:50.620
Because if you want some bundle ID, you still encounter some problem.

39:50.980 --> 39:56.080
You still possibly get the PRT cookie safe on your Mac OS system.

39:59.260 --> 40:00.800
And here is a summary.

40:00.880 --> 40:04.980
We found that the PRT cookie safe on Mac OS is now a reality.

40:05.180 --> 40:12.360
And we've also noticed other vendors, not just Microsoft, other vendors have implemented the SSO extension on Mac OS.

40:12.360 --> 40:14.900
We think there might be a similar problem.

40:15.920 --> 40:22.620
You are a Mac OS developer, you should choose a team ID, not a bundle ID to verify the binary.

40:23.660 --> 40:30.460
And before Microsoft already implement the patch, just pray for your end point never being compromised.

40:30.920 --> 40:35.420
And here is some mitigation for the persistent method.

40:35.940 --> 40:39.960
You can create a weak criteria from the condition as a policy.

40:39.960 --> 40:48.960
Like the IP location, user agent, just make the attacker very hard to add a new device or add a new MFA.

40:49.020 --> 40:53.600
And then monitor the new joint device and then add a new MFA.

40:53.600 --> 40:59.240
If you have an employee add a new device, you can trigger alert, but it's kind of annoying.

40:59.420 --> 40:59.860
Yeah.

41:00.760 --> 41:01.720
And thanks.

41:01.720 --> 41:03.200
And here is our cool release.

41:03.200 --> 41:06.020
You can check on this for Mac OS cookie safe.

41:06.020 --> 41:07.020
And thank you.

