WEBVTT

00:01.910 --> 00:04.410
Hey, good evening to everyone.

00:04.970 --> 00:06.050
Okay.

00:10.490 --> 00:11.730
Thank you.

00:11.730 --> 00:13.430
Thank you, thank you.

00:13.430 --> 00:17.950
Okay, so what do you expect from patches?

00:18.030 --> 00:19.570
Security updates.

00:19.830 --> 00:23.050
You expect them to be a Fort Knox security update, right?

00:23.050 --> 00:26.890
That solves fully the vulnerability, all the control flows.

00:26.970 --> 00:28.410
Is it really?

00:29.690 --> 00:32.670
In reality, this is what we usually get.

00:33.830 --> 00:34.950
Yep.

00:35.210 --> 00:39.870
So we've all been there, expecting that one patch solves it all, right?

00:39.870 --> 00:46.730
But essentially it's kind of a patch to a bullet, or there's a better phrase for that.

00:46.810 --> 00:54.030
We will be sharing insights about what happens when the patch does not quite do the trick.

00:54.450 --> 00:57.650
And sometimes you also find new vulnerabilities.

00:57.790 --> 01:02.310
So this talk will be sharing new details about vulnerabilities that we discovered.

01:02.310 --> 01:05.330
And were patched during June and July.

01:05.710 --> 01:10.070
Those are two out of a bigger number of vulnerabilities.

01:10.490 --> 01:13.770
Let's not be too harsh with the vendors.

01:13.890 --> 01:16.670
There's a reason why this happens many times.

01:16.670 --> 01:21.410
Just a couple of weeks ago, we all saw the mega crash from a CrowdStrike update.

01:21.650 --> 01:25.530
It's not exactly a security update, nevertheless the impact is obvious, right?

01:25.530 --> 01:27.070
Blue screens all over.

01:27.070 --> 01:32.530
And this is exactly the reason why many vendors are kind of trying to solve only the specific problem.

01:32.910 --> 01:43.370
While doing so, also kind of share with us the investigative researchers on additional vulnerabilities that are within the code.

01:44.450 --> 01:47.950
So just very shortly about ourselves.

01:47.950 --> 01:52.350
My name is Michael Gorelick, I'm the chief technology officer and founder of Morphisec.

01:52.650 --> 01:55.970
I have around 20 years of experience in cyber security.

01:55.970 --> 02:02.310
I was the one to discover one of the largest supply chain attacks, the SeaCleaner, in history.

02:02.550 --> 02:07.990
I have a lot of experience in reverse engineering, red teaming and blue teaming.

02:08.150 --> 02:09.830
Go ahead, Arnold.

02:10.330 --> 02:12.870
Hey guys, my name is Arnold.

02:12.870 --> 02:17.090
I'm leading the malware research efforts at Morphisec.

02:17.090 --> 02:25.070
And for some time now I'm poking with some patch analysis for fan and profit and product, of course.

02:26.150 --> 02:27.610
Thanks, Arnold.

02:29.310 --> 02:30.470
Okay.

02:30.890 --> 02:33.550
So just starting with a disclaimer.

02:33.850 --> 02:36.490
With great power comes greater responsibility.

02:36.550 --> 02:38.810
Use your powers for the good.

02:40.950 --> 02:42.910
So now about the talk itself.

02:42.910 --> 02:44.650
A bit about the motivation.

02:44.650 --> 02:56.310
Some of our work that we're doing in Morphisec, we are going and reviewing the most critical vulnerabilities that exist, especially those that lead to remote code executions.

02:56.390 --> 03:15.170
The latest vulnerabilities that we were reviewing were ones that were discovered by the NetSpy group, done an amazing work on the form injection category, basically a category of vulnerabilities that lead to remote code execution, but do require authentication,

03:15.170 --> 03:16.670
prior authentication.

03:16.770 --> 03:24.350
Additional category that Arnold will be sharing is about compound monikers, also lead to remote code execution.

03:24.630 --> 03:30.770
Checkpoint done a great research and a great work discovering some vulnerabilities during the year.

03:30.770 --> 03:38.350
We will also show how the patch doesn't really do the trick, and how we discovered additional vulnerabilities by purely looking at the patch.

03:40.190 --> 03:43.610
Okay, so let's start talking about the forms.

03:44.250 --> 03:59.210
I mean, every of those categories can go a full lecture, so we'll be kind of covering very quickly on the introduction, but you are welcome to see additional details and documentation again on the internet.

03:59.570 --> 04:07.950
So forms, exactly as you would see, you get a message, you're sending a message, it's eventually based on forms.

04:07.950 --> 04:12.530
Now, message, email message is not the only thing that is based on forms.

04:12.530 --> 04:21.190
Essentially, there is quite a significant mechanism that works behind, and imagine you are sending a recall message on the message that you sent to your boss.

04:21.190 --> 04:22.550
What happens behind?

04:22.550 --> 04:24.830
What happens when recall being sent?

04:24.930 --> 04:32.090
So essentially, it's something there activates and starts to delete the email from the inboxes of your manager.

04:32.490 --> 04:44.610
It's a rendering mechanism that is based on, again, the synchronization of forms, and we'll be covering that, and we'll share, basically, how we utilize that to inject malicious forms.

04:44.790 --> 04:52.770
We'll get back to recall in the coming slides, but let's first talk a bit about forms and custom forms.

04:53.270 --> 04:57.610
So forms, overall, can be of two different types.

04:57.610 --> 05:08.650
Now, if you integrate the developer mode in Outlook, you can see that you can modify existing forms into your own kind of purpose.

05:08.710 --> 05:25.330
So if you get a nice message, maybe you want to add some button there or some sound, you can definitely do that and even change the structure of the forms by basically opening the built-in Microsoft Form and starting moving stuff.

05:25.390 --> 05:32.790
Now, we will not be talking about that because we are looking into injecting full form, but this is one of the ways to create the form.

05:33.070 --> 05:37.070
We'll talk about the creation of the form in the next slide.

05:37.170 --> 05:43.630
What is outside of the scope of this presentation is talking about visual basic execution within the form.

05:43.630 --> 05:47.010
It was well covered by Etienne Stevens.

05:47.010 --> 05:50.950
He done a lot of research in 2017, a lot of presentations.

05:50.950 --> 05:53.870
You are welcome to check them out.

05:53.870 --> 06:01.390
Microsoft introduced a lot of hardening to avoid the default execution of visual basic inside forms.

06:01.390 --> 06:03.770
So this is outside of the scope.

06:05.070 --> 06:10.090
Okay, so I already mentioned that we have one way to create a custom form.

06:10.090 --> 06:13.590
This one way is by modifying existing built-in forms.

06:13.590 --> 06:21.010
But what is interesting for us in this category of form injection is the way you can programmatically create new forms.

06:21.010 --> 06:26.410
If you look at the documentation of Microsoft, this is actually a snapshot from Microsoft documentation.

06:26.670 --> 06:32.870
There is a way to create your own form by basically generating a configuration file called CFG.

06:33.070 --> 06:42.050
Within this configuration file, you basically define the different properties of the same form that you see, like a message or appointment or calendar, it's all forms.

06:42.610 --> 06:45.930
And you can also specify a form server.

06:45.930 --> 06:49.470
In this case, you see the example is helpdesk.exe.

06:49.470 --> 06:52.090
That is responsible to render the form.

06:52.090 --> 06:56.970
So upon receiving that message in your Outlook, you want to do something about that.

06:56.970 --> 07:01.870
This is the executable that eventually spawned and does something about that.

07:01.870 --> 07:04.290
And we will share a couple of examples.

07:04.410 --> 07:06.130
Now, it doesn't have to be executable.

07:06.130 --> 07:10.250
You can use a different DLL or any other ways.

07:10.250 --> 07:12.230
We'll share that as well.

07:12.430 --> 07:17.470
But again, there is a very nice way to run that form.

07:17.470 --> 07:25.490
Now, we'll not get into too much details about the whole mechanism of forms because we don't have enough time.

07:25.670 --> 07:33.110
Nevertheless, it's important to understand one of the most interesting things in forms is the synchronization mechanism.

07:33.190 --> 07:46.290
So exactly like you would open a draft email and it suddenly exists in all your clients, behind them there is a mechanism that basically synchronizes all those forms across the different clients through the Exchange server.

07:46.290 --> 07:49.310
This is not the only thing that obviously synchronizes.

07:49.310 --> 07:58.550
But in this case, we will leverage that mechanism to inject and execute the forms on any of the clients that they are a victim basically using.

07:58.630 --> 08:03.330
Now, the mechanism involves form libraries that represent properties.

08:03.330 --> 08:06.750
It will also include form servers, etc.

08:07.110 --> 08:12.850
And there's also important to understand that not all forms are synchronized.

08:12.850 --> 08:19.630
If you put your form into a personal library, it will not be synchronized across the different clients.

08:19.630 --> 08:27.150
But if you, for example, install it in the inbox, it will definitely be synced by the Microsoft protocol.

08:29.070 --> 08:33.710
So shortly, how forms are loading and registered.

08:33.710 --> 08:39.870
So if you take, in this example, a simple built-in modified form, this is not a programmatically created form.

08:39.870 --> 08:42.410
Nevertheless, it's the same mechanism.

08:42.890 --> 08:52.710
So if you look at your registry hive under the class ID, you will find, again, based on whether you have Outlook 32-bit or 64-bit, you have the WOW there.

08:52.890 --> 08:59.830
But you will find a lot of those class IDs, and each class ID, many of those class IDs basically represent the different forms.

08:59.830 --> 09:09.970
Now, as soon as you find the class ID, you will find also what is the name of the form, and you will find what is the location of that form on your disk.

09:10.190 --> 09:20.130
Those forms, when they are synchronized, they are saved in a special folder, many times in the app data, local data, under the forms folder.

09:20.190 --> 09:26.650
And the built-in forms are saved within the program files office, also special folder there.

09:26.650 --> 09:37.630
Essentially, those form libraries are comb objects, and those can be rendered and instantiated like any other comb.

09:38.210 --> 09:46.450
As we said, the original kind of oily form library is a bit outside of the scope of this lecture.

09:46.450 --> 10:00.610
Nevertheless, I strongly recommend people here to try and play with it, because you can modify the streams and also lead to malicious behavior by basically modifying the properties of the oily itself.

10:00.970 --> 10:07.770
But we will be talking about programmatically created forms through the configuration files.

10:07.770 --> 10:19.750
This is a great example of a built-in recall message form that basically exists on any of the computers that are installed with Outlook, whether it's 32-bit or 64-bit.

10:19.750 --> 10:25.150
You can go to this specified directory and find those CFG files.

10:25.170 --> 10:29.670
Now, you identify that there is a special file called a React CFG.

10:29.670 --> 10:33.230
This is an example of the recall message form.

10:33.230 --> 10:43.690
You see also that the CFG itself also includes the rendering file, the recall.dll, basically instantiated automatically through the InProc server 32.

10:44.210 --> 10:52.530
Now, if you are not using your cloud recall, which is kind of the latest thing through Azure, this is kind of the default built-in.

10:52.530 --> 11:01.430
If you are sending a special message, you basically identify the class message, and the recall.dll is loaded within the context of the Outlook.

11:01.430 --> 11:07.390
It basically starts to delete from your inbox the message that you want to remove.

11:07.930 --> 11:09.870
So we want to achieve the same thing.

11:09.870 --> 11:19.490
We want to exploit the same behavior and define our own CFG with our own dll that will be put automatically into the victim environment.

11:19.610 --> 11:20.950
But can we do that?

11:22.910 --> 11:28.190
Here is an example again from this recall call, which is a column object.

11:28.350 --> 11:29.750
But can we do that?

11:29.750 --> 11:31.670
Well, not exactly.

11:31.670 --> 11:40.210
There is a special mechanism that bypasses Outlook.

11:40.290 --> 11:42.390
And by default, it's disabled.

11:42.390 --> 11:46.790
Now, if it would be enabled, you can definitely define such a CFG.

11:46.810 --> 11:51.470
You can load it, and then you have a form automatically synchronized to your victim environment.

11:51.610 --> 11:57.470
And you can send a special message that will trigger the initiation of the form.

11:57.470 --> 12:21.310
But if this flag is basically disabled, which is by default, your form goes through a special matching algorithm, which validates that you are not using special keywords like inprox server, local handler, which basically automatically instantiate those com objects or those malicious dlls or executables that are put in this folder.

12:21.310 --> 12:25.410
Now, one of the problems with this matching algorithm is...

12:25.410 --> 12:26.730
Wow, it's noisy.

12:27.450 --> 12:32.730
So one of the problems with this matching algorithm is that it is an exact matching.

12:32.730 --> 12:34.850
It checks for an exact words.

12:34.850 --> 12:41.010
Not less, not more, but an exact words within the keys that are specified in the configuration file.

12:41.990 --> 12:51.410
So somehow we lead basically to the first vulnerability that was discovered by NetSpy, which has done amazing work.

12:51.410 --> 12:57.430
They introduced into this registry file an additional relative path.

12:57.430 --> 12:58.910
Okay, so basically...

13:01.600 --> 13:03.460
One, one, one.

13:04.060 --> 13:05.500
Okay.

13:18.840 --> 13:20.040
Yeah.

13:20.040 --> 13:23.900
I'm sure the line at the end will hear.

13:32.010 --> 13:34.190
Yeah, yeah, yeah.

13:35.230 --> 13:36.590
That's more.

13:41.130 --> 13:42.110
One.

13:42.110 --> 13:43.110
Okay.

13:43.930 --> 13:45.290
Okay.

13:45.310 --> 13:47.090
So it's kind of a temporary solution.

13:47.290 --> 13:51.210
So I hope we will finish the presentation until then.

13:51.250 --> 13:53.970
But again, it's a great finding.

13:53.970 --> 13:58.230
Basically, the NetSpy group added a relative class ID.

13:58.450 --> 14:08.290
And it's also documented in Microsoft documentation that they clearly say that you can provide a relative path for your form server rendering.

14:08.650 --> 14:10.410
And they added that.

14:10.410 --> 14:25.910
And then, surprisingly, because the algorithm that checks for the forbidden words does an exact matching, the algorithm fails and you have automatically instantiated form, malicious form, with a fully controlled class ID of your own.

14:25.910 --> 14:41.690
Beside that vulnerability, they also discovered kind of a directory traversal vulnerability in which basically allows to install that form anywhere on the file disk because you can play with one of the properties.

14:41.690 --> 14:43.770
But this property is less interesting for us.

14:43.770 --> 14:46.690
It was nicely patched by Microsoft.

14:46.790 --> 14:51.370
But I will be talking specifically about the bypass algorithm.

14:51.790 --> 14:53.550
So now is the interesting part.

14:53.550 --> 15:00.470
How Microsoft patched that vulnerability and what led us basically to discover new vulnerabilities following that patch.

15:00.550 --> 15:09.010
So as we see in the patch that was introduced by Microsoft, Microsoft said, okay, you have a problem with the relative path.

15:09.010 --> 15:10.510
Let's remove relative path.

15:10.510 --> 15:12.710
They didn't update the documentation yet.

15:12.950 --> 15:15.710
But they basically removed that functionality.

15:15.710 --> 15:19.970
You cannot put a backslash anymore in the property of the form.

15:19.970 --> 15:21.410
So great.

15:21.410 --> 15:21.850
Okay.

15:21.850 --> 15:23.070
It solved the problem.

15:23.070 --> 15:25.330
But they didn't change the matching algorithm.

15:25.330 --> 15:27.130
The algorithm is still the same.

15:27.490 --> 15:38.790
So as you would expect, we were looking for additional control flows that allow us to still instantiate the same forms by abusing the failure in the matching algorithm.

15:40.290 --> 15:44.270
So I have to commend to Microsoft because they have done it quite quickly.

15:44.270 --> 15:46.530
We reported it in April.

15:46.970 --> 15:48.770
They patched it in June.

15:49.170 --> 15:51.110
So nice work.

15:52.410 --> 16:03.730
But, again, before we are diving into how we created additional control flow, we need to understand how a Windows core API function works.

16:03.850 --> 16:14.250
Now, when you basically register a form, it goes through a process in which they use recreate XA function.

16:14.250 --> 16:17.310
It's also utilized in most of the applications today.

16:17.310 --> 16:20.970
It's one of the most popular functions that exist today.

16:20.970 --> 16:31.730
One of the properties of this function, which is interesting, you can supply to this function a parameter that composed of multiple keys by separating them through backslashes.

16:32.130 --> 16:34.990
Now, I think it's limited to 32 keys.

16:34.990 --> 16:45.270
So if you are basically using that function with 31 backslashes, it will create a nested directory structure automatically.

16:45.690 --> 16:55.010
And one of the additional properties is that if you provide a register key with a backslash, trailing backslash, it will be removed to maintain consistency.

16:55.010 --> 16:58.250
It's correct to any recreate XA.

16:58.310 --> 17:06.810
And this will be probably interesting to investigate other applications that may be vulnerable due to the same reason.

17:07.370 --> 17:13.470
So as you would probably guess, we just added this backslash at the end.

17:13.670 --> 17:22.130
So as soon as you add the backslash at the end, obviously, it goes through the matching algorithm, which does the exact matching.

17:22.130 --> 17:26.090
It goes through because, again, we have the backslash.

17:26.090 --> 17:33.550
And when the reg X creates the registry, it removes the trailing backslash.

17:33.550 --> 17:43.290
And voila, you have a fully executing form written automatically, synchronized by Microsoft to any of the victim environments.

17:43.330 --> 17:46.290
And what do we need to basically execute that?

17:46.290 --> 17:50.810
Just to send the message, a simple email with the message class of that form.

17:52.390 --> 17:56.310
So very quickly, just a demonstration.

17:57.190 --> 17:58.750
Let's see.

18:01.220 --> 18:02.740
Okay.

18:06.500 --> 18:09.380
I hope you see the video.

18:09.640 --> 18:12.100
So in this video, we will... no?

18:13.060 --> 18:14.240
Okay.

18:14.240 --> 18:15.820
It's a problem.

18:20.480 --> 18:23.780
Maybe we can push it here.

18:23.980 --> 18:24.780
Okay.

18:24.780 --> 18:26.700
Ah, solution.

18:26.700 --> 18:29.280
So we'll try to do a play like that.

18:29.800 --> 18:31.540
Maybe this works.

18:32.300 --> 18:33.340
Okay.

18:33.560 --> 18:34.400
Remotely.

18:34.600 --> 18:35.880
Nice.

18:36.000 --> 18:36.580
Okay.

18:36.580 --> 18:40.520
So essentially we are working here on outdated outlook.

18:40.520 --> 18:46.640
This was recorded in June, just before the patch was introduced by Microsoft.

18:46.640 --> 18:59.520
We are using a tool by Etienne Stevens called the ruler, which basically allows us to utilize the MAPI API to synchronize and create a new form.

18:59.520 --> 19:01.080
We didn't have to use that.

19:01.080 --> 19:07.840
We just could open a client in our environment, use the credentials, and create the same form.

19:07.840 --> 19:12.220
Here we are utilizing and creating the property with the backslash.

19:12.220 --> 19:27.920
And with the next step, we will be sending right now an authenticated token that allows us basically to upload the form and to synchronize it across the different victims.

19:28.720 --> 19:36.860
So in the next step, as soon as it will be sent, we will see that the form suddenly appeared on the victim environment.

19:36.860 --> 19:41.120
It takes a bit... a couple of seconds.

19:41.120 --> 19:42.160
Okay.

19:43.700 --> 19:44.740
Good.

19:47.200 --> 19:48.140
Okay.

19:48.140 --> 19:49.620
So here we receive the message.

19:49.620 --> 19:51.800
We're still not opening that message.

19:51.860 --> 20:01.440
The opening of the message will instantiate the execution of the form, but the form was already written, synchronized into the folder.

20:01.440 --> 20:04.620
So this is a way in which you can also use the advanced button.

20:04.620 --> 20:10.920
You can check out the forms, or you can simply go to the folder of the forms and identify it was written.

20:10.920 --> 20:16.640
As soon as I open that, the form server is executed.

20:16.640 --> 20:20.600
As you see, it's executed within the context of the Outlook process.

20:21.060 --> 20:31.240
Now, the same if you would use not inprox server 32, but let's say local handler, it would execute an external application executable the same way.

20:31.580 --> 20:34.320
Now we need to pull it back somehow.

20:35.740 --> 20:36.460
Huh?

20:37.920 --> 20:40.700
No, maybe I just closed it.

20:40.700 --> 20:41.780
Oh, okay.

20:42.980 --> 20:44.100
Okay.

20:45.720 --> 20:47.120
Okay, good.

20:47.140 --> 20:55.220
So this was a very nice demonstration for a form, but again, it's assumed that we have authentication beforehand.

20:55.220 --> 21:03.520
We will show later on how easy we can get the authentication, the tokens from the environment and have a full RC, non-authenticated.

21:03.520 --> 21:08.120
But again, in this case, we do require the credentials of the victim.

21:09.560 --> 21:10.880
Let's continue.

21:12.180 --> 21:15.100
Okay, so what do we have here?

21:15.100 --> 21:17.080
We have a patch to this vulnerability.

21:17.300 --> 21:25.160
Now, it's interesting because we just bypassed one patch, and this patch was introduced to solve the vulnerability that we discovered.

21:25.320 --> 21:32.980
Now, if you look at the patch, again, for those that are reversing here, it's probably more clear.

21:32.980 --> 21:38.260
But essentially, they didn't change the function that checks for the exact strings.

21:38.260 --> 21:42.260
They just decided to remove the trailing backslashes.

21:42.260 --> 21:55.060
So basically, they introduced additional loop that goes over the key and removes all the trailing backslashes, and then continue with the same exact matching algorithm instead of looking for a contain, et cetera.

21:55.060 --> 22:01.640
So I definitely welcome you guys to check out what additional control flows you can find out.

22:01.640 --> 22:03.660
And maybe you will.

22:04.720 --> 22:06.760
But it's not all.

22:06.760 --> 22:13.980
When they introduced that patch, they also introduced additional extension for the blocking list.

22:13.980 --> 22:30.420
Now, it's also interesting, those that identify those special key attributes, those key allows hijacking and execution of additional comments or com hijacking, et cetera.

22:30.420 --> 22:34.880
So definitely an interesting additional path to investigate.

22:34.880 --> 22:41.260
This just shows that there were additional vulnerabilities in place that could be utilized by an adversary.

22:42.640 --> 22:51.220
Okay, so just to put things in the right order, there are more vulnerabilities that were discovered.

22:51.440 --> 22:57.440
Next week, there will be a patch for additional vulnerabilities.

22:57.440 --> 23:06.860
I suppose we will share the details somewhere a month or two months after, but we do recommend you to patch your Outlook clients because it's not very difficult.

23:06.860 --> 23:08.600
The exploit is very trivial.

23:10.460 --> 23:19.060
Now, again, form injection is nice for remote code execution, but it's not the only way to utilize that type of vulnerabilities.

23:19.400 --> 23:22.240
Now, we can obviously do a persistency with that.

23:22.240 --> 23:24.220
We can also escalate privileges.

23:25.000 --> 23:37.540
If you, for example, hijack the credentials of an Exchange admin, we can propagate the same forms across all the inboxes and do much more damage than just a simple victim.

23:39.420 --> 23:45.320
So let's talk for a second about the other part which is missing, the authentication.

23:45.320 --> 24:01.440
Now, I'm talking about authentication only in two slides, but there is a nice presentation tomorrow by someone else that is only talking about NTLM, and I trust that it will be a great presentation.

24:01.660 --> 24:16.220
But NTLM is essentially, or anti-hash if you would say, if you would, for example, send an email and send a link to a file, and the victim will double-click on those links.

24:16.340 --> 24:25.880
Behind that, there will be an SMB protocol that will require basically a challenge response algorithm that will require authentication.

24:26.240 --> 24:37.660
And if you are by default not doing a Kerberos authentication, a rogue server will take your anti-hash automatically, and the file doesn't have to exist there, just you pressing the link.

24:37.660 --> 24:44.660
But aside of that, there were a lot of vulnerabilities that were discovered in 2023 and 2024.

24:44.760 --> 24:52.260
It was, I think, one of the significant years for NTLM leaks all across with zero clicks.

24:52.260 --> 25:14.080
So you didn't need to press or get a warning that there is an SMB file, you just needed to have an appointment reminder that is sent with a nice kind of link to a sound that will be sound when the appointment is being sent, or some kind of Windows performance analyzer that is being directed,

25:14.080 --> 25:18.100
and all kinds of additional exploits that lead to the same NTLM leak.

25:18.100 --> 25:21.240
So it's not very difficult to get NTLM leaks.

25:21.280 --> 25:25.940
We'll get into a recommendation how it can be blocked going forward.

25:26.020 --> 25:28.480
But one of them is interesting.

25:28.480 --> 25:36.440
The last one, especially NTLM leaks that are led through execution of monikers, so compound monikers.

25:36.440 --> 25:46.020
And this is a great time to move to Arnold, which will be talking about compound monikers that lead to remote code executions and NTLM.

25:47.600 --> 25:48.700
Okay, then.

25:48.700 --> 25:49.900
Thank you, Michael.

25:52.590 --> 26:03.830
So before we dive into the next RCE vulnerability we discovered in Outlook, we first need to get at least some high-level understanding of what monikers are.

26:03.830 --> 26:15.930
And I highly encourage you to dig deeper into the subject, as multiple vulnerabilities in Outlook involve monikers in Office applications, involve monikers in some way or another.

26:16.110 --> 26:22.630
Now, actually we are all using monikers with our daily work with Office applications.

26:22.630 --> 26:32.230
One example is when you try to send an email, and in the body of that email you attach an Excel chart as a link.

26:32.490 --> 26:41.850
Well, a moniker is used to point to that specific Excel chart using a string understood by the moniker mechanism and the monikers involved.

26:42.010 --> 26:57.190
Now, the general idea of a moniker is to provide you with some way to locate and identify this specific com object using strings or instead of writing a custom mechanism to do that.

26:57.190 --> 27:03.450
And in order to achieve it, all monikers must implement the IMoniker interface.

27:03.730 --> 27:15.980
Well, Microsoft actually provides several implementations of monikers, some of them related to the OLE objects and most notably used in Office applications.

27:15.980 --> 27:24.160
Some of these monikers include the FileMoniker, ItemMoniker, URLMoniker and a few more.

27:25.680 --> 27:36.680
One additional example is using the getObject method within the Visual Basic Programming Language or its Windows API equivalent, the call getObject.

27:36.680 --> 27:49.000
This is basically a helper function that simplifies the way of converting the moniker string, the display name, into a moniker and then binding to that named object.

27:49.000 --> 27:58.200
Now, it does that by encapsulating calls to the com library functions, the createBind, mkParseDisplayName and bindToObject.

27:59.460 --> 28:02.880
Okay, so moving back to Outlook.

28:02.880 --> 28:08.700
Imagine receiving an email with hyperlink points to a file located on an SMB share.

28:08.700 --> 28:18.720
If you would click on that file or on that link, you won't get a pop-up notification asking whether you are sure you want to click on that link.

28:18.720 --> 28:22.660
Clicking on links from untrusted sources can do this and that.

28:23.020 --> 28:36.480
Instead, a warning message is displayed in the Windows Notification Center stating that something unexpected went wrong with the URL and the file on that SMB share would never be accessed.

28:36.480 --> 28:38.640
We would expect that to be good, right?

28:38.640 --> 28:53.280
So, if the file would have been accessed, at least the local NTLM credentials would have been leaked as accessing the file would go through the SMB protocol which relies on the local NTLM credentials to authenticate.

28:55.180 --> 29:07.840
Well, earlier this year, Checkpoint Researcher found a vulnerability in Outlook that bypasses that warning message by simply adding an exclamation mark at the end of that link.

29:07.960 --> 29:22.320
Apparently, this turns the hyperlink from a simple hyperlink that points to a file moniker into a generic composite moniker that is composed from a file moniker and an item moniker.

29:22.400 --> 29:31.680
Clicking on such a link results in accessing the file, leaking the local NTLM credentials, and potentially allow for remote code execution.

29:32.500 --> 29:36.500
So, let's dive in and understand how this is happening.

29:36.520 --> 29:45.600
Most Microsoft Office applications load the MSO DLL, which is a core component used by multiple Office applications.

29:45.640 --> 29:51.680
The DLL contains essential functionalities that is split between multiple DLLs.

29:51.680 --> 29:53.780
Some of them are presented.

29:53.900 --> 30:04.840
The one we are interested with the vulnerability discovered by Checkpoint is the MSO-30 DLL, which handles things related to links and links parsing.

30:04.840 --> 30:20.260
And to be more specific, the MSO HRLinkCreateFromString function that is a wrapper for HLinkCreateFromString that basically creates hyperlink objects from strings that represent the hyperlink target.

30:20.300 --> 30:35.820
If you would look at the documentation for HLinkCreateFromString, we see that it starts with a security warning that states, never parse strings from a non-trusted source when creating hyperlinks with HLinkCreateFromString.

30:35.820 --> 30:39.560
The target parameter is passed to MKParseDisplayName.

30:39.580 --> 30:43.560
Now, you might be wondering what is wrong with MKParseDisplayName.

30:43.560 --> 30:45.140
We'll get it in a second.

30:45.140 --> 30:48.000
But before that, take a look at the second paragraph.

30:48.120 --> 31:02.720
You can see that it is mentioned that if a string of the form suggested in the checkpoints vulnerability at composite moniker is passed, it will instantiate the object registered with the specific prog ID.

31:03.040 --> 31:09.840
And if it implements the iMoniker interface, it can in turn run unexpected code.

31:10.700 --> 31:12.560
And it doesn't stop just there.

31:12.560 --> 31:26.220
Looking at the documentation for MKParseDisplayName, we see that it states that calling MKParseDisplayName with a display name parameter from an untrusted source is unsafe.

31:26.220 --> 31:32.920
And it can lead to some moniker implementations to act on the string during the parsing of it.

31:34.200 --> 31:59.940
Well, if you take a closer look at how it happens in the code, we see that when there is a character indicated that the string is a composite moniker, and by the way, not only by the exclamation mark, but also the opening square bracket and colon, the parsing of that composite moniker would go through the MKParseDisplayName for handling with,

31:59.940 --> 32:04.980
of course, composite monikers instead of creating a file moniker.

32:05.100 --> 32:23.660
Now, when MKParseDisplayName is called, it will call the bindToObject method, which eventually involves the relevant com object, responsible for handling with the specific file type pointed to by the file moniker.

32:23.660 --> 32:32.460
For instance, if the file pointed to by the file moniker is an RTF, WinWord will be spawned in the background without displaying the UI.

32:32.460 --> 32:44.820
It will access the file pointed to by the file moniker, and will try to access the object pointed to by the item moniker.

32:47.540 --> 32:51.580
Now, this behavior leads to two significant issues.

32:51.580 --> 33:08.500
First, the file is being accessed, so we have an NTLM credential leak, and second, the file is being parsed, so any RCE involved in the parsing routine can be chained to gain full RCE.

33:08.800 --> 33:24.420
Now, one important note I want to point is that characters other than the exclamation mark can trigger this vulnerability, and it's important from a detection and prevention standpoint, as it wasn't mentioned anywhere else.

33:25.660 --> 33:36.040
Now, before we dive into the patch analysis and how we bypassed it, we first need to understand how Microsoft patches some vulnerabilities in Office applications.

33:36.040 --> 33:43.820
Surprisingly or not, they use hooks which are installed from the ineditors function within the MSODLL.

33:43.840 --> 33:58.180
Apparently, each Office application has its own application ID, and before the hook is installed, the ineditors function checks that the current process has a valid application ID.

33:58.180 --> 34:02.520
Well, this technique kind of reminds us hot-patching, right?

34:02.820 --> 34:17.340
Pinpointing a specific API in a specific location only by specific processes, as well, these APIs are being used system-wide across many other applications.

34:19.040 --> 34:29.940
Now, moving on to the patch itself, as you can see, Microsoft updated the ineditors function to add hooks for the MKParsDisplayName APIs.

34:31.460 --> 34:47.260
The hook simply checks if a flag named block MKParsDisplayName on current thread is set to true, and if that's the case, as the name suggests, MKParsDisplayName would not be invoked, and it will return an error instead.

34:49.060 --> 34:53.000
Now you might be wondering where that flag is being set.

34:53.000 --> 34:57.420
If you recall, the MSOHRLink createFromString.

34:57.660 --> 35:10.000
responsible for creating hyperlink objects from strings, sets the flag to true at the beginning of the function, and it only does that if the application ID equals outlook.

35:11.560 --> 35:17.720
Looking at the patch analysis, a few questions come to mind.

35:17.720 --> 35:22.240
Well, I'm sure that some of you are already asking yourselves these questions.

35:22.240 --> 35:30.270
Well, the whole hyperlink creation goes through the MSOHRLink createFromString, where that flag was being set to true.

35:31.100 --> 35:38.060
What about other code flows that may reach the unsafe API, the MKParsDisplayName?

35:39.380 --> 35:42.800
What about the application ID?

35:42.800 --> 35:46.000
We've seen comparison to outlook only.

35:46.000 --> 35:48.160
What about other apps?

35:48.960 --> 35:53.180
To answer these questions, I want to do a quick recap.

35:53.180 --> 36:05.270
The following diagram demonstrates the interesting API calls when clicking on a composite moniker hyperlink within an email, before the patch was employed.

36:06.390 --> 36:09.490
And this is how it looks after the patch.

36:09.890 --> 36:23.590
We have the addition of the block MKParsDisplayName flag that is being set to true at the beginning, as we said, and the detoured function checks that flag and acts accordingly.

36:25.330 --> 36:43.570
We were looking for ways to get to the unsafe API, the MKParsDisplayName, without going through the function that sets that flag to true, and we found a candidate, the hrpmon from URL.

36:44.030 --> 36:54.370
We found that doing some cross-referencing through the relevant API calls, and we've seen that this one may reach the unsafe API.

36:55.010 --> 37:01.130
And as a matter of fact, this is how we got to discover the RC vulnerability in Outlook.

37:02.590 --> 37:13.390
When you pass a composite moniker within an image tag, the parsing of that composite moniker won't go through the mso-hrlink-reform string that was patched.

37:13.390 --> 37:36.310
Instead, it will invoke the hrpmon from URL that handles the parsing of the URLs from image tags, and it will directly call the hlink-parsDisplayName that will eventually get the same code flow that reaches to the unsafe API, MKParsDisplayName.

37:37.210 --> 37:46.290
Now that we are familiar with how Microsoft patches some vulnerabilities in Office applications, the patch is quite obvious, right?

37:46.290 --> 37:57.830
Setting the infamous flag to true, but this time from hrpmon from URL, and again, only if the application ID equals Outlook.

37:58.310 --> 38:23.790
Now, to sum up these two patches, we saw that Microsoft only addresses specific code flows and specific scenarios that leads to the unsafe API, the MKParsDisplayName, and we left some questions open for you to investigate, and we are certain that there are more applications and more code flows that leads to that unsafe API.

38:26.610 --> 38:30.850
Okay, just some additional notes.

38:31.010 --> 38:43.150
As Arnold shared, and thank you, Arnold, Microsoft patched the remote code execution by introducing this additional hook and turning on the flag through this control flow.

38:43.150 --> 38:45.730
It didn't solve the NTLM leak.

38:45.730 --> 39:05.870
Now, we obviously didn't want to publish it, but we got a response from Microsoft that there is a medium risk, and for Microsoft it's not an urgency, and the fact that the image cannot be automatically downloaded because you have kind of a preview mode,

39:05.870 --> 39:09.450
if the sender is not trusted, and they are right.

39:09.450 --> 39:28.570
If the sender is not trusted, the image will not be automatically downloaded, and the compound moniker will not be automatically executed, but if the sender is trusted, again, someone in the organization, let's say, was compromised, and you're utilizing his credential to send to the other victim within the same organization,

39:28.570 --> 39:38.270
the same link, the image will be automatically downloaded or previewed, and the NTLM will happen, and this unfortunately wasn't patched.

39:38.270 --> 39:41.910
So let's just finalize.

39:41.910 --> 39:43.890
We have a couple of minutes left.

39:43.890 --> 39:45.430
Some recommendations.

39:46.270 --> 39:48.310
Some of them are obvious.

39:48.310 --> 39:52.530
Microsoft basically writes a lot about some of the recommendations.

39:52.530 --> 40:05.050
Obviously, in four scare bureaus, Windows 11 introduces, I think, an update, already introduced update, in which by default NTLM authentication will not be possible.

40:05.050 --> 40:09.610
I suppose it will not hold for long due to backward compatibilities, etc.

40:10.310 --> 40:15.650
Definitely enable SMB signing and manage your outbound SMB.

40:15.650 --> 40:21.250
You don't want that kind of, let's say, network communication going outside of your organization.

40:21.450 --> 40:25.950
And there are definitely additional recommendations that can follow.

40:26.150 --> 40:32.090
Now, just before we kind of end the presentation, some credit references.

40:32.090 --> 40:37.110
Again, as we mentioned, NetSpy is doing great work discovering new stuff.

40:37.710 --> 40:39.530
Checkpoint also, as well.

40:39.530 --> 40:41.810
And so is Etienne Stevens.

40:41.810 --> 40:46.730
I'm sure I'm missing a lot of other folks because a lot of work is being invested.

40:46.770 --> 40:49.510
You guys are welcome to ask our questions.

40:49.870 --> 40:54.850
We will be waiting here behind the entry door for like 10 minutes.

40:54.870 --> 40:58.110
But overall, we are done.

40:58.410 --> 41:00.930
It's an honor to present at the DEF CON.

41:00.930 --> 41:05.710
We are thanking you to come here to see our presentation.

41:05.710 --> 41:06.730
Thank you very much.

