1 00:00:01,910 --> 00:00:04,410 Hey, good evening to everyone. 2 00:00:04,970 --> 00:00:06,050 Okay. 3 00:00:10,490 --> 00:00:11,730 Thank you. 4 00:00:11,730 --> 00:00:13,430 Thank you, thank you. 5 00:00:13,430 --> 00:00:17,950 Okay, so what do you expect from patches? 6 00:00:18,030 --> 00:00:19,570 Security updates. 7 00:00:19,830 --> 00:00:23,050 You expect them to be a Fort Knox security update, right? 8 00:00:23,050 --> 00:00:26,890 That solves fully the vulnerability, all the control flows. 9 00:00:26,970 --> 00:00:28,410 Is it really? 10 00:00:29,690 --> 00:00:32,670 In reality, this is what we usually get. 11 00:00:33,830 --> 00:00:34,950 Yep. 12 00:00:35,210 --> 00:00:39,870 So we've all been there, expecting that one patch solves it all, right? 13 00:00:39,870 --> 00:00:46,730 But essentially it's kind of a patch to a bullet, or there's a better phrase for that. 14 00:00:46,810 --> 00:00:54,030 We will be sharing insights about what happens when the patch does not quite do the trick. 15 00:00:54,450 --> 00:00:57,650 And sometimes you also find new vulnerabilities. 16 00:00:57,790 --> 00:01:02,310 So this talk will be sharing new details about vulnerabilities that we discovered. 17 00:01:02,310 --> 00:01:05,330 And were patched during June and July. 18 00:01:05,710 --> 00:01:10,070 Those are two out of a bigger number of vulnerabilities. 19 00:01:10,490 --> 00:01:13,770 Let's not be too harsh with the vendors. 20 00:01:13,890 --> 00:01:16,670 There's a reason why this happens many times. 21 00:01:16,670 --> 00:01:21,410 Just a couple of weeks ago, we all saw the mega crash from a CrowdStrike update. 22 00:01:21,650 --> 00:01:25,530 It's not exactly a security update, nevertheless the impact is obvious, right? 23 00:01:25,530 --> 00:01:27,070 Blue screens all over. 24 00:01:27,070 --> 00:01:32,530 And this is exactly the reason why many vendors are kind of trying to solve only the specific problem. 25 00:01:32,910 --> 00:01:43,370 While doing so, also kind of share with us the investigative researchers on additional vulnerabilities that are within the code. 26 00:01:44,450 --> 00:01:47,950 So just very shortly about ourselves. 27 00:01:47,950 --> 00:01:52,350 My name is Michael Gorelick, I'm the chief technology officer and founder of Morphisec. 28 00:01:52,650 --> 00:01:55,970 I have around 20 years of experience in cyber security. 29 00:01:55,970 --> 00:02:02,310 I was the one to discover one of the largest supply chain attacks, the SeaCleaner, in history. 30 00:02:02,550 --> 00:02:07,990 I have a lot of experience in reverse engineering, red teaming and blue teaming. 31 00:02:08,150 --> 00:02:09,830 Go ahead, Arnold. 32 00:02:10,330 --> 00:02:12,870 Hey guys, my name is Arnold. 33 00:02:12,870 --> 00:02:17,090 I'm leading the malware research efforts at Morphisec. 34 00:02:17,090 --> 00:02:25,070 And for some time now I'm poking with some patch analysis for fan and profit and product, of course. 35 00:02:26,150 --> 00:02:27,610 Thanks, Arnold. 36 00:02:29,310 --> 00:02:30,470 Okay. 37 00:02:30,890 --> 00:02:33,550 So just starting with a disclaimer. 38 00:02:33,850 --> 00:02:36,490 With great power comes greater responsibility. 39 00:02:36,550 --> 00:02:38,810 Use your powers for the good. 40 00:02:40,950 --> 00:02:42,910 So now about the talk itself. 41 00:02:42,910 --> 00:02:44,650 A bit about the motivation. 42 00:02:44,650 --> 00: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. 43 00:02:56,390 --> 00: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, 44 00:03:15,170 --> 00:03:16,670 prior authentication. 45 00:03:16,770 --> 00:03:24,350 Additional category that Arnold will be sharing is about compound monikers, also lead to remote code execution. 46 00:03:24,630 --> 00:03:30,770 Checkpoint done a great research and a great work discovering some vulnerabilities during the year. 47 00:03:30,770 --> 00: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. 48 00:03:40,190 --> 00:03:43,610 Okay, so let's start talking about the forms. 49 00:03:44,250 --> 00: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. 50 00:03:59,570 --> 00: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. 51 00:04:07,950 --> 00:04:12,530 Now, message, email message is not the only thing that is based on forms. 52 00:04:12,530 --> 00: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. 53 00:04:21,190 --> 00:04:22,550 What happens behind? 54 00:04:22,550 --> 00:04:24,830 What happens when recall being sent? 55 00:04:24,930 --> 00:04:32,090 So essentially, it's something there activates and starts to delete the email from the inboxes of your manager. 56 00:04:32,490 --> 00: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. 57 00:04:44,790 --> 00: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. 58 00:04:53,270 --> 00:04:57,610 So forms, overall, can be of two different types. 59 00:04:57,610 --> 00: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. 60 00:05:08,710 --> 00: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. 61 00:05:25,390 --> 00: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. 62 00:05:33,070 --> 00:05:37,070 We'll talk about the creation of the form in the next slide. 63 00:05:37,170 --> 00:05:43,630 What is outside of the scope of this presentation is talking about visual basic execution within the form. 64 00:05:43,630 --> 00:05:47,010 It was well covered by Etienne Stevens. 65 00:05:47,010 --> 00:05:50,950 He done a lot of research in 2017, a lot of presentations. 66 00:05:50,950 --> 00:05:53,870 You are welcome to check them out. 67 00:05:53,870 --> 00:06:01,390 Microsoft introduced a lot of hardening to avoid the default execution of visual basic inside forms. 68 00:06:01,390 --> 00:06:03,770 So this is outside of the scope. 69 00:06:05,070 --> 00:06:10,090 Okay, so I already mentioned that we have one way to create a custom form. 70 00:06:10,090 --> 00:06:13,590 This one way is by modifying existing built-in forms. 71 00:06:13,590 --> 00:06:21,010 But what is interesting for us in this category of form injection is the way you can programmatically create new forms. 72 00:06:21,010 --> 00:06:26,410 If you look at the documentation of Microsoft, this is actually a snapshot from Microsoft documentation. 73 00:06:26,670 --> 00:06:32,870 There is a way to create your own form by basically generating a configuration file called CFG. 74 00:06:33,070 --> 00: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. 75 00:06:42,610 --> 00:06:45,930 And you can also specify a form server. 76 00:06:45,930 --> 00:06:49,470 In this case, you see the example is helpdesk.exe. 77 00:06:49,470 --> 00:06:52,090 That is responsible to render the form. 78 00:06:52,090 --> 00:06:56,970 So upon receiving that message in your Outlook, you want to do something about that. 79 00:06:56,970 --> 00:07:01,870 This is the executable that eventually spawned and does something about that. 80 00:07:01,870 --> 00:07:04,290 And we will share a couple of examples. 81 00:07:04,410 --> 00:07:06,130 Now, it doesn't have to be executable. 82 00:07:06,130 --> 00:07:10,250 You can use a different DLL or any other ways. 83 00:07:10,250 --> 00:07:12,230 We'll share that as well. 84 00:07:12,430 --> 00:07:17,470 But again, there is a very nice way to run that form. 85 00:07:17,470 --> 00: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. 86 00:07:25,670 --> 00:07:33,110 Nevertheless, it's important to understand one of the most interesting things in forms is the synchronization mechanism. 87 00:07:33,190 --> 00: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. 88 00:07:46,290 --> 00:07:49,310 This is not the only thing that obviously synchronizes. 89 00:07:49,310 --> 00: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. 90 00:07:58,630 --> 00:08:03,330 Now, the mechanism involves form libraries that represent properties. 91 00:08:03,330 --> 00:08:06,750 It will also include form servers, etc. 92 00:08:07,110 --> 00:08:12,850 And there's also important to understand that not all forms are synchronized. 93 00:08:12,850 --> 00:08:19,630 If you put your form into a personal library, it will not be synchronized across the different clients. 94 00:08:19,630 --> 00:08:27,150 But if you, for example, install it in the inbox, it will definitely be synced by the Microsoft protocol. 95 00:08:29,070 --> 00:08:33,710 So shortly, how forms are loading and registered. 96 00:08:33,710 --> 00:08:39,870 So if you take, in this example, a simple built-in modified form, this is not a programmatically created form. 97 00:08:39,870 --> 00:08:42,410 Nevertheless, it's the same mechanism. 98 00:08:42,890 --> 00: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. 99 00:08:52,890 --> 00: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. 100 00:08:59,830 --> 00: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. 101 00:09:10,190 --> 00: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. 102 00:09:20,190 --> 00:09:26,650 And the built-in forms are saved within the program files office, also special folder there. 103 00:09:26,650 --> 00:09:37,630 Essentially, those form libraries are comb objects, and those can be rendered and instantiated like any other comb. 104 00:09:38,210 --> 00:09:46,450 As we said, the original kind of oily form library is a bit outside of the scope of this lecture. 105 00:09:46,450 --> 00: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. 106 00:10:00,970 --> 00:10:07,770 But we will be talking about programmatically created forms through the configuration files. 107 00:10:07,770 --> 00: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. 108 00:10:19,750 --> 00:10:25,150 You can go to this specified directory and find those CFG files. 109 00:10:25,170 --> 00:10:29,670 Now, you identify that there is a special file called a React CFG. 110 00:10:29,670 --> 00:10:33,230 This is an example of the recall message form. 111 00:10:33,230 --> 00: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. 112 00:10:44,210 --> 00: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. 113 00:10:52,530 --> 00: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. 114 00:11:01,430 --> 00:11:07,390 It basically starts to delete from your inbox the message that you want to remove. 115 00:11:07,930 --> 00:11:09,870 So we want to achieve the same thing. 116 00:11:09,870 --> 00: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. 117 00:11:19,610 --> 00:11:20,950 But can we do that? 118 00:11:22,910 --> 00:11:28,190 Here is an example again from this recall call, which is a column object. 119 00:11:28,350 --> 00:11:29,750 But can we do that? 120 00:11:29,750 --> 00:11:31,670 Well, not exactly. 121 00:11:31,670 --> 00:11:40,210 There is a special mechanism that bypasses Outlook. 122 00:11:40,290 --> 00:11:42,390 And by default, it's disabled. 123 00:11:42,390 --> 00:11:46,790 Now, if it would be enabled, you can definitely define such a CFG. 124 00:11:46,810 --> 00:11:51,470 You can load it, and then you have a form automatically synchronized to your victim environment. 125 00:11:51,610 --> 00:11:57,470 And you can send a special message that will trigger the initiation of the form. 126 00:11:57,470 --> 00: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. 127 00:12:21,310 --> 00:12:25,410 Now, one of the problems with this matching algorithm is... 128 00:12:25,410 --> 00:12:26,730 Wow, it's noisy. 129 00:12:27,450 --> 00:12:32,730 So one of the problems with this matching algorithm is that it is an exact matching. 130 00:12:32,730 --> 00:12:34,850 It checks for an exact words. 131 00:12:34,850 --> 00:12:41,010 Not less, not more, but an exact words within the keys that are specified in the configuration file. 132 00:12:41,990 --> 00:12:51,410 So somehow we lead basically to the first vulnerability that was discovered by NetSpy, which has done amazing work. 133 00:12:51,410 --> 00:12:57,430 They introduced into this registry file an additional relative path. 134 00:12:57,430 --> 00:12:58,910 Okay, so basically... 135 00:13:01,600 --> 00:13:03,460 One, one, one. 136 00:13:04,060 --> 00:13:05,500 Okay. 137 00:13:18,840 --> 00:13:20,040 Yeah. 138 00:13:20,040 --> 00:13:23,900 I'm sure the line at the end will hear. 139 00:13:32,010 --> 00:13:34,190 Yeah, yeah, yeah. 140 00:13:35,230 --> 00:13:36,590 That's more. 141 00:13:41,130 --> 00:13:42,110 One. 142 00:13:42,110 --> 00:13:43,110 Okay. 143 00:13:43,930 --> 00:13:45,290 Okay. 144 00:13:45,310 --> 00:13:47,090 So it's kind of a temporary solution. 145 00:13:47,290 --> 00:13:51,210 So I hope we will finish the presentation until then. 146 00:13:51,250 --> 00:13:53,970 But again, it's a great finding. 147 00:13:53,970 --> 00:13:58,230 Basically, the NetSpy group added a relative class ID. 148 00:13:58,450 --> 00: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. 149 00:14:08,650 --> 00:14:10,410 And they added that. 150 00:14:10,410 --> 00: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. 151 00:14:25,910 --> 00: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. 152 00:14:41,690 --> 00:14:43,770 But this property is less interesting for us. 153 00:14:43,770 --> 00:14:46,690 It was nicely patched by Microsoft. 154 00:14:46,790 --> 00:14:51,370 But I will be talking specifically about the bypass algorithm. 155 00:14:51,790 --> 00:14:53,550 So now is the interesting part. 156 00:14:53,550 --> 00:15:00,470 How Microsoft patched that vulnerability and what led us basically to discover new vulnerabilities following that patch. 157 00:15:00,550 --> 00: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. 158 00:15:09,010 --> 00:15:10,510 Let's remove relative path. 159 00:15:10,510 --> 00:15:12,710 They didn't update the documentation yet. 160 00:15:12,950 --> 00:15:15,710 But they basically removed that functionality. 161 00:15:15,710 --> 00:15:19,970 You cannot put a backslash anymore in the property of the form. 162 00:15:19,970 --> 00:15:21,410 So great. 163 00:15:21,410 --> 00:15:21,850 Okay. 164 00:15:21,850 --> 00:15:23,070 It solved the problem. 165 00:15:23,070 --> 00:15:25,330 But they didn't change the matching algorithm. 166 00:15:25,330 --> 00:15:27,130 The algorithm is still the same. 167 00:15:27,490 --> 00: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. 168 00:15:40,290 --> 00:15:44,270 So I have to commend to Microsoft because they have done it quite quickly. 169 00:15:44,270 --> 00:15:46,530 We reported it in April. 170 00:15:46,970 --> 00:15:48,770 They patched it in June. 171 00:15:49,170 --> 00:15:51,110 So nice work. 172 00:15:52,410 --> 00: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. 173 00:16:03,850 --> 00:16:14,250 Now, when you basically register a form, it goes through a process in which they use recreate XA function. 174 00:16:14,250 --> 00:16:17,310 It's also utilized in most of the applications today. 175 00:16:17,310 --> 00:16:20,970 It's one of the most popular functions that exist today. 176 00:16:20,970 --> 00: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. 177 00:16:32,130 --> 00:16:34,990 Now, I think it's limited to 32 keys. 178 00:16:34,990 --> 00:16:45,270 So if you are basically using that function with 31 backslashes, it will create a nested directory structure automatically. 179 00:16:45,690 --> 00: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. 180 00:16:55,010 --> 00:16:58,250 It's correct to any recreate XA. 181 00:16:58,310 --> 00:17:06,810 And this will be probably interesting to investigate other applications that may be vulnerable due to the same reason. 182 00:17:07,370 --> 00:17:13,470 So as you would probably guess, we just added this backslash at the end. 183 00:17:13,670 --> 00: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. 184 00:17:22,130 --> 00:17:26,090 It goes through because, again, we have the backslash. 185 00:17:26,090 --> 00:17:33,550 And when the reg X creates the registry, it removes the trailing backslash. 186 00:17:33,550 --> 00:17:43,290 And voila, you have a fully executing form written automatically, synchronized by Microsoft to any of the victim environments. 187 00:17:43,330 --> 00:17:46,290 And what do we need to basically execute that? 188 00:17:46,290 --> 00:17:50,810 Just to send the message, a simple email with the message class of that form. 189 00:17:52,390 --> 00:17:56,310 So very quickly, just a demonstration. 190 00:17:57,190 --> 00:17:58,750 Let's see. 191 00:18:01,220 --> 00:18:02,740 Okay. 192 00:18:06,500 --> 00:18:09,380 I hope you see the video. 193 00:18:09,640 --> 00:18:12,100 So in this video, we will... no? 194 00:18:13,060 --> 00:18:14,240 Okay. 195 00:18:14,240 --> 00:18:15,820 It's a problem. 196 00:18:20,480 --> 00:18:23,780 Maybe we can push it here. 197 00:18:23,980 --> 00:18:24,780 Okay. 198 00:18:24,780 --> 00:18:26,700 Ah, solution. 199 00:18:26,700 --> 00:18:29,280 So we'll try to do a play like that. 200 00:18:29,800 --> 00:18:31,540 Maybe this works. 201 00:18:32,300 --> 00:18:33,340 Okay. 202 00:18:33,560 --> 00:18:34,400 Remotely. 203 00:18:34,600 --> 00:18:35,880 Nice. 204 00:18:36,000 --> 00:18:36,580 Okay. 205 00:18:36,580 --> 00:18:40,520 So essentially we are working here on outdated outlook. 206 00:18:40,520 --> 00:18:46,640 This was recorded in June, just before the patch was introduced by Microsoft. 207 00:18:46,640 --> 00: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. 208 00:18:59,520 --> 00:19:01,080 We didn't have to use that. 209 00:19:01,080 --> 00:19:07,840 We just could open a client in our environment, use the credentials, and create the same form. 210 00:19:07,840 --> 00:19:12,220 Here we are utilizing and creating the property with the backslash. 211 00:19:12,220 --> 00: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. 212 00:19:28,720 --> 00: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. 213 00:19:36,860 --> 00:19:41,120 It takes a bit... a couple of seconds. 214 00:19:41,120 --> 00:19:42,160 Okay. 215 00:19:43,700 --> 00:19:44,740 Good. 216 00:19:47,200 --> 00:19:48,140 Okay. 217 00:19:48,140 --> 00:19:49,620 So here we receive the message. 218 00:19:49,620 --> 00:19:51,800 We're still not opening that message. 219 00:19:51,860 --> 00: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. 220 00:20:01,440 --> 00:20:04,620 So this is a way in which you can also use the advanced button. 221 00:20:04,620 --> 00: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. 222 00:20:10,920 --> 00:20:16,640 As soon as I open that, the form server is executed. 223 00:20:16,640 --> 00:20:20,600 As you see, it's executed within the context of the Outlook process. 224 00:20:21,060 --> 00: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. 225 00:20:31,580 --> 00:20:34,320 Now we need to pull it back somehow. 226 00:20:35,740 --> 00:20:36,460 Huh? 227 00:20:37,920 --> 00:20:40,700 No, maybe I just closed it. 228 00:20:40,700 --> 00:20:41,780 Oh, okay. 229 00:20:42,980 --> 00:20:44,100 Okay. 230 00:20:45,720 --> 00:20:47,120 Okay, good. 231 00:20:47,140 --> 00:20:55,220 So this was a very nice demonstration for a form, but again, it's assumed that we have authentication beforehand. 232 00:20:55,220 --> 00: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. 233 00:21:03,520 --> 00:21:08,120 But again, in this case, we do require the credentials of the victim. 234 00:21:09,560 --> 00:21:10,880 Let's continue. 235 00:21:12,180 --> 00:21:15,100 Okay, so what do we have here? 236 00:21:15,100 --> 00:21:17,080 We have a patch to this vulnerability. 237 00:21:17,300 --> 00: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. 238 00:21:25,320 --> 00:21:32,980 Now, if you look at the patch, again, for those that are reversing here, it's probably more clear. 239 00:21:32,980 --> 00:21:38,260 But essentially, they didn't change the function that checks for the exact strings. 240 00:21:38,260 --> 00:21:42,260 They just decided to remove the trailing backslashes. 241 00:21:42,260 --> 00: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. 242 00:21:55,060 --> 00:22:01,640 So I definitely welcome you guys to check out what additional control flows you can find out. 243 00:22:01,640 --> 00:22:03,660 And maybe you will. 244 00:22:04,720 --> 00:22:06,760 But it's not all. 245 00:22:06,760 --> 00:22:13,980 When they introduced that patch, they also introduced additional extension for the blocking list. 246 00:22:13,980 --> 00: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. 247 00:22:30,420 --> 00:22:34,880 So definitely an interesting additional path to investigate. 248 00:22:34,880 --> 00:22:41,260 This just shows that there were additional vulnerabilities in place that could be utilized by an adversary. 249 00:22:42,640 --> 00:22:51,220 Okay, so just to put things in the right order, there are more vulnerabilities that were discovered. 250 00:22:51,440 --> 00:22:57,440 Next week, there will be a patch for additional vulnerabilities. 251 00:22:57,440 --> 00: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. 252 00:23:06,860 --> 00:23:08,600 The exploit is very trivial. 253 00:23:10,460 --> 00: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. 254 00:23:19,400 --> 00:23:22,240 Now, we can obviously do a persistency with that. 255 00:23:22,240 --> 00:23:24,220 We can also escalate privileges. 256 00:23:25,000 --> 00: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. 257 00:23:39,420 --> 00:23:45,320 So let's talk for a second about the other part which is missing, the authentication. 258 00:23:45,320 --> 00: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. 259 00:24:01,660 --> 00: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. 260 00:24:16,340 --> 00:24:25,880 Behind that, there will be an SMB protocol that will require basically a challenge response algorithm that will require authentication. 261 00:24:26,240 --> 00: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. 262 00:24:37,660 --> 00:24:44,660 But aside of that, there were a lot of vulnerabilities that were discovered in 2023 and 2024. 263 00:24:44,760 --> 00:24:52,260 It was, I think, one of the significant years for NTLM leaks all across with zero clicks. 264 00:24:52,260 --> 00: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, 265 00:25:14,080 --> 00:25:18,100 and all kinds of additional exploits that lead to the same NTLM leak. 266 00:25:18,100 --> 00:25:21,240 So it's not very difficult to get NTLM leaks. 267 00:25:21,280 --> 00:25:25,940 We'll get into a recommendation how it can be blocked going forward. 268 00:25:26,020 --> 00:25:28,480 But one of them is interesting. 269 00:25:28,480 --> 00:25:36,440 The last one, especially NTLM leaks that are led through execution of monikers, so compound monikers. 270 00:25:36,440 --> 00: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. 271 00:25:47,600 --> 00:25:48,700 Okay, then. 272 00:25:48,700 --> 00:25:49,900 Thank you, Michael. 273 00:25:52,590 --> 00: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. 274 00:26:03,830 --> 00: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. 275 00:26:16,110 --> 00:26:22,630 Now, actually we are all using monikers with our daily work with Office applications. 276 00:26:22,630 --> 00: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. 277 00:26:32,490 --> 00: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. 278 00:26:42,010 --> 00: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. 279 00:26:57,190 --> 00:27:03,450 And in order to achieve it, all monikers must implement the IMoniker interface. 280 00:27:03,730 --> 00: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. 281 00:27:15,980 --> 00:27:24,160 Some of these monikers include the FileMoniker, ItemMoniker, URLMoniker and a few more. 282 00:27:25,680 --> 00: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. 283 00:27:36,680 --> 00: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. 284 00:27:49,000 --> 00:27:58,200 Now, it does that by encapsulating calls to the com library functions, the createBind, mkParseDisplayName and bindToObject. 285 00:27:59,460 --> 00:28:02,880 Okay, so moving back to Outlook. 286 00:28:02,880 --> 00:28:08,700 Imagine receiving an email with hyperlink points to a file located on an SMB share. 287 00:28:08,700 --> 00: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. 288 00:28:18,720 --> 00:28:22,660 Clicking on links from untrusted sources can do this and that. 289 00:28:23,020 --> 00: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. 290 00:28:36,480 --> 00:28:38,640 We would expect that to be good, right? 291 00:28:38,640 --> 00: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. 292 00:28:55,180 --> 00: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. 293 00:29:07,960 --> 00: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. 294 00:29:22,400 --> 00: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. 295 00:29:32,500 --> 00:29:36,500 So, let's dive in and understand how this is happening. 296 00:29:36,520 --> 00:29:45,600 Most Microsoft Office applications load the MSO DLL, which is a core component used by multiple Office applications. 297 00:29:45,640 --> 00:29:51,680 The DLL contains essential functionalities that is split between multiple DLLs. 298 00:29:51,680 --> 00:29:53,780 Some of them are presented. 299 00:29:53,900 --> 00: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. 300 00:30:04,840 --> 00: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. 301 00:30:20,300 --> 00: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. 302 00:30:35,820 --> 00:30:39,560 The target parameter is passed to MKParseDisplayName. 303 00:30:39,580 --> 00:30:43,560 Now, you might be wondering what is wrong with MKParseDisplayName. 304 00:30:43,560 --> 00:30:45,140 We'll get it in a second. 305 00:30:45,140 --> 00:30:48,000 But before that, take a look at the second paragraph. 306 00:30:48,120 --> 00: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. 307 00:31:03,040 --> 00:31:09,840 And if it implements the iMoniker interface, it can in turn run unexpected code. 308 00:31:10,700 --> 00:31:12,560 And it doesn't stop just there. 309 00:31:12,560 --> 00: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. 310 00:31:26,220 --> 00:31:32,920 And it can lead to some moniker implementations to act on the string during the parsing of it. 311 00:31:34,200 --> 00: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, 312 00:31:59,940 --> 00:32:04,980 of course, composite monikers instead of creating a file moniker. 313 00:32:05,100 --> 00: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. 314 00:32:23,660 --> 00: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. 315 00:32:32,460 --> 00: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. 316 00:32:47,540 --> 00:32:51,580 Now, this behavior leads to two significant issues. 317 00:32:51,580 --> 00: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. 318 00:33:08,800 --> 00: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. 319 00:33:25,660 --> 00: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. 320 00:33:36,040 --> 00:33:43,820 Surprisingly or not, they use hooks which are installed from the ineditors function within the MSODLL. 321 00:33:43,840 --> 00: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. 322 00:33:58,180 --> 00:34:02,520 Well, this technique kind of reminds us hot-patching, right? 323 00:34:02,820 --> 00: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. 324 00:34:19,040 --> 00: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. 325 00:34:31,460 --> 00: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. 326 00:34:49,060 --> 00:34:53,000 Now you might be wondering where that flag is being set. 327 00:34:53,000 --> 00:34:57,420 If you recall, the MSOHRLink createFromString. 328 00:34:57,660 --> 00: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. 329 00:35:11,560 --> 00:35:17,720 Looking at the patch analysis, a few questions come to mind. 330 00:35:17,720 --> 00:35:22,240 Well, I'm sure that some of you are already asking yourselves these questions. 331 00:35:22,240 --> 00:35:30,270 Well, the whole hyperlink creation goes through the MSOHRLink createFromString, where that flag was being set to true. 332 00:35:31,100 --> 00:35:38,060 What about other code flows that may reach the unsafe API, the MKParsDisplayName? 333 00:35:39,380 --> 00:35:42,800 What about the application ID? 334 00:35:42,800 --> 00:35:46,000 We've seen comparison to outlook only. 335 00:35:46,000 --> 00:35:48,160 What about other apps? 336 00:35:48,960 --> 00:35:53,180 To answer these questions, I want to do a quick recap. 337 00:35:53,180 --> 00: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. 338 00:36:06,390 --> 00:36:09,490 And this is how it looks after the patch. 339 00:36:09,890 --> 00: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. 340 00:36:25,330 --> 00: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. 341 00:36:44,030 --> 00: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. 342 00:36:55,010 --> 00:37:01,130 And as a matter of fact, this is how we got to discover the RC vulnerability in Outlook. 343 00:37:02,590 --> 00: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. 344 00:37:13,390 --> 00: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. 345 00:37:37,210 --> 00:37:46,290 Now that we are familiar with how Microsoft patches some vulnerabilities in Office applications, the patch is quite obvious, right? 346 00:37:46,290 --> 00: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. 347 00:37:58,310 --> 00: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. 348 00:38:26,610 --> 00:38:30,850 Okay, just some additional notes. 349 00:38:31,010 --> 00: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. 350 00:38:43,150 --> 00:38:45,730 It didn't solve the NTLM leak. 351 00:38:45,730 --> 00: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, 352 00:39:05,870 --> 00:39:09,450 if the sender is not trusted, and they are right. 353 00:39:09,450 --> 00: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, 354 00:39:28,570 --> 00: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. 355 00:39:38,270 --> 00:39:41,910 So let's just finalize. 356 00:39:41,910 --> 00:39:43,890 We have a couple of minutes left. 357 00:39:43,890 --> 00:39:45,430 Some recommendations. 358 00:39:46,270 --> 00:39:48,310 Some of them are obvious. 359 00:39:48,310 --> 00:39:52,530 Microsoft basically writes a lot about some of the recommendations. 360 00:39:52,530 --> 00: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. 361 00:40:05,050 --> 00:40:09,610 I suppose it will not hold for long due to backward compatibilities, etc. 362 00:40:10,310 --> 00:40:15,650 Definitely enable SMB signing and manage your outbound SMB. 363 00:40:15,650 --> 00:40:21,250 You don't want that kind of, let's say, network communication going outside of your organization. 364 00:40:21,450 --> 00:40:25,950 And there are definitely additional recommendations that can follow. 365 00:40:26,150 --> 00:40:32,090 Now, just before we kind of end the presentation, some credit references. 366 00:40:32,090 --> 00:40:37,110 Again, as we mentioned, NetSpy is doing great work discovering new stuff. 367 00:40:37,710 --> 00:40:39,530 Checkpoint also, as well. 368 00:40:39,530 --> 00:40:41,810 And so is Etienne Stevens. 369 00:40:41,810 --> 00:40:46,730 I'm sure I'm missing a lot of other folks because a lot of work is being invested. 370 00:40:46,770 --> 00:40:49,510 You guys are welcome to ask our questions. 371 00:40:49,870 --> 00:40:54,850 We will be waiting here behind the entry door for like 10 minutes. 372 00:40:54,870 --> 00:40:58,110 But overall, we are done. 373 00:40:58,410 --> 00:41:00,930 It's an honor to present at the DEF CON. 374 00:41:00,930 --> 00:41:05,710 We are thanking you to come here to see our presentation. 375 00:41:05,710 --> 00:41:06,730 Thank you very much.