start	end	text
1910	4410	Hey, good evening to everyone.
4970	6050	Okay.
10490	13430	Thank you. Thank you, thank you.
13430	17950	Okay, so what do you expect from patches?
18030	19570	Security updates.
19830	23050	You expect them to be a Fort Knox security update, right?
23050	26890	That solves fully the vulnerability, all the control flows.
26970	28410	Is it really?
29690	32670	In reality, this is what we usually get.
33830	34950	Yep.
35210	39870	So we've all been there, expecting that one patch solves it all, right?
39870	46730	But essentially it's kind of a patch to a bullet, or there's a better phrase for that.
46810	54030	We will be sharing insights about what happens when the patch does not quite do the trick.
54450	57650	And sometimes you also find new vulnerabilities.
57790	62310	So this talk will be sharing new details about vulnerabilities that we discovered.
62310	65330	And were patched during June and July.
65710	70070	Those are two out of a bigger number of vulnerabilities.
70490	73770	Let's not be too harsh with the vendors.
73890	76670	There's a reason why this happens many times.
76670	81410	Just a couple of weeks ago, we all saw the mega crash from a CrowdStrike update.
81650	85530	It's not exactly a security update, nevertheless the impact is obvious, right?
85530	87070	Blue screens all over.
87070	92530	And this is exactly the reason why many vendors are kind of trying to solve only the specific problem.
92910	103370	While doing so, also kind of share with us the investigative researchers on additional vulnerabilities that are within the code.
104450	107950	So just very shortly about ourselves.
107950	112350	My name is Michael Gorelick, I'm the chief technology officer and founder of Morphisec.
112650	115970	I have around 20 years of experience in cyber security.
115970	122310	I was the one to discover one of the largest supply chain attacks, the SeaCleaner, in history.
122550	127990	I have a lot of experience in reverse engineering, red teaming and blue teaming.
128150	129830	Go ahead, Arnold.
130330	137090	Hey guys, my name is Arnold. I'm leading the malware research efforts at Morphisec.
137090	145070	And for some time now I'm poking with some patch analysis for fan and profit and product, of course.
146150	147610	Thanks, Arnold.
149310	150470	Okay.
150890	153550	So just starting with a disclaimer.
153850	156490	With great power comes greater responsibility.
156550	158810	Use your powers for the good.
160950	162910	So now about the talk itself.
162910	164650	A bit about the motivation.
164650	173350	Some of our work that we're doing in Morphisec, we are going and reviewing the most critical vulnerabilities that exist,
173350	176310	especially those that lead to remote code executions.
176390	183290	The latest vulnerabilities that we were reviewing were ones that were discovered by the NetSpy group,
183290	187820	done an amazing work on the form injection category,
188210	192650	basically a category of vulnerabilities that lead to remote code execution,
192650	196670	but do require authentication, prior authentication.
196770	201750	Additional category that Arnold will be sharing is about compound monikers,
201750	204350	also lead to remote code execution.
204630	210770	Checkpoint done a great research and a great work discovering some vulnerabilities during the year.
210770	214210	We will also show how the patch doesn't really do the trick,
214210	218350	and how we discovered additional vulnerabilities by purely looking at the patch.
220190	223610	Okay, so let's start talking about the forms.
224250	227930	I mean, every of those categories can go a full lecture,
227930	232190	so we'll be kind of covering very quickly on the introduction,
232190	239210	but you are welcome to see additional details and documentation again on the internet.
239570	246110	So forms, exactly as you would see, you get a message, you're sending a message,
246110	247950	it's eventually based on forms.
247950	252530	Now, message, email message is not the only thing that is based on forms.
252530	256210	Essentially, there is quite a significant mechanism that works behind,
256610	261190	and imagine you are sending a recall message on the message that you sent to your boss.
261190	264830	What happens behind? What happens when recall being sent?
264930	272090	So essentially, it's something there activates and starts to delete the email from the inboxes of your manager.
272490	277450	It's a rendering mechanism that is based on, again, the synchronization of forms,
277450	284610	and we'll be covering that, and we'll share, basically, how we utilize that to inject malicious forms.
284790	292770	We'll get back to recall in the coming slides, but let's first talk a bit about forms and custom forms.
293270	297610	So forms, overall, can be of two different types.
297610	301630	Now, if you integrate the developer mode in Outlook,
301630	308650	you can see that you can modify existing forms into your own kind of purpose.
308710	314210	So if you get a nice message, maybe you want to add some button there or some sound,
314210	318550	you can definitely do that and even change the structure of the forms
318550	325330	by basically opening the built-in Microsoft Form and starting moving stuff.
325390	329570	Now, we will not be talking about that because we are looking into injecting full form,
329570	332790	but this is one of the ways to create the form.
333070	337070	We'll talk about the creation of the form in the next slide.
337170	343630	What is outside of the scope of this presentation is talking about visual basic execution within the form.
343630	347010	It was well covered by Etienne Stevens.
347010	350950	He done a lot of research in 2017, a lot of presentations.
350950	353870	You are welcome to check them out.
353870	361390	Microsoft introduced a lot of hardening to avoid the default execution of visual basic inside forms.
361390	363770	So this is outside of the scope.
365070	370090	Okay, so I already mentioned that we have one way to create a custom form.
370090	373590	This one way is by modifying existing built-in forms.
373590	376990	But what is interesting for us in this category of form injection
376990	381010	is the way you can programmatically create new forms.
381010	386410	If you look at the documentation of Microsoft, this is actually a snapshot from Microsoft documentation.
386670	392870	There is a way to create your own form by basically generating a configuration file called CFG.
393070	398930	Within this configuration file, you basically define the different properties of the same form that you see,
398930	402050	like a message or appointment or calendar, it's all forms.
402610	405930	And you can also specify a form server.
405930	409470	In this case, you see the example is helpdesk.exe.
409470	412090	That is responsible to render the form.
412090	416970	So upon receiving that message in your Outlook, you want to do something about that.
416970	421870	This is the executable that eventually spawned and does something about that.
421870	424290	And we will share a couple of examples.
424410	426130	Now, it doesn't have to be executable.
426130	430250	You can use a different DLL or any other ways.
430250	432230	We'll share that as well.
432430	437470	But again, there is a very nice way to run that form.
437470	445490	Now, we'll not get into too much details about the whole mechanism of forms because we don't have enough time.
445670	453110	Nevertheless, it's important to understand one of the most interesting things in forms is the synchronization mechanism.
453190	459350	So exactly like you would open a draft email and it suddenly exists in all your clients,
459350	466290	behind them there is a mechanism that basically synchronizes all those forms across the different clients through the Exchange server.
466290	469310	This is not the only thing that obviously synchronizes.
469310	478550	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.
478630	483330	Now, the mechanism involves form libraries that represent properties.
483330	486750	It will also include form servers, etc.
487110	492850	And there's also important to understand that not all forms are synchronized.
492850	499630	If you put your form into a personal library, it will not be synchronized across the different clients.
499630	507150	But if you, for example, install it in the inbox, it will definitely be synced by the Microsoft protocol.
509070	513710	So shortly, how forms are loading and registered.
513710	519870	So if you take, in this example, a simple built-in modified form, this is not a programmatically created form.
519870	522410	Nevertheless, it's the same mechanism.
522890	532710	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.
532890	539830	But you will find a lot of those class IDs, and each class ID, many of those class IDs basically represent the different forms.
539830	549970	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.
550190	560130	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.
560190	566650	And the built-in forms are saved within the program files office, also special folder there.
566650	577630	Essentially, those form libraries are comb objects, and those can be rendered and instantiated like any other comb.
578210	586450	As we said, the original kind of oily form library is a bit outside of the scope of this lecture.
586450	600610	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.
600970	607770	But we will be talking about programmatically created forms through the configuration files.
607770	619750	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.
619750	625150	You can go to this specified directory and find those CFG files.
625170	629670	Now, you identify that there is a special file called a React CFG.
629670	633230	This is an example of the recall message form.
633230	643690	You see also that the CFG itself also includes the rendering file, the recall.dll, basically instantiated automatically through the InProc server 32.
644210	652530	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.
652530	661430	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.
661430	667390	It basically starts to delete from your inbox the message that you want to remove.
667930	679490	So we want to achieve the same thing. 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.
679610	680950	But can we do that?
682910	688190	Here is an example again from this recall call, which is a column object.
688350	689750	But can we do that?
689750	700210	Well, not exactly. There is a special mechanism that bypasses Outlook.
700290	702390	And by default, it's disabled.
702390	706790	Now, if it would be enabled, you can definitely define such a CFG.
706810	711470	You can load it, and then you have a form automatically synchronized to your victim environment.
711610	717470	And you can send a special message that will trigger the initiation of the form.
717470	725870	But if this flag is basically disabled, which is by default, your form goes through a special matching algorithm,
725870	731770	which validates that you are not using special keywords like inprox server, local handler,
731770	741310	which basically automatically instantiate those com objects or those malicious dlls or executables that are put in this folder.
741310	745410	Now, one of the problems with this matching algorithm is...
745410	746730	Wow, it's noisy.
747450	752730	So one of the problems with this matching algorithm is that it is an exact matching.
752730	754850	It checks for an exact words.
754850	761010	Not less, not more, but an exact words within the keys that are specified in the configuration file.
761990	771410	So somehow we lead basically to the first vulnerability that was discovered by NetSpy, which has done amazing work.
771410	777430	They introduced into this registry file an additional relative path.
777430	778910	Okay, so basically...
781600	783460	One, one, one.
784060	785500	Okay.
798840	800040	Yeah.
800040	803900	I'm sure the line at the end will hear.
812010	814190	Yeah, yeah, yeah.
815230	816590	That's more.
821130	822110	One.
822110	823110	Okay.
823930	825290	Okay.
825310	827090	So it's kind of a temporary solution.
827290	831210	So I hope we will finish the presentation until then.
831250	833970	But again, it's a great finding.
833970	838230	Basically, the NetSpy group added a relative class ID.
838450	848290	And it's also documented in Microsoft documentation that they clearly say that you can provide a relative path for your form server rendering.
848650	850410	And they added that.
850410	865910	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.
865910	881690	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.
881690	883770	But this property is less interesting for us.
883770	886690	It was nicely patched by Microsoft.
886790	891370	But I will be talking specifically about the bypass algorithm.
891790	893550	So now is the interesting part.
893550	900470	How Microsoft patched that vulnerability and what led us basically to discover new vulnerabilities following that patch.
900550	909010	So as we see in the patch that was introduced by Microsoft, Microsoft said, okay, you have a problem with the relative path.
909010	910510	Let's remove relative path.
910510	912710	They didn't update the documentation yet.
912950	915710	But they basically removed that functionality.
915710	919970	You cannot put a backslash anymore in the property of the form.
919970	921410	So great.
921410	921850	Okay.
921850	923070	It solved the problem.
923070	925330	But they didn't change the matching algorithm.
925330	927130	The algorithm is still the same.
927490	938790	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.
940290	944270	So I have to commend to Microsoft because they have done it quite quickly.
944270	946530	We reported it in April.
946970	948770	They patched it in June.
949170	951110	So nice work.
952410	963730	But, again, before we are diving into how we created additional control flow, we need to understand how a Windows core API function works.
963850	974250	Now, when you basically register a form, it goes through a process in which they use recreate XA function.
974250	977310	It's also utilized in most of the applications today.
977310	980970	It's one of the most popular functions that exist today.
980970	991730	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.
992130	994990	Now, I think it's limited to 32 keys.
994990	1005270	So if you are basically using that function with 31 backslashes, it will create a nested directory structure automatically.
1005690	1015010	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.
1015010	1018250	It's correct to any recreate XA.
1018310	1026810	And this will be probably interesting to investigate other applications that may be vulnerable due to the same reason.
1027370	1033470	So as you would probably guess, we just added this backslash at the end.
1033670	1042130	So as soon as you add the backslash at the end, obviously, it goes through the matching algorithm, which does the exact matching.
1042130	1046090	It goes through because, again, we have the backslash.
1046090	1053550	And when the reg X creates the registry, it removes the trailing backslash.
1053550	1063290	And voila, you have a fully executing form written automatically, synchronized by Microsoft to any of the victim environments.
1063330	1066290	And what do we need to basically execute that?
1066290	1070810	Just to send the message, a simple email with the message class of that form.
1072390	1076310	So very quickly, just a demonstration.
1077190	1078750	Let's see.
1081220	1082740	Okay.
1086500	1089380	I hope you see the video.
1089640	1092100	So in this video, we will... no?
1093060	1094240	Okay.
1094240	1095820	It's a problem.
1100480	1103780	Maybe we can push it here.
1103980	1104780	Okay.
1104780	1106700	Ah, solution.
1106700	1109280	So we'll try to do a play like that.
1109800	1111540	Maybe this works.
1112300	1113340	Okay.
1113560	1114400	Remotely.
1114600	1115880	Nice.
1116000	1116580	Okay.
1116580	1120520	So essentially we are working here on outdated outlook.
1120520	1126640	This was recorded in June, just before the patch was introduced by Microsoft.
1126640	1139520	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.
1139520	1141080	We didn't have to use that.
1141080	1147840	We just could open a client in our environment, use the credentials, and create the same form.
1147840	1152220	Here we are utilizing and creating the property with the backslash.
1152220	1167920	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.
1168720	1176860	So in the next step, as soon as it will be sent, we will see that the form suddenly appeared on the victim environment.
1176860	1181120	It takes a bit... a couple of seconds.
1181120	1182160	Okay.
1183700	1184740	Good.
1187200	1188140	Okay.
1188140	1189620	So here we receive the message.
1189620	1191800	We're still not opening that message.
1191860	1201440	The opening of the message will instantiate the execution of the form, but the form was already written, synchronized into the folder.
1201440	1204620	So this is a way in which you can also use the advanced button.
1204620	1210920	You can check out the forms, or you can simply go to the folder of the forms and identify it was written.
1210920	1216640	As soon as I open that, the form server is executed.
1216640	1220600	As you see, it's executed within the context of the Outlook process.
1221060	1231240	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.
1231580	1234320	Now we need to pull it back somehow.
1235740	1236460	Huh?
1237920	1240700	No, maybe I just closed it.
1240700	1241780	Oh, okay.
1242980	1244100	Okay.
1245720	1247120	Okay, good.
1247140	1255220	So this was a very nice demonstration for a form, but again, it's assumed that we have authentication beforehand.
1255220	1263520	We will show later on how easy we can get the authentication, the tokens from the environment and have a full RC, non-authenticated.
1263520	1268120	But again, in this case, we do require the credentials of the victim.
1269560	1270880	Let's continue.
1272180	1275100	Okay, so what do we have here?
1275100	1277080	We have a patch to this vulnerability.
1277300	1285160	Now, it's interesting because we just bypassed one patch, and this patch was introduced to solve the vulnerability that we discovered.
1285320	1292980	Now, if you look at the patch, again, for those that are reversing here, it's probably more clear.
1292980	1298260	But essentially, they didn't change the function that checks for the exact strings.
1298260	1302260	They just decided to remove the trailing backslashes.
1302260	1308740	So basically, they introduced additional loop that goes over the key and removes all the trailing backslashes,
1308740	1315060	and then continue with the same exact matching algorithm instead of looking for a contain, et cetera.
1315060	1321640	So I definitely welcome you guys to check out what additional control flows you can find out.
1321640	1323660	And maybe you will.
1324720	1326760	But it's not all.
1326760	1333980	When they introduced that patch, they also introduced additional extension for the blocking list.
1333980	1340620	Now, it's also interesting, those that identify those special key attributes,
1340620	1350420	those key allows hijacking and execution of additional comments or com hijacking, et cetera.
1350420	1354880	So definitely an interesting additional path to investigate.
1354880	1361260	This just shows that there were additional vulnerabilities in place that could be utilized by an adversary.
1362640	1371220	Okay, so just to put things in the right order, there are more vulnerabilities that were discovered.
1371440	1377440	Next week, there will be a patch for additional vulnerabilities.
1377440	1382380	I suppose we will share the details somewhere a month or two months after,
1382380	1386860	but we do recommend you to patch your Outlook clients because it's not very difficult.
1386860	1388600	The exploit is very trivial.
1390460	1399060	Now, again, form injection is nice for remote code execution, but it's not the only way to utilize that type of vulnerabilities.
1399400	1402240	Now, we can obviously do a persistency with that.
1402240	1404220	We can also escalate privileges.
1405000	1412600	If you, for example, hijack the credentials of an Exchange admin, we can propagate the same forms across all the inboxes
1412600	1417540	and do much more damage than just a simple victim.
1419420	1425320	So let's talk for a second about the other part which is missing, the authentication.
1425320	1431680	Now, I'm talking about authentication only in two slides,
1431680	1437820	but there is a nice presentation tomorrow by someone else that is only talking about NTLM,
1437820	1441440	and I trust that it will be a great presentation.
1441660	1446020	But NTLM is essentially, or anti-hash if you would say,
1446020	1453060	if you would, for example, send an email and send a link to a file,
1453060	1456220	and the victim will double-click on those links.
1456340	1465880	Behind that, there will be an SMB protocol that will require basically a challenge response algorithm that will require authentication.
1466240	1473620	And if you are by default not doing a Kerberos authentication, a rogue server will take your anti-hash automatically,
1473620	1477660	and the file doesn't have to exist there, just you pressing the link.
1477660	1484660	But aside of that, there were a lot of vulnerabilities that were discovered in 2023 and 2024.
1484760	1492260	It was, I think, one of the significant years for NTLM leaks all across with zero clicks.
1492260	1497280	So you didn't need to press or get a warning that there is an SMB file,
1497280	1504720	you just needed to have an appointment reminder that is sent with a nice kind of link to a sound
1504720	1508700	that will be sound when the appointment is being sent,
1508700	1514080	or some kind of Windows performance analyzer that is being directed,
1514080	1518100	and all kinds of additional exploits that lead to the same NTLM leak.
1518100	1521240	So it's not very difficult to get NTLM leaks.
1521280	1525940	We'll get into a recommendation how it can be blocked going forward.
1526020	1528480	But one of them is interesting.
1528480	1534980	The last one, especially NTLM leaks that are led through execution of monikers,
1534980	1536440	so compound monikers.
1536440	1539520	And this is a great time to move to Arnold,
1539520	1546020	which will be talking about compound monikers that lead to remote code executions and NTLM.
1547600	1549900	Okay, then. Thank you, Michael.
1552590	1558990	So before we dive into the next RCE vulnerability we discovered in Outlook,
1558990	1563830	we first need to get at least some high-level understanding of what monikers are.
1563830	1567430	And I highly encourage you to dig deeper into the subject,
1567430	1573010	as multiple vulnerabilities in Outlook involve monikers in Office applications,
1573010	1575930	involve monikers in some way or another.
1576110	1582630	Now, actually we are all using monikers with our daily work with Office applications.
1582630	1585770	One example is when you try to send an email,
1585770	1592230	and in the body of that email you attach an Excel chart as a link.
1592490	1597110	Well, a moniker is used to point to that specific Excel chart using a string
1597110	1601850	understood by the moniker mechanism and the monikers involved.
1602010	1607430	Now, the general idea of a moniker is to provide you with some way to locate
1607430	1611710	and identify this specific com object using strings
1611710	1617190	or instead of writing a custom mechanism to do that.
1617190	1623450	And in order to achieve it, all monikers must implement the IMoniker interface.
1623730	1630430	Well, Microsoft actually provides several implementations of monikers,
1630430	1635980	some of them related to the OLE objects and most notably used in Office applications.
1635980	1644160	Some of these monikers include the FileMoniker, ItemMoniker, URLMoniker and a few more.
1645680	1652480	One additional example is using the getObject method within the Visual Basic Programming Language
1652480	1656680	or its Windows API equivalent, the call getObject.
1656680	1663980	This is basically a helper function that simplifies the way of converting the moniker string,
1663980	1669000	the display name, into a moniker and then binding to that named object.
1669000	1674940	Now, it does that by encapsulating calls to the com library functions, the createBind,
1675640	1678200	mkParseDisplayName and bindToObject.
1679460	1682880	Okay, so moving back to Outlook.
1682880	1688700	Imagine receiving an email with hyperlink points to a file located on an SMB share.
1688700	1695160	If you would click on that file or on that link, you won't get a pop-up notification
1695160	1698720	asking whether you are sure you want to click on that link.
1698720	1702660	Clicking on links from untrusted sources can do this and that.
1703020	1707600	Instead, a warning message is displayed in the Windows Notification Center
1707600	1711620	stating that something unexpected went wrong with the URL
1711620	1716480	and the file on that SMB share would never be accessed.
1716480	1718640	We would expect that to be good, right?
1718640	1724380	So, if the file would have been accessed, at least the local NTLM credentials would have been leaked
1724380	1727920	as accessing the file would go through the SMB protocol
1728480	1733280	which relies on the local NTLM credentials to authenticate.
1735180	1740860	Well, earlier this year, Checkpoint Researcher found a vulnerability in Outlook
1740860	1745000	that bypasses that warning message by simply adding an exclamation mark
1745000	1747840	at the end of that link.
1747960	1755340	Apparently, this turns the hyperlink from a simple hyperlink that points to a file moniker
1756000	1762320	into a generic composite moniker that is composed from a file moniker and an item moniker.
1762400	1766140	Clicking on such a link results in accessing the file,
1766140	1771680	leaking the local NTLM credentials, and potentially allow for remote code execution.
1772500	1776500	So, let's dive in and understand how this is happening.
1776520	1780840	Most Microsoft Office applications load the MSO DLL,
1780840	1785600	which is a core component used by multiple Office applications.
1785640	1791680	The DLL contains essential functionalities that is split between multiple DLLs.
1791680	1793780	Some of them are presented.
1793900	1801040	The one we are interested with the vulnerability discovered by Checkpoint is the MSO-30 DLL,
1801040	1804840	which handles things related to links and links parsing.
1804840	1809160	And to be more specific, the MSO HRLinkCreateFromString function
1809160	1812940	that is a wrapper for HLinkCreateFromString
1812940	1820260	that basically creates hyperlink objects from strings that represent the hyperlink target.
1820300	1825200	If you would look at the documentation for HLinkCreateFromString,
1825200	1829220	we see that it starts with a security warning that states,
1829220	1835820	never parse strings from a non-trusted source when creating hyperlinks with HLinkCreateFromString.
1835820	1839560	The target parameter is passed to MKParseDisplayName.
1839580	1843560	Now, you might be wondering what is wrong with MKParseDisplayName.
1843560	1845140	We'll get it in a second.
1845140	1848000	But before that, take a look at the second paragraph.
1848120	1852380	You can see that it is mentioned that if a string of the form suggested
1852380	1857640	in the checkpoints vulnerability at composite moniker is passed,
1857640	1862720	it will instantiate the object registered with the specific prog ID.
1863040	1869840	And if it implements the iMoniker interface, it can in turn run unexpected code.
1870700	1872560	And it doesn't stop just there.
1872560	1877180	Looking at the documentation for MKParseDisplayName,
1877180	1881460	we see that it states that calling MKParseDisplayName
1881460	1886220	with a display name parameter from an untrusted source is unsafe.
1886220	1892920	And it can lead to some moniker implementations to act on the string during the parsing of it.
1894200	1899100	Well, if you take a closer look at how it happens in the code,
1899100	1905820	we see that when there is a character indicated that the string is a composite moniker,
1905820	1912740	and by the way, not only by the exclamation mark, but also the opening square bracket and colon,
1912740	1918780	the parsing of that composite moniker would go through the MKParseDisplayName
1918780	1924980	for handling with, of course, composite monikers instead of creating a file moniker.
1925100	1932020	Now, when MKParseDisplayName is called, it will call the bindToObject method,
1932020	1936380	which eventually involves the relevant com object,
1936380	1943660	responsible for handling with the specific file type pointed to by the file moniker.
1943660	1948060	For instance, if the file pointed to by the file moniker is an RTF,
1948540	1952460	WinWord will be spawned in the background without displaying the UI.
1952460	1956540	It will access the file pointed to by the file moniker,
1956540	1964820	and will try to access the object pointed to by the item moniker.
1967540	1971580	Now, this behavior leads to two significant issues.
1971580	1977900	First, the file is being accessed, so we have an NTLM credential leak,
1977900	1980280	and second, the file is being parsed,
1980280	1988500	so any RCE involved in the parsing routine can be chained to gain full RCE.
1988800	1994800	Now, one important note I want to point is that characters other than the exclamation mark
1994800	1996570	can trigger this vulnerability,
1997080	2001900	and it's important from a detection and prevention standpoint,
2001900	2004420	as it wasn't mentioned anywhere else.
2005660	2010060	Now, before we dive into the patch analysis and how we bypassed it,
2010060	2016040	we first need to understand how Microsoft patches some vulnerabilities in Office applications.
2016040	2023820	Surprisingly or not, they use hooks which are installed from the ineditors function within the MSODLL.
2023840	2029080	Apparently, each Office application has its own application ID,
2029080	2038180	and before the hook is installed, the ineditors function checks that the current process has a valid application ID.
2038180	2042520	Well, this technique kind of reminds us hot-patching, right?
2042820	2050300	Pinpointing a specific API in a specific location only by specific processes,
2050700	2057340	as well, these APIs are being used system-wide across many other applications.
2059040	2061960	Now, moving on to the patch itself,
2061960	2069940	as you can see, Microsoft updated the ineditors function to add hooks for the MKParsDisplayName APIs.
2071460	2079000	The hook simply checks if a flag named block MKParsDisplayName on current thread is set to true,
2079000	2084600	and if that's the case, as the name suggests, MKParsDisplayName would not be invoked,
2084600	2087260	and it will return an error instead.
2089060	2093000	Now you might be wondering where that flag is being set.
2093000	2097420	If you recall, the MSOHRLink createFromString.
2097660	2101480	responsible for creating hyperlink objects from strings,
2101480	2105300	sets the flag to true at the beginning of the function,
2105300	2110000	and it only does that if the application ID equals outlook.
2111560	2117720	Looking at the patch analysis, a few questions come to mind.
2117720	2122240	Well, I'm sure that some of you are already asking yourselves these questions.
2122240	2127800	Well, the whole hyperlink creation goes through the MSOHRLink createFromString,
2127800	2130270	where that flag was being set to true.
2131100	2138060	What about other code flows that may reach the unsafe API, the MKParsDisplayName?
2139380	2146000	What about the application ID? We've seen comparison to outlook only.
2146000	2148160	What about other apps?
2148960	2153180	To answer these questions, I want to do a quick recap.
2153180	2156680	The following diagram demonstrates the interesting API calls
2156680	2162440	when clicking on a composite moniker hyperlink within an email,
2162440	2165270	before the patch was employed.
2166390	2169490	And this is how it looks after the patch.
2169890	2173970	We have the addition of the block MKParsDisplayName flag
2173970	2178410	that is being set to true at the beginning, as we said,
2178410	2183590	and the detoured function checks that flag and acts accordingly.
2185330	2192590	We were looking for ways to get to the unsafe API, the MKParsDisplayName,
2192590	2198390	without going through the function that sets that flag to true,
2198390	2203570	and we found a candidate, the hrpmon from URL.
2204030	2209850	We found that doing some cross-referencing through the relevant API calls,
2210130	2214370	and we've seen that this one may reach the unsafe API.
2215010	2221130	And as a matter of fact, this is how we got to discover the RC vulnerability in Outlook.
2222590	2226690	When you pass a composite moniker within an image tag,
2226690	2233390	the parsing of that composite moniker won't go through the mso-hrlink-reform string that was patched.
2233390	2243330	Instead, it will invoke the hrpmon from URL that handles the parsing of the URLs from image tags,
2243330	2247450	and it will directly call the hlink-parsDisplayName
2247450	2256310	that will eventually get the same code flow that reaches to the unsafe API, MKParsDisplayName.
2257210	2263850	Now that we are familiar with how Microsoft patches some vulnerabilities in Office applications,
2263850	2266290	the patch is quite obvious, right?
2266290	2272630	Setting the infamous flag to true, but this time from hrpmon from URL,
2272630	2277830	and again, only if the application ID equals Outlook.
2278310	2284530	Now, to sum up these two patches, we saw that Microsoft only addresses specific code flows
2284530	2292310	and specific scenarios that leads to the unsafe API, the MKParsDisplayName,
2292310	2295650	and we left some questions open for you to investigate,
2295650	2303790	and we are certain that there are more applications and more code flows that leads to that unsafe API.
2306610	2310850	Okay, just some additional notes.
2311010	2313790	As Arnold shared, and thank you, Arnold,
2313790	2319290	Microsoft patched the remote code execution by introducing this additional hook
2319290	2323150	and turning on the flag through this control flow.
2323150	2325730	It didn't solve the NTLM leak.
2325730	2330570	Now, we obviously didn't want to publish it, but we got a response from Microsoft
2330570	2337770	that there is a medium risk, and for Microsoft it's not an urgency,
2337770	2342590	and the fact that the image cannot be automatically downloaded
2343670	2345870	because you have kind of a preview mode,
2345870	2349450	if the sender is not trusted, and they are right.
2349450	2353390	If the sender is not trusted, the image will not be automatically downloaded,
2353390	2356510	and the compound moniker will not be automatically executed,
2356950	2363470	but if the sender is trusted, again, someone in the organization, let's say, was compromised,
2363470	2368570	and you're utilizing his credential to send to the other victim within the same organization,
2368570	2373410	the same link, the image will be automatically downloaded or previewed,
2373410	2378270	and the NTLM will happen, and this unfortunately wasn't patched.
2378270	2383890	So let's just finalize. We have a couple of minutes left.
2383890	2388310	Some recommendations. Some of them are obvious.
2388310	2392530	Microsoft basically writes a lot about some of the recommendations.
2392530	2398430	Obviously, in four scare bureaus, Windows 11 introduces, I think, an update,
2398430	2405050	already introduced update, in which by default NTLM authentication will not be possible.
2405050	2409610	I suppose it will not hold for long due to backward compatibilities, etc.
2410310	2415650	Definitely enable SMB signing and manage your outbound SMB.
2415650	2421250	You don't want that kind of, let's say, network communication going outside of your organization.
2421450	2425950	And there are definitely additional recommendations that can follow.
2426150	2432090	Now, just before we kind of end the presentation, some credit references.
2432090	2437110	Again, as we mentioned, NetSpy is doing great work discovering new stuff.
2437710	2441810	Checkpoint also, as well. And so is Etienne Stevens.
2441810	2446730	I'm sure I'm missing a lot of other folks because a lot of work is being invested.
2446770	2449510	You guys are welcome to ask our questions.
2449870	2454850	We will be waiting here behind the entry door for like 10 minutes.
2454870	2458110	But overall, we are done.
2458410	2460930	It's an honor to present at the DEF CON.
2460930	2465710	We are thanking you to come here to see our presentation.
2465710	2466730	Thank you very much.
