[00:02.650 --> 00:25.720] I can start? Okay. It's good to be here. I'm Wang Junjie Zhang. I'm a security researcher from [00:25.720 --> 00:33.460] the Hearthstone Networks. My research direction is Windows vulnerability research including [00:33.460 --> 00:41.060] user mode and kernel mode. And also I've been listed as the most valuable researcher of the [00:41.060 --> 00:56.380] Microsoft 2020, 2022, and 2023, 2024. Yeah. Okay. So, let's just start my talk. And this is, [00:56.380 --> 01:03.440] I already introduced myself and our colleague here. So, I'm Wang Junjie Zhang. I'm a [01:03.460 --> 01:08.420] researcher at Microsoft. Um, firstly, let's see our agenda today. It's mainly consists of [01:08.420 --> 01:16.440] four parts. Um, we'll introduce architecture of the LPC and RPC. So, we'll have a deeper [01:16.440 --> 01:24.740] understanding of it. And then look at some, uh, common vulnerabilities inside LPC and RPC. And [01:24.740 --> 01:30.860] we'll study some root cause of the vulnerabilities. And then I will share some details of [01:30.860 --> 01:37.900] the vulnerabilities I found by myself and my team. And which can bypass the LPC, RPC, uh, [01:37.900 --> 01:44.160] security mechanism. Uh, I will show you step-by-step, uh, to use, uh, this small security [01:44.160 --> 01:51.840] flaw to bypass the security mitigations like SDR, DEP, XFG, and finally get system shell. Uh, [01:51.840 --> 02:00.540] you won't get it from anywhere else. So, and that's the way to make a conclusion. Yeah. Uh, [02:00.540 --> 02:09.120] so it's, uh, architecture, yeah. We already know, um, the LPC, uh, was introduced, uh, to [02:09.120 --> 02:16.900] replace the ARPC. Uh, it's called, uh, Lightweight, Lightweight Procedure Core, uh, mainly [02:16.900 --> 02:24.400] used in, uh, Windows system, uh, inside, uh, Windows system services. Uh, and it's, uh, [02:24.400 --> 02:30.520] concerned by many researchers for each, it's huge attack service. Uh, so it's, uh, [02:30.540 --> 02:39.800] based on the ARPC. And this is, uh, uh, uh, ARPC and RPC architecture. And why we [02:39.800 --> 02:51.240] combine the ARPC and RPC together? Uh, why we combine, uh, it's together? For reason [02:51.240 --> 02:57.320] listed below, uh, most, uh, RPC services is based on the ARPC or NAND pipe. So it's [02:57.320 --> 03:03.060] almost, uh, based on the same, uh, security mechanism. And the security flaw inside [03:03.060 --> 03:10.820] the, uh, ARPC can affect the security of RPC services. And this is, uh, also the [03:10.820 --> 03:15.540] architecture of the ARPC, RPC from, uh, Windows internal. Uh, you can communicate, [03:15.540 --> 03:21.200] this, uh, see the communication module inside it. And it's also support some, uh, [03:21.200 --> 03:26.680] message queries and some share section. Uh, also, uh, support share section to pass [03:26.680 --> 03:36.820] the message. Uh, why we use, uh, section here? Uh, because it's a more effective, uh, [03:36.820 --> 03:41.860] data passing mechanism on Windows, uh, section object. Uh, more efficient and fast. [03:41.860 --> 03:46.920] And, uh, what about the region? Uh, why region is, uh, represent a range of the shared [03:46.920 --> 03:52.220] memory that can be opened within the context of a given port. Uh, the section can be [03:52.220 --> 03:58.400] shared, uh, accessed by one process, uh, which only have a right access. And meanwhile, [03:58.400 --> 04:04.400] uh, the client only have the right access. Uh, this picture, uh, describe the relationship [04:04.400 --> 04:11.260] between the section. Yeah. We can split up the whole section into, uh, different region. Uh, [04:11.260 --> 04:18.140] one piece is represented by, uh, one region object. Uh, we have a set, uh, size, uh, [04:18.140 --> 04:25.480] which is representing the map of the set and the size of the set section. Yeah. Uh, I see [04:25.480 --> 04:33.760] some, uh, historical vulnerabilities. Yeah. Um, first kind of bug is, uh, kind of logical [04:33.760 --> 04:40.440] bug, uh, in ARPC when, uh, you know, there's too much, uh, uh, research, uh, on the [04:40.440 --> 04:47.000] internet. Um, it related to, uh, uh, doing when the service doing some, uh, file [04:47.000 --> 04:52.560] operating, uh, operations. Uh, it's need to, uh, impersonate the colors, uh, token and [04:52.560 --> 04:57.500] doing some, uh, operations on file. Uh, however, you know, sometimes the failure to [04:57.500 --> 05:03.660] properly handle the file operation, uh, with a file, like the symbol link, it may be [05:03.660 --> 05:10.640] resulting the service being able to modify, or write, or delete, and even create, uh, some [05:10.640 --> 05:16.980] files when client should not have the permission, uh, these operations. So, uh, this [05:16.980 --> 05:24.940] vulnerability, uh, CVE 2020 and 0F0911 is an example of the using user's device map, uh, [05:24.940 --> 05:32.540] where impersonating users and the service will operate on malicious, uh, MSAI files, uh, on [05:33.240 --> 05:38.560] the user's device map installer directory, and it will directly, uh, to another path. So, [05:38.560 --> 05:43.720] when the service revert to the system privilege, it also trust the content, uh, to read from [05:43.720 --> 05:50.860] their client installer directory and source, um, the privilege acceleration happen, yeah. [05:53.340 --> 05:59.840] Uh, uh, this kind of bug exploitation have much articles and research, uh, on the internet, uh, [05:59.840 --> 06:05.880] by using tricks of, uh, firstly, uh, I think it's discovered by Google research, uh, [06:05.880 --> 06:11.980] James Fosho, uh, by using tricks like NTFS junctions, uh, higher link or object symbol [06:11.980 --> 06:17.960] links and, uh, opportunities locks, you can easily, uh, write exploitations, uh, on this [06:17.960 --> 06:24.620] kind of bugs. Yeah. Uh, the second, second example is, um, malicious, uh, memory [06:24.620 --> 06:30.900] corruption bug inside LPC, LPC kernel, uh, in recent years. Uh, we have seen a lot of, um, [06:30.900 --> 06:37.360] memory corruption issues inside the LPC, LPC kernel. Uh, so the following code snippet is a [06:37.360 --> 06:42.960] part of the vulnerability and is associated with the LPC section blob object. Uh, when you [06:42.960 --> 06:48.580] create a LPC section, uh, in the map legacy port view function, uh, there's a race window [06:48.580 --> 06:53.880] before the function with, uh, uh, view port, view object. Uh, during this race window, [06:53.880 --> 07:01.980] attacker can, uh, destroy the LPC port object, uh, causing it, uh, LPC create section view [07:01.980 --> 07:10.160] function, uh, access, uh, 3D pointer. The picture describe the, uh, race window, uh, in the [07:10.160 --> 07:16.220] connect port function. Uh, the kernel, kernel creates the first, uh, LPC port and, uh, we can [07:16.220 --> 07:22.720] try to close the handle table in the second thread. Uh, if this moment, close moment, uh, [07:22.720 --> 07:27.680] between the create section and the create view port function, you can get a blue screen. Uh, [07:27.680 --> 07:33.040] but however, this kind of issue is, I think it's a little bit hard to exploit because you need to [07:33.040 --> 07:40.060] win the race first. Uh, what we observe is that most of these, uh, memory corruption bug, uh, [07:40.060 --> 07:46.440] inside LPC kernel or LPC services, and most of them are traditionally memory corruption bug, [07:46.440 --> 07:52.000] bugs, uh, due to the server side lack of check when LPC services, uh, handle data from the [07:52.000 --> 07:57.600] client side. And last example is, uh, I think it's very interesting. Uh, logical [07:57.600 --> 08:03.360] fallback in LPC RPC discovered in 2016-2017. Uh, research found that the kernel doesn't [08:03.360 --> 08:09.600] protect the shared memory privilege, uh, when using it to pass the, uh, m-message data. In [08:09.600 --> 08:15.620] theory, the kernel changes the shared section protection in client sides, uh, to read only, uh, [08:15.620 --> 08:19.900] preventing the client side changing the memory, uh, while server side, uh, calling stop code [08:19.900 --> 08:25.260] that may be cause double fetch loss in server side. Uh, you can use the virtual protect [08:25.260 --> 08:31.160] function to change the shared memory, uh, from read only to write, uh, read write, and [08:31.160 --> 08:37.540] causing data race condition in server side. Uh, it's pretty, uh, predictable, right? Uh, [08:37.540 --> 08:43.040] imagine, uh, we have a, have already have a, uh, RPC function, uh, accepts, uh, string [08:43.040 --> 08:47.920] parameter and print it twice with a sleep, uh, between these two option. Uh, we write a [08:47.920 --> 08:52.640] POC and, uh, send a string and try to call the virtual protect and change the content of the [08:52.640 --> 08:58.920] string. Uh, we can see the server side print two, uh, different, uh, strings. Um, it means [08:58.920 --> 09:04.300] that, uh, we can change the parameter while the server side, uh, perform any other [09:04.300 --> 09:12.060] operation. Although, uh, this vulnerability has been fixed, uh, I decide to learn more from [09:12.060 --> 09:20.080] it. Uh, maybe we can find, uh, more interesting stuff. So, uh, first question is, uh, is [09:20.080 --> 09:31.260] really secure update patch? Yeah, uh, from my, all of the research, uh, result I know, uh, [09:31.260 --> 09:38.800] shared memory is, uh, available for, uh, almost any RPC over LPC services. So I decide to write [09:38.920 --> 09:45.420] a custom RPC service and try to, uh, change the, uh, memory pro-memory protection again. But [09:45.420 --> 09:53.260] finally, uh, get, uh, virtual protect EX error. So, uh, what happened to after the patch? So I [09:53.260 --> 09:59.400] decide to, uh, learn more from the reverse engineering. Uh, first, uh, N2S kernel try to [09:59.400 --> 10:04.020] secure the view of the section. It doesn't allow to change the memory attribute from the user [10:04.020 --> 10:13.080] space. And, uh, secondly, both N2S and RPC RT4 module DLL enable secure mode in mode check. It [10:13.080 --> 10:17.420] means that the server will not manipulate the shared memory, uh, when it detected the shared [10:17.420 --> 10:24.980] memory is unsafe. Uh, this technique, uh, this is a technique that tells, uh, the security [10:24.980 --> 10:32.380] mechanism when handle shared memory from client side. Uh, kernel use map view, secure view of [10:32.380 --> 10:37.540] section function to create a security view. So you secure virtual memory and you can't change, [10:37.540 --> 12:51.820] uh, attribute. And when sending the attribute, uh, sending message to the server, it's check [12:51.820 --> 12:58.340] the RPC section and the region we use to send the message to see if it's safe and the region [12:58.340 --> 13:04.280] can't bind with more than two view objects. It's trying to change the attributes of the shared [13:04.280 --> 13:10.760] memory. The address, uh, to read only. If this step falls, then the server side will be marked [13:10.760 --> 13:18.980] with unsafe and the RPC RT4 dot DLL will use the shared memory to unmasher the, uh, server side. [13:20.000 --> 13:26.340] And this is the code pieces, uh, from the user mode in RPC RT4. Uh, it will acquire the RPC [13:26.340 --> 13:33.100] message attributes, uh, including the security flag of the RPC region. If the region is [13:33.100 --> 13:39.240] unsecure, you can see, uh, it will lock its heap buffer. Uh, it's managed by Pcache object and [13:39.240 --> 13:43.700] copying the shared memory to the heap buffer. So it will not cause double phishing [13:43.700 --> 13:50.980] vulnerability. So when the server decide, uh, detect the region, it's unsafe. Also take a [13:50.980 --> 14:03.080] look at the virtual protect ES function to, uh, see how the kernel patch, uh, the, uh, [14:03.080 --> 14:08.960] special bad event object, uh, to, uh, secure them, mark the bad objects. It's a security view or [14:08.960 --> 14:16.320] not. So we know that Windows kernel use MM bad object to describe one virtual address in, uh, [14:16.320 --> 14:22.040] user space. It's, uh, it's, uh, describe the start and the ending of the virtual page. Uh, when [14:22.040 --> 14:27.820] changing the memory of, uh, production, it will check if the bad event object is, uh, in the [14:34.040 --> 14:41.180] list. Uh, unfortunately, the bad event structure symbol was deleted from Windows 11. Uh, so I [14:41.180 --> 14:47.380] can only use the old symbol from Windows 10. And digging into it, uh, there's two key [14:47.380 --> 14:53.540] function, uh, for address, uh, protection. One is m-i-c-w-i-s-s-l-e protection and the [14:53.540 --> 15:02.020] other is revert m-i-r-e-v-e-r-t function. Uh, this is the output from the, uh, uh, debug, uh, in [15:02.020 --> 15:09.120] the right picture. And you can see, uh, before and after the w-i-c-w-i-s-s-l-e protection, it's [15:09.120 --> 15:14.860] changed a bit of the w-i-s-s-l-e protection from 4 to 1. Yeah, I guess it's mean to read [15:14.860 --> 15:21.020] right when the value is 4 and the no access value is 1. Uh, left picture describe the p-t-u [15:21.020 --> 15:26.880] content, uh, about Intel. Uh, it's also, you know, it's, uh, page table structure. Uh, after [15:26.880 --> 15:32.580] the function of the m-i-r-e-v-e-r-t, uh, value the p-t-e, the r and the right bit will set to [15:32.580 --> 15:40.300] 0, so the whole page in the current, uh, current side will change to the read only. Uh, but the [15:40.300 --> 15:46.620] server side with another, will use another page table, uh, so when, what about the w-i-s-s-l-e [15:46.620 --> 15:53.980] protection? Uh, I think it's, uh, this bit from 60, 60 to 62 is reversed according to, uh, [15:53.980 --> 16:00.340] Intel's documentation, so I guess Microsoft use it for some special purpose, yeah. And, uh, [16:00.340 --> 16:05.160] when changing the address protection, it's called m-m-m-check security, uh, secure vat to [16:05.160 --> 16:13.340] check if there's, uh, uh, special vat event, as we talked before. And, um, uh, we, when we [16:13.340 --> 16:18.420] call the compare p-t-e protection, it will compare the page table. Finally, compare the [16:18.420 --> 16:25.420] page table, uh, protection with, with the desired protection mask, uh, uh, we, uh, process [16:25.420 --> 16:35.760] the, uh, we pass to the virtual protect e-x, uh, to see, uh, return change, uh, attribute if [16:35.760 --> 16:41.980] two value is the same. If it's not equal to the virtual protect e-x, it will return error. [16:41.980 --> 16:47.940] Unfortunately, uh, WS protection now is one, so it's not the same as before. Uh, it's really [16:47.940 --> 16:54.780] has some weird errors you see when changing the protection from the address. It's really, uh, [16:54.780 --> 17:04.800] not the same as we thought. Uh, I should actually try to bypass, uh, this function. Uh, so [17:04.800 --> 17:17.930] it's changing the p-t-e... so it's changing... you're right, it's changing the p-t-e [17:17.950 --> 17:29.950] function. Can you hear me? Oh, now it's okay, yeah. Uh, so I tried to bypass the, uh, this [17:29.950 --> 17:35.330] function, uh, and, uh, it's changed the protection one page. So, if you allow the shared [17:35.330 --> 17:39.970] memory for more than two page, and you only write data to the first page without it doing [17:39.970 --> 17:47.850] any other operations, so, um, the operation will fail. Uh, but the security function, uh, [17:48.430 --> 17:54.070] you know, uh, because, uh, the rest of the page doesn't even have the page table, uh, so you [17:54.070 --> 18:01.970] can't change the attributes. Okay, let's, uh, see the vulnerability details, uh, we found [18:01.970 --> 18:10.710] in, uh, the region. Uh, the kernel always do try to alignment the allocation size to one page. [18:10.810 --> 18:17.710] Uh, you can skip the session object, uh, the starting of session, actually, um, it's auto [18:17.710 --> 18:23.230] increased, uh, based on the, uh, uh, last region and the offset. However, the allocation size [18:23.230 --> 18:32.250] is unchecked. So, what about this, um, small security, uh, um, flaw? This small undiscovered [18:32.250 --> 18:39.730] issue can cause, uh, afterwards. Uh, but you still remember the previous picture, yeah. Uh, [18:39.730 --> 18:44.770] assuming we had located, uh, we already allocated four, uh, region. Uh, the size of the first [18:44.770 --> 18:53.630] region is 0x1000, so the start of, start offset of the second region, uh, is actually, will be [18:53.630 --> 19:00.610] one, 0x1000. Based on the info in the picture, we can know a starting offset of the region [19:00.610 --> 19:07.570] three is 0x, uh, 4000, uh, which is pretty easy to understand and, uh, calculate it. Uh, so [19:07.570 --> 19:13.810] based on the, this, uh, info we know, we can see how unchecked section, unchecked, uh, section [19:13.810 --> 19:22.110] size, uh, we can do in the following. Uh, if we allocated, uh, which region was extremely big [19:22.110 --> 19:33.470] size, 0x002 is actually minus, uh, FFFE. Uh, based on the region, uh, and the view granularity, [19:33.470 --> 19:39.350] the final offset of region two is actually will be zero. So, the allocation size, uh, will be [19:39.350 --> 19:46.470] still zero. So, what does this mean? Uh, uh, this means that the region two will overlap with [19:46.470 --> 19:53.470] the region one, and they will be mapping to the same physical address. Uh, we can use the [19:53.470 --> 19:59.310] view one to send and receive the LLPC message, and this view will be protected by the LLPC [19:59.310 --> 20:04.770] kernel, by using secure view against the write, uh, function. But the second view will be [20:04.770 --> 20:11.470] left, and the kernel will do nothing on it. So, because we don't even use it, um, so we can use [20:11.470 --> 20:19.050] the address of the second region, it actually change, um, the content. It's writable, so the [20:19.050 --> 20:24.190] double fish will happen again. Uh, the secure view, uh, write against the write function, uh, [20:24.190 --> 20:30.790] can't protect you anymore. So, it is, uh, there will be many, still many questions, uh, for [20:30.790 --> 20:37.070] you. Uh, as you see in the previous page, uh, the region allocation size is zero. Uh, so [20:37.070 --> 20:42.650] while you still can change the content of the shared memory, um, you know, because, uh, the [20:42.650 --> 20:48.910] map view function support mapping size of zero, uh, you allocate a page with size, uh, one [20:48.910 --> 20:54.710] page by default, so we don't need to worry about it. And the second, if you set the map view [20:54.710 --> 21:02.630] function, it cannot, uh, cannot, it can't accept zero size? Why don't you pass zero size? Uh, [21:02.630 --> 21:08.650] because it's unacceptable. There was a, there's a check, uh, before the allocation, uh, [21:08.650 --> 21:16.110] allocate the view, create view, create, uh, section view function. It's also, um, the region [21:16.110 --> 21:21.890] object can't use it in more than two views, uh, but the situation I've never encountered, uh, [21:21.890 --> 21:29.550] uh, so let's, uh, rest again on the Windows 11 again. Uh, based on the custom, uh, PC [21:29.550 --> 21:36.890] service, uh, we created, uh, two views with the same section offset. So, uh, overlap happened, [21:36.890 --> 21:40.690] and the kernel only secured the first view, uh, leaving the second view at address [21:40.690 --> 21:45.530] writable. So you can see, we successfully changed the content of the, uh, service, uh, [21:45.530 --> 21:51.630] parameter without changing the protection of the, uh, first view. Uh, the RPC services, uh, [21:51.630 --> 21:59.510] will be vulnerable again. So we have already win the race. So, from the page table entry, uh, [21:59.510 --> 22:05.490] from the win debug, uh, you can see two address pointed to same pages frame, uh, page frame [22:05.490 --> 22:11.090] number. It means that it's been to the, uh, pointed to the same physical memory. And, uh, [22:11.090 --> 22:15.790] we can see from the protection, we break into the debug when server trying to, uh, print the [22:15.790 --> 22:22.390] stream from client. So, the first page is, uh, read only, and it's writable, but it's, uh, the [22:22.390 --> 22:26.490] second page is writable, uh, on the same physical memory. Uh, which will result in [22:26.490 --> 22:34.230] confirm our ideas, and the result is the result from the terminal. So, from the exploitation [22:34.230 --> 22:43.170] analyze. Uh, so let's discuss some, uh, possible exploitation, uh, from the assessment [22:43.170 --> 22:51.330] before. Uh, there's two way to, uh, exploit. Uh, one is, uh, you can use Windows services, or [22:51.330 --> 22:57.770] third party services using, uh, file operations, uh, for exploitation techniques. Uh, use, uh, [22:57.770 --> 23:03.610] created by Jamf Spatial, uh, change to write system DLL, or, and get any, uh, system [23:03.610 --> 23:09.230] privilege, or bypass some security check in, and access some functions, uh, which, uh, the [23:09.230 --> 23:18.550] main user, uh, can access, or bypass, uh, UAC on, UAC on the Windows 11. Uh, uh, the, on [23:18.550 --> 23:24.510] the other side, we can also use, uh, memory corruption, uh, exploitation techniques. Uh, [23:24.510 --> 23:31.490] firstly, I can almost crush any RPC services, or over ARPC services, and even can get [23:31.490 --> 23:38.490] system shell. So, I must, uh, admit that, uh, I'm lazy sometimes, just want to make the [23:38.490 --> 23:45.510] exploitation as easy as possible. So, unfortunately, uh, Microsoft is also stupid. Uh, they [23:45.510 --> 23:52.850] were deleted the services code, which, uh, several years ago, that Thomas used to exploit, uh, to [23:52.850 --> 23:58.910] exploit this type of issue. Uh, we need to find, uh, another possible way. But, however, it's [23:58.910 --> 24:04.110] likely possible to find the RPC services, uh, meet, uh, these conditions. It's impossible, I [24:04.110 --> 24:09.250] think. Uh, first, uh, the service need to use the shell memory without copying it to another [24:09.250 --> 24:16.110] address, and also need to have some sensitive operations on the file. So, consider this, uh, [24:16.110 --> 24:22.410] situations, it's almost impossible to find this kind of service. At least, I didn't find one. [24:22.410 --> 24:31.970] Uh, you can try it. Uh, but I think it's possible on some, uh, third party, uh, services. Uh, [24:31.970 --> 24:36.770] next, we should know what kind of, uh, argument can we use to double fish. Uh, simple [24:36.770 --> 24:42.770] structure or pointed, uh, like, uh, integer pointers, string, uh, double string use, uh, [24:42.770 --> 24:49.190] shell memory. Uh, the context structure is also, you call, uh, you may not call, you may know [24:49.190 --> 24:53.810] it's called the longest struct, uh, without copying to heap buffer. Uh, you may confuse [24:53.810 --> 25:00.230] about what is the, uh, complex, uh, or simple structure. To put it simple, uh, you just [25:00.230 --> 25:07.810] remember, if a structure contains a pointer, it will be a complex structure. Uh, this is the [25:07.810 --> 25:12.150] example of the simple complex structure, uh, we've seen. Uh, and they were, uh, treated [25:12.150 --> 25:19.150] differently when RPC unmashered them. Uh, and above is, uh, Bambi's structure, uh, which we [25:19.150 --> 25:28.370] will never use, uh, uh, in the shell memory. So, which below is the example of the, uh, [25:28.370 --> 25:32.950] complex structure? Uh, so we need to understand RPC format and the type format first. And, uh, [25:32.950 --> 25:38.610] proc format is, uh, one server function infos, uh, parameter type, and, uh, store the, uh, [25:38.610 --> 25:44.510] it's stored offset, uh, inside the parameter. And, for example, if we have, uh, output one [25:44.510 --> 25:51.950] function in server side, uh, the proc format will generate, uh, IDL, uh, compiler from the [25:51.950 --> 25:57.070] compiler, uh, storing the parameter into, like, the parameter type offset and the location [25:57.070 --> 26:01.990] info of the parameter. And the IDL compiler also generates the comment for every... [26:02.950 --> 28:03.970] Oh, I see. Oh, it's okay now? Yeah. And then we can see, uh, the difference between, uh, the [28:03.970 --> 28:12.210] simple and, uh, complex structure in, uh, type format. Okay, the proc mark, uh, give us [28:12.210 --> 28:16.570] where the parameter type definition located in the type format string. So we can see [28:16.570 --> 28:22.730] different, uh, between the simple and the complex structure. In the header flag, you can see [28:22.730 --> 28:31.790] them in the comment. Uh, there's three situation buffer flow I can cause. Uh, I try to find [28:31.790 --> 28:38.870] the exploitation services by code auditing, uh, or faster contents. Uh, but one, uh, one [28:38.870 --> 28:43.990] condition is inside the RPC, uh, string marshal function. Uh, the pre-memory content we can [28:43.990 --> 28:50.110] control. So one service has multiple output string, uh, result sending to the client. So it's [28:50.110 --> 28:54.410] also, well, we use the shared memory to send to the client. So we can fill the whole shared [28:54.410 --> 29:01.770] memory and the argument gap. Assuming the first string is 0x50 less and the second is 0x50 [29:03.090 --> 29:09.370] less. So we can fill the argument gap in the memory, uh, after the server finished the [29:09.370 --> 29:17.950] subcode and returned to the RPCRT4. And the client size will be over 0x1000. So it's the [29:18.470 --> 29:25.810] maximum size in shared memory will cause the crash of the service. And, uh, also another [29:25.810 --> 29:31.770] heap operation, uh, which means, uh, uh, which means the size of the string store, uh, in [29:31.770 --> 29:37.090] side a pointer. So it's not easy to find this part of the server. So we can change the size [29:37.090 --> 29:41.450] of the string when the server on marshal, the server resulting in the string, uh, sending [29:41.450 --> 29:48.230] to the client. Uh, however, it's still, uh, uh, possible, not possible to exploit. You can [29:48.230 --> 29:54.090] only cause the shared memory output, uh, outbound read. Uh, so when calling the pre-memory [29:54.090 --> 30:01.750] function, so it's a pity. And, uh, third exploitation is, uh, spore service, uh, uh, [30:02.450 --> 30:06.910] spore server service. Uh, when it opened a printer, it will double check, access the name [30:06.910 --> 30:14.090] of the printer. And the first time, uh, the server will cause WCs, a string result, uh, [30:14.090 --> 30:21.370] offset, uh, can be a large offset and then allocate a string again. And I recalculated [30:21.370 --> 30:25.970] the string length. So this time the string can be small size. So you will cause out of [30:25.970 --> 30:33.830] bound write a null pointer, a null bytes. Uh, but this issue is how to exploit. So we also [30:33.830 --> 30:39.690] need to win the race and the doing heap feng shui, uh, to construct some usable target. So [30:39.690 --> 30:46.170] it's really a huge challenge. So, um, what should I do? So I decided to, uh, try to do some [30:46.170 --> 30:55.110] easy stuff first. Let's see. Uh, we're passing UIC. Uh, how is it works? Uh, the key [30:55.110 --> 31:02.990] function inside the application information service, uh, in a UIC, uh, service. Uh, luckily [31:02.990 --> 31:07.670] the service access the command line argument from the shared memory, uh, without copying [31:07.670 --> 31:14.990] it to the heap buffer. So we can have a chance to use this. Um, and also the program name [31:14.990 --> 31:21.750] and the CMD line argument are also stored in the shared memory. Uh, the UIC has a special [31:21.750 --> 31:26.470] feature. Uh, when the client executes some special program, you have not launched the [31:26.470 --> 31:32.010] save confirm window. So we can use the features to launch the arbitrary program without any [31:32.010 --> 31:39.530] launch any confirm window, uh, from APP info service. So we can bypass it. Uh, it's also [31:40.070 --> 31:45.950] not the easy as we analyzed. Uh, there's a white list, uh, inside the service. Uh, you [31:45.950 --> 31:52.270] should know that it is also argument the white list, uh, for some special program, uh, which [31:52.270 --> 31:58.570] you can, which you not, not, you not, not need to launch the, uh, confirm window. Uh, [31:58.570 --> 32:03.910] so also the new process, uh, we launched the by IPP info service, uh, will suspend the [32:03.910 --> 32:08.950] first. That means that we still cannot execute our payload. So server will check the process [32:08.950 --> 32:13.810] image section with the program file section, uh, means although we have a launch, uh, [32:13.810 --> 32:18.190] malicious program result, confirm window, the IPP info, well, every info service or [32:18.190 --> 32:24.110] also, um, launch, launch the, uh, confirm window because the true image are not the [32:24.110 --> 32:30.610] same. So it's, Microsoft is not stupid, stupid, really a good solution to prevent a launching [32:30.610 --> 32:35.990] from any malicious program. So, but unfortunately they, uh, doesn't check the argument [32:35.990 --> 32:41.250] program by launch. Uh, after the launching the program, it doesn't know, doesn't the [32:41.250 --> 32:46.150] check the argument. So we still have to change. Uh, [32:46.150 --> 32:51.530] the good thing is we can create a malicious MSCC file and there's just a research on [32:51.530 --> 32:57.170] the MSCC file when MSCC, uh, open and auto-launch the CMT shell, uh, [32:57.170 --> 32:58.990] with a malicious strip. Uh, you know, [32:58.990 --> 33:03.990] service.msc is in the white list of the UIC, uh, [33:03.990 --> 33:08.700] UIC services. So, uh, we can see, [33:08.700 --> 33:14.080] launch a high integrated command line shell without any other problem. Uh, [33:14.080 --> 33:17.380] but I'm not satisfied in doing this. Uh, [33:17.380 --> 33:19.920] it's even not a vulnerability to Microsoft. [33:19.920 --> 33:25.400] So you should be an administrator first and a main system to the system. [33:25.400 --> 33:28.960] It's not a security boundary as we seen from the, uh, Microsoft. [33:31.220 --> 33:35.620] So last is, uh, get system privilege. Uh, another good thing is, [33:35.620 --> 33:42.880] it's truly exploitable. Uh, I found a service in DCOM launch. Uh, [33:42.880 --> 33:46.640] the key is that key service in Windows system, uh, interface, uh, [33:46.640 --> 33:51.140] normal user can access, uh, the list, uh, the service dual ID, [33:51.140 --> 33:56.580] service, uh, uh, pass. So, and the service function, uh, [33:56.580 --> 34:01.940] I used to exploit, uh, it's a game, get game name, uh, config. Yeah. [34:02.120 --> 34:03.960] It's truly, and it's true. [34:03.960 --> 34:08.020] And the three parameter with simple structure means the service can use the [34:08.020 --> 34:12.540] shared memory. It would obviously get the execution from the start point. [34:15.000 --> 34:17.700] And that's the first parameter is the dual ID stream. [34:17.700 --> 34:22.160] It's come from the registry, uh, representing a game. As you know, [34:22.160 --> 34:26.320] dual ID in the picture, uh, this dual ID represent the battlefield. [34:26.320 --> 34:30.400] I think some of you might played it before. Uh, [34:30.980 --> 34:34.840] most importantly is the key is a key is fully controlled by the current user [34:34.840 --> 34:39.640] because every user in the system have the, uh, 80 independent, uh, [34:39.640 --> 34:41.820] game store configuration in the user hive. [34:41.840 --> 34:46.420] So you can just traverse the key, current key and the final one. [34:46.580 --> 34:50.600] Uh, next we may start, what can we do in the service? Uh, [34:50.600 --> 34:55.280] because we cannot pass in the, uh, uh, parameters through the shared memory. [34:55.280 --> 34:57.640] So we can, uh, pretty lucky. [34:57.640 --> 35:02.160] We can do memory leak and array buffer or array overflow in this function. [35:02.440 --> 35:06.400] So first the function directly write a string, uh, pointer to the shared memory, [35:06.400 --> 35:10.180] which means we can leak the shared memory address mapped in the server side. [35:10.280 --> 35:14.020] Although the memory is unmapped after the request, [35:14.020 --> 35:15.940] but the address will never change. [35:15.940 --> 35:22.340] So we can use the shared memory to construct our fake object and the V tables [35:22.340 --> 35:25.960] and the plus this stack array buffer floor upon access. [35:25.960 --> 35:28.900] And after the information leak on the share memory, [35:28.900 --> 35:34.020] you can see the function directly use the index from the share memory and the [35:34.020 --> 35:38.360] writer share memory or the dress a pointer out of a bond on the stack. Uh, [35:38.360 --> 35:41.740] this means that we can do info leak and the stop off for all floor, uh, [35:41.740 --> 35:45.700] just in one function. And, uh, it's a good and, uh, really, [35:45.700 --> 35:49.780] and the good right pump primitive. Uh, [35:49.780 --> 35:53.140] this is just a strategy, a strategy I use. Uh, [35:53.140 --> 35:58.560] the first I need to leak the share memory address and we just, uh, [35:58.560 --> 36:00.500] call the server function and the, you know, [36:00.500 --> 36:05.320] those thread to repeatedly read the share memory so we can get the pointer. [36:05.820 --> 36:08.780] And when we get the share memory, we can create a fake object. [36:08.780 --> 36:12.280] The V table are based on the liquid information in the step one. [36:12.340 --> 36:13.900] And then finally, uh, [36:13.900 --> 36:17.200] we can try to change the index of the share memory to trick the stack array, [36:17.720 --> 36:18.480] uh, floor, [36:18.480 --> 36:23.420] overflow to load our evil DRL to the service and to get system shell. [36:24.260 --> 36:28.620] Uh, I'll show you one step up by step. And this is, uh, [36:28.620 --> 36:30.660] I'll put on the windy bug window. [36:30.660 --> 36:33.680] We can see several right the share memory pointer on the share memory. [36:33.680 --> 36:38.680] We just read it repeatedly from the kind until, uh, we read the, uh, [36:38.680 --> 36:43.140] pointer, share, share pointer. Uh, next the real problem cam. [36:43.140 --> 36:46.840] So we can get a staff or a buffer or floor, but, uh, [36:46.840 --> 36:50.680] how and where to write, right. I don't know what to write. Uh, [36:50.680 --> 36:54.500] I choose to write the RPC message object on the stack. Uh, [36:54.500 --> 36:59.540] first the RPC message is a member in MIT or some message and the object is [36:59.540 --> 37:02.340] allocated on the stack. So before I see you call the server, [37:02.340 --> 37:06.960] it's easy to over override it. And there's all the share memories, uh, [37:06.960 --> 37:10.580] not executable. So we can just overwrite and the return. [37:10.580 --> 37:13.980] If we choose to override the return address, uh, [37:13.980 --> 37:19.040] we cannot directly do the ROP. Uh, uh, [37:19.040 --> 37:22.360] let's see what we write from the view of the wind debug. Uh, [37:22.360 --> 37:25.660] RCX is a rain decks. Uh, we can fully a contrary it. [37:25.660 --> 37:30.340] RX is a shimmer memory address and then we also can't fully control it. [37:30.340 --> 37:34.720] So you can see, uh, we easily override RPC message pointer on the stack. [37:35.000 --> 37:37.440] So when a server you turn to RPC core engine, [37:37.440 --> 37:41.120] it will be operated on the fake object. Uh, [37:41.120 --> 37:46.660] so we can see from the engine call NDR get buffer RCX already being the share [37:46.660 --> 37:51.480] memory address. And this is a layout of the share memory. Uh, [37:51.480 --> 37:55.200] there's also some type check, uh, because we can't fully control it. [37:55.200 --> 37:56.940] So it's not a problem. Uh, [37:56.940 --> 38:00.940] I choose to construct that fake RPC binding handle, uh, [38:00.940 --> 38:05.940] in the share memory, uh, real problem cam, uh, [38:06.280 --> 38:09.560] where you can see finally you arrive to the virtual function calling. [38:09.560 --> 38:12.380] It's a XFG check. Um, [38:13.460 --> 38:17.680] the first, uh, uh, of a table and, um, uh, [38:17.680 --> 38:21.580] I want to actually low, uh, uh, directly call to the load library, [38:21.580 --> 38:26.240] but you can see, uh, the V table and the, uh, first parameter is overlapped. [38:26.240 --> 38:31.240] So we can directly onto, we can not directly call the load library. Uh, [38:31.240 --> 38:35.700] so, uh, we can always find a way. Uh, [38:35.700 --> 38:37.780] if I can directly call a load library, [38:37.780 --> 38:42.220] I can find a legal callable function to, to register pivoting. [38:42.220 --> 38:44.880] So we know there's a technique, uh, [38:44.880 --> 38:49.500] called a stack pivoting in CTF exportation techniques where you can directly [38:49.500 --> 38:53.940] RP on the current stack. So for the register pivoting, [38:53.940 --> 38:57.680] I just need to find a function which can exchange the content of the register [38:57.680 --> 39:00.760] RCX. And, uh, uh, [39:00.760 --> 39:04.300] then the register were appointed to the DRL pass. And luckily I found this kind [39:04.300 --> 39:07.740] of, uh, uh, function. It can't reach your cage. It's changed. [39:07.740 --> 39:11.640] The register is inside the combats DRL. Okay. [39:11.640 --> 39:16.840] Directly called bypass the XFG check is a callback function. [39:16.840 --> 39:22.720] And this is a layout. Uh, RCX is before we call into the callback, [39:22.720 --> 39:27.320] it's pointing to bind handle object and the value in a purple color is the type [39:27.320 --> 39:30.610] of information and the callback function. Uh, [39:30.610 --> 39:35.430] we can call low libraries with log in function to with the DRL pass in the [39:35.430 --> 39:38.530] second parameter. So luckily before the control for all check, [39:38.530 --> 39:40.510] the validity of the callback function, [39:40.510 --> 39:44.850] the function is not the first member of the Vtable is at the 0x70. [39:44.850 --> 39:49.570] So the start location of the Vtable we can use to put out with DRL pass. Uh, [39:49.570 --> 39:53.910] so without worrying about the function validity because we were never used. [39:54.670 --> 39:59.750] So then we can load our custom DRL without any resistance. Yeah. [40:00.060 --> 40:02.660] And I will show you the demo. [40:07.430 --> 40:09.980] I use a, uh, a normal user. [40:10.960 --> 40:12.920] It's a user group [40:15.770 --> 40:19.060] and I write it in all the POC in that person [40:21.430 --> 40:25.900] and you can see is a normal user with a medium privilege. [40:25.900 --> 40:28.160] It's not in our administrator group. [40:30.570 --> 40:31.130] Okay. [40:31.130 --> 40:38.050] And then we check the DECOM service to see if we can load our malicious DRL. [40:41.130 --> 40:41.790] Okay. [40:41.790 --> 40:46.910] We can see the shared memory and the COM base and we see we already know that [40:46.910 --> 40:53.850] our evil DRL and there's a shell coming and we type who am I and we get a [40:53.850 --> 41:02.720] system privilege. It's all the privilege. [41:02.720 --> 41:04.000] Thank you. Thank you. Thank you. [41:11.410 --> 41:19.970] Oh, thank you. And, uh, a conclusion. [41:19.970 --> 41:24.150] So the voices. So to be continue, um, [41:25.710 --> 41:30.330] I think there's still some research I need to do in the future. [41:31.230 --> 41:37.150] I like the automation info extract from the RPC interface. [41:37.150 --> 41:38.630] I need to find this, um, [41:38.990 --> 41:43.510] exportation service and the argument which made the exportation bar. Uh, [41:43.510 --> 41:47.430] if you have any good ideas and you can please share it to me, [41:47.430 --> 41:52.810] I also want to know some good ideas for the two develop developing. [41:52.970 --> 41:55.090] And there's a much special, more, uh, [41:55.090 --> 42:00.290] special features in RPC and the need to be X mind and the more effective [42:01.190 --> 42:04.670] exportation techniques. If you're on the other, any good ideas, [42:04.670 --> 42:07.390] feel free to contact me. Yeah. [42:09.190 --> 42:09.750] Yeah. [42:09.750 --> 42:12.870] And the right Bob, uh, this is our bunk hunting experience. [42:12.870 --> 42:17.190] I want to share with you and the first don't trust any patches from the render. [42:17.190 --> 42:20.750] It may still not patch the vulnerability effectively. [42:20.750 --> 42:25.310] And also the patch analyze is still more effect in back hunting. [42:25.590 --> 42:30.150] You should be more creative and the criticizing when criticizing, [42:30.150 --> 42:35.990] when back hunting. Yeah. You should dare to do it and we should be patient. [42:36.370 --> 42:40.990] But bunk hunting is a long way medicine. And our last, uh, [42:40.990 --> 42:45.790] don't meet any, meet any, miss any other, any side effect. [42:45.790 --> 42:49.890] This effect may cause security flaw afterwards. [42:51.350 --> 42:56.090] Yeah. And, uh, this, uh, for this type of service, uh, [42:56.090 --> 43:00.650] we mentioned in the talk, there's still much special feature is the RPC RPC. [43:00.950 --> 43:05.930] Uh, we need to XMI and the security of RPC is actually effect. [43:05.930 --> 43:08.950] The security of the RPC, uh, for Microsoft, uh, [43:08.950 --> 43:13.990] we can see it's really done a great tireless works on the security of the RPC [43:13.990 --> 43:18.430] services. Although we cause the double fish in the RPC services, uh, [43:18.430 --> 43:21.950] we need to still find the, uh, export both service in the, [43:21.950 --> 43:26.490] and the parameters still meet us very strict bars. [43:27.630 --> 43:32.590] And this is a reference of our talk. And, uh, thank you. [43:32.590 --> 43:33.950] Uh, is there another questions? Uh, [43:33.950 --> 43:37.810] because there is a microphone has any problems and sorry for that. Yeah. [43:50.580 --> 43:51.660] Oh, thank you.