1 00:00:02,650 --> 00:00:04,750 I can start? 2 00:00:04,750 --> 00:00:06,270 Okay. 3 00:00:10,540 --> 00:00:20,860 It's good to be here. 4 00:00:20,980 --> 00:00:23,460 I'm Wang Junjie Zhang. 5 00:00:23,460 --> 00:00:27,680 I'm a security researcher from the Hearthstone Networks. 6 00:00:27,680 --> 00:00:35,940 My research direction is Windows vulnerability research including user mode and kernel mode. 7 00:00:36,380 --> 00:00:46,580 And also I've been listed as the most valuable researcher of the Microsoft 2020, 2022, and 2023, 2024. 8 00:00:46,580 --> 00:00:47,380 Yeah. 9 00:00:48,080 --> 00:00:49,240 Okay. 10 00:00:50,520 --> 00:00:54,900 So, let's just start my talk. 11 00:00:55,500 --> 00:01:02,660 And this is, I already introduced myself and our colleague here. 12 00:01:02,660 --> 00:01:03,440 So, I'm Wang Junjie Zhang. 13 00:01:03,440 --> 00:01:03,460 I'm a researcher at Microsoft . 14 00:01:03,820 --> 00:01:07,360 Um, firstly, let's see our agenda today. 15 00:01:07,360 --> 00:01:09,460 It's mainly consists of four parts. 16 00:01:09,460 --> 00:01:14,440 Um, we'll introduce architecture of the LPC and RPC. 17 00:01:14,440 --> 00:01:17,720 So, we'll have a deeper understanding of it. 18 00:01:17,720 --> 00:01:24,020 And then look at some, uh, common vulnerabilities inside LPC and RPC. 19 00:01:24,220 --> 00:01:27,960 And we'll study some root cause of the vulnerabilities. 20 00:01:29,020 --> 00:01:34,160 And then I will share some details of the vulnerabilities I found by myself and my team. 21 00:01:34,160 --> 00:01:39,340 And which can bypass the LPC, RPC, uh, security mechanism. 22 00:01:39,340 --> 00:01:51,300 Uh, I will show you step-by-step, uh, to use, uh, this small security flaw to bypass the security mitigations like SDR, DEP, XFG, and finally get system shell. 23 00:01:51,300 --> 00:01:54,160 Uh, you won't get it from anywhere else. 24 00:01:54,160 --> 00:01:57,520 So, and that's the way to make a conclusion. 25 00:01:58,720 --> 00:01:59,700 Yeah. 26 00:02:00,200 --> 00:02:03,960 Uh, so it's, uh, architecture, yeah. 27 00:02:04,020 --> 00:02:11,180 We already know, um, the LPC, uh, was introduced, uh, to replace the ARPC. 28 00:02:11,180 --> 00:02:22,380 Uh, it's called, uh, Lightweight, Lightweight Procedure Core, uh, mainly used in, uh, Windows system, uh, inside, uh, Windows system services. 29 00:02:22,380 --> 00:02:29,600 Uh, and it's, uh, concerned by many researchers for each, it's huge attack service. 30 00:02:29,880 --> 00:02:31,080 Uh, so it's, uh, based on the ARPC. 31 00:02:31,080 --> 00:02:37,040 And this is, uh, uh, uh, ARPC and RPC architecture. 32 00:02:37,540 --> 00:02:44,440 And why we combine the ARPC and RPC together? 33 00:02:47,700 --> 00:02:50,900 Uh, why we combine, uh, it's together? 34 00:02:50,900 --> 00:02:56,920 For reason listed below, uh, most, uh, RPC services is based on the ARPC or NAND pipe. 35 00:02:56,920 --> 00:03:01,140 So it's almost, uh, based on the same, uh, security mechanism. 36 00:03:01,140 --> 00:03:07,700 And the security flaw inside the, uh, ARPC can affect the security of RPC services. 37 00:03:09,060 --> 00:03:14,040 And this is, uh, also the architecture of the ARPC, RPC from, uh, Windows internal. 38 00:03:14,160 --> 00:03:18,460 Uh, you can communicate, this, uh, see the communication module inside it. 39 00:03:18,860 --> 00:03:23,460 And it's also support some, uh, message queries and some share section. 40 00:03:23,680 --> 00:03:28,100 Uh, also, uh, support share section to pass the message. 41 00:03:30,080 --> 00:03:33,800 Uh, why we use, uh, section here? 42 00:03:34,140 --> 00:03:40,040 Uh, because it's a more effective, uh, data passing mechanism on Windows, uh, section object. 43 00:03:40,040 --> 00:03:41,860 Uh, more efficient and fast. 44 00:03:41,860 --> 00:03:43,560 And, uh, what about the region? 45 00:03:43,660 --> 00:03:50,660 Uh, why region is, uh, represent a range of the shared memory that can be opened within the context of a given port. 46 00:03:50,660 --> 00:03:57,260 Uh, the section can be shared, uh, accessed by one process, uh, which only have a right access. 47 00:03:57,320 --> 00:04:00,900 And meanwhile, uh, the client only have the right access. 48 00:04:01,760 --> 00:04:05,940 Uh, this picture, uh, describe the relationship between the section. 49 00:04:06,040 --> 00:04:06,780 Yeah. 50 00:04:07,140 --> 00:04:10,980 We can split up the whole section into, uh, different region. 51 00:04:11,020 --> 00:04:15,200 Uh, one piece is represented by, uh, one region object. 52 00:04:15,200 --> 00:04:22,220 Uh, we have a set, uh, size, uh, which is representing the map of the set and the size of the set section. 53 00:04:23,420 --> 00:04:24,120 Yeah. 54 00:04:24,200 --> 00:04:28,180 Uh, I see some, uh, historical vulnerabilities. 55 00:04:28,220 --> 00:04:28,860 Yeah. 56 00:04:30,540 --> 00:04:41,140 Um, first kind of bug is, uh, kind of logical bug, uh, in ARPC when, uh, you know, there's too much, uh, uh, research, uh, on the internet. 57 00:04:41,320 --> 00:04:48,860 Um, it related to, uh, uh, doing when the service doing some, uh, file operating, uh, operations. 58 00:04:48,860 --> 00:04:55,180 Uh, it's need to, uh, impersonate the colors, uh, token and doing some, uh, operations on file. 59 00:04:55,180 --> 00:05:13,460 Uh, however, you know, sometimes the failure to properly handle the file operation, uh, with a file, like the symbol link, it may be resulting the service being able to modify, or write, or delete, and even create, uh, some files when client should not have the permission, 60 00:05:13,460 --> 00:05:15,260 uh, these operations. 61 00:05:15,260 --> 00:05:36,740 So, uh, this vulnerability, uh, CVE 2020 and 0F0911 is an example of the using user's device map, uh, where impersonating users and the service will operate on malicious, uh, MSAI files, uh, on the user's device map installer directory, and it will directly, 62 00:05:36,740 --> 00:05:38,300 uh, to another path. 63 00:05:38,300 --> 00:05:50,860 So, when the service revert to the system privilege, it also trust the content, uh, to read from their client installer directory and source, um, the privilege acceleration happen, yeah. 64 00:05:53,340 --> 00:06:12,780 Uh, uh, this kind of bug exploitation have much articles and research, uh, on the internet, uh, by using tricks of, uh, firstly, uh, I think it's discovered by Google research, uh, James Fosho, uh, by using tricks like NTFS junctions, uh, higher link or object symbol links and, 65 00:06:12,780 --> 00:06:19,400 uh, opportunities locks, you can easily, uh, write exploitations, uh, on this kind of bugs. 66 00:06:19,980 --> 00:06:20,940 Yeah. 67 00:06:21,100 --> 00:06:28,560 Uh, the second, second example is, um, malicious, uh, memory corruption bug inside LPC, LPC kernel, uh, in recent years. 68 00:06:28,560 --> 00:06:35,200 Uh, we have seen a lot of, um, memory corruption issues inside the LPC, LPC kernel. 69 00:06:35,420 --> 00:06:42,620 Uh, so the following code snippet is a part of the vulnerability and is associated with the LPC section blob object. 70 00:06:42,620 --> 00:06:52,380 Uh, when you create a LPC section, uh, in the map legacy port view function, uh, there's a race window before the function with, uh, uh, view port, view object. 71 00:06:52,380 --> 00:07:04,940 Uh, during this race window, attacker can, uh, destroy the LPC port object, uh, causing it, uh, LPC create section view function, uh, access, uh, 3D pointer. 72 00:07:05,660 --> 00:07:11,720 The picture describe the, uh, race window, uh, in the connect port function. 73 00:07:11,720 --> 00:07:19,460 Uh, the kernel, kernel creates the first, uh, LPC port and, uh, we can try to close the handle table in the second thread. 74 00:07:19,500 --> 00:07:27,520 Uh, if this moment, close moment, uh, between the create section and the create view port function, you can get a blue screen. 75 00:07:27,520 --> 00:07:34,520 Uh, but however, this kind of issue is, I think it's a little bit hard to exploit because you need to win the race first. 76 00:07:35,760 --> 00:07:53,020 Uh, what we observe is that most of these, uh, memory corruption bug, uh, inside LPC kernel or LPC services, and most of them are traditionally memory corruption bug, bugs , uh, due to the server side lack of check when LPC services, uh, handle data from the client side. 77 00:07:53,700 --> 00:07:57,080 And last example is, uh, I think it's very interesting. 78 00:07:57,080 --> 00:08:01,540 Uh, logical fallback in LPC RPC discovered in 2016-2017. 79 00:08:01,540 --> 00:08:09,380 Uh, research found that the kernel doesn't protect the shared memory privilege, uh, when using it to pass the, uh, m-message data. 80 00:08:09,380 --> 00:08:24,000 In theory, the kernel changes the shared section protection in client sides, uh, to read only, uh, preventing the client side changing the memory, uh, while server side, uh, calling stop code that may be cause double fetch loss in server side. 81 00:08:24,000 --> 00:08:33,440 Uh, you can use the virtual protect function to change the shared memory, uh, from read only to write, uh, read write, and causing data race condition in server side. 82 00:08:33,440 --> 00:08:36,420 Uh, it's pretty, uh, predictable, right? 83 00:08:37,160 --> 00:08:47,080 Uh, imagine, uh, we have a, have already have a, uh, RPC function, uh, accepts, uh, string parameter and print it twice with a sleep, uh, between these two option. 84 00:08:47,080 --> 00:08:53,000 Uh, we write a POC and, uh, send a string and try to call the virtual protect and change the content of the string. 85 00:08:53,000 --> 00:08:57,740 Uh, we can see the server side print two, uh, different, uh, strings. 86 00:08:57,740 --> 00:09:04,900 Um, it means that, uh, we can change the parameter while the server side, uh, perform any other operation. 87 00:09:05,160 --> 00:09:12,880 Although, uh, this vulnerability has been fixed, uh, I decide to learn more from it. 88 00:09:12,880 --> 00:09:16,780 Uh, maybe we can find, uh, more interesting stuff. 89 00:09:17,480 --> 00:09:22,640 So, uh, first question is, uh, is really secure update patch? 90 00:09:24,620 --> 00:09:37,680 Yeah, uh, from my, all of the research, uh, result I know, uh, shared memory is, uh, available for, uh, almost any RPC over LPC services. 91 00:09:37,680 --> 00:09:44,980 So I decide to write a custom RPC service and try to, uh, change the, uh, memory pro-memory protection again. 92 00:09:44,980 --> 00:09:48,540 But finally, uh, get, uh, virtual protect EX error. 93 00:09:48,560 --> 00:09:52,980 So, uh, what happened to after the patch? 94 00:09:52,980 --> 00:09:57,020 So I decide to, uh, learn more from the reverse engineering. 95 00:09:57,200 --> 00:10:01,300 Uh, first, uh, N2S kernel try to secure the view of the section. 96 00:10:01,300 --> 00:10:04,960 It doesn't allow to change the memory attribute from the user space. 97 00:10:05,080 --> 00:10:13,040 And, uh, secondly, both N2S and RPC RT4 module DLL enable secure mode in mode check. 98 00:10:13,040 --> 00:10:19,320 It means that the server will not manipulate the shared memory, uh, when it detected the shared memory is unsafe. 99 00:10:20,560 --> 00:10:29,520 Uh, this technique, uh, this is a technique that tells, uh, the security mechanism when handle shared memory from client side. 100 00:10:29,520 --> 00:10:34,760 Uh, kernel use map view, secure view of section function to create a security view. 101 00:10:34,760 --> 00:10:38,720 So you secure virtual memory and you can't change, uh, attribute. 102 00:10:39,040 --> 00:10:39,060 And 103 00:12:46,380 --> 00:13:01,780 when sending the attribute, uh, sending message to the server, it's check the RPC section and the region we use to send the message to see if it's safe and the region can't bind with more than two view objects. 104 00:13:01,780 --> 00:13:04,880 It's trying to change the attributes of the shared memory. 105 00:13:05,120 --> 00:13:07,420 The address, uh, to read only. 106 00:13:07,440 --> 00:13:18,980 If this step falls, then the server side will be marked with unsafe and the RPC RT4 dot DLL will use the shared memory to unmasher the, uh, server side. 107 00:13:20,000 --> 00:13:24,880 And this is the code pieces, uh, from the user mode in RPC RT4. 108 00:13:24,880 --> 00:13:32,380 Uh, it will acquire the RPC message attributes, uh, including the security flag of the RPC region. 109 00:13:32,380 --> 00:13:36,340 If the region is unsecure, you can see, uh, it will lock its heap buffer. 110 00:13:36,340 --> 00:13:41,260 Uh, it's managed by Pcache object and copying the shared memory to the heap buffer. 111 00:13:41,260 --> 00:13:44,600 So it will not cause double phishing vulnerability. 112 00:13:44,740 --> 00:13:48,640 So when the server decide, uh, detect the region, it's unsafe. 113 00:13:50,100 --> 00:14:07,680 Also take a look at the virtual protect ES function to, uh, see how the kernel patch, uh, the, uh, special bad event object, uh, to, uh, secure them, mark the bad objects. 114 00:14:07,680 --> 00:14:09,400 It's a security view or not. 115 00:14:09,400 --> 00:14:17,060 So we know that Windows kernel use MM bad object to describe one virtual address in, uh, user space. 116 00:14:17,060 --> 00:14:21,280 It's, uh, it's, uh, describe the start and the ending of the virtual page. 117 00:14:21,380 --> 00:14:27,820 Uh, when changing the memory of, uh, production, it will check if the bad event object is, uh, in the 118 00:14:34,040 --> 00:14:35,080 list. 119 00:14:35,740 --> 00:14:40,680 Uh, unfortunately, the bad event structure symbol was deleted from Windows 11. 120 00:14:40,780 --> 00:14:43,940 Uh, so I can only use the old symbol from Windows 10. 121 00:14:44,720 --> 00:14:50,300 And digging into it, uh, there's two key function, uh, for address, uh, protection. 122 00:14:50,380 --> 00:14:56,900 One is m-i-c-w-i-s-s-l-e protection and the other is revert m-i-r-e-v-e-r-t function. 123 00:14:57,540 --> 00:15:02,900 Uh, this is the output from the, uh, uh, debug, uh, in the right picture. 124 00:15:03,000 --> 00:15:13,220 And you can see, uh, before and after the w-i-c-w-i-s-s-l-e protection, it's changed a bit of the w-i-s-s-l-e protection from 4 to 1. 125 00:15:13,220 --> 00:15:19,260 Yeah, I guess it's mean to read right when the value is 4 and the no access value is 1. 126 00:15:19,280 --> 00:15:22,840 Uh, left picture describe the p-t-u content, uh, about Intel. 127 00:15:23,020 --> 00:15:26,080 Uh, it's also, you know, it's, uh, page table structure. 128 00:15:26,140 --> 00:15:38,020 Uh, after 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 0, so the whole page in the current, uh, current side will change to the read only. 129 00:15:39,200 --> 00:15:47,420 Uh, but the server side with another, will use another page table, uh, so when, what about the w-i-s-s-l-e protection? 130 00:15:47,420 --> 00:15:58,880 Uh, I think it's, uh, this bit from 60, 60 to 62 is reversed according to, uh, Intel's documentation, so I guess Microsoft use it for some special purpose, yeah. 131 00:15:59,660 --> 00:16:09,780 And, uh, when changing the address protection, it's called m-m-m-check security, uh, secure vat to check if there's, uh, uh, special vat event, as we talked before. 132 00:16:09,940 --> 00:16:17,200 And, um, uh, we, when we call the compare p-t-e protection, it will compare the page table. 133 00:16:17,200 --> 00:16:37,180 Finally, compare the page table, uh, protection with, with the desired protection mask, uh, uh, we, uh, process the, uh, we pass to the virtual protect e-x, uh, to see, uh, return change, uh, attribute if two value is the same. 134 00:16:37,180 --> 00:16:41,980 If it's not equal to the virtual protect e-x, it will return error. 135 00:16:41,980 --> 00:16:47,260 Unfortunately, uh, WS protection now is one, so it's not the same as before. 136 00:16:47,340 --> 00:16:53,060 Uh, it's really has some weird errors you see when changing the protection from the address. 137 00:16:53,060 --> 00:16:56,660 It's really, uh, not the same as we thought. 138 00:16:58,200 --> 00:17:02,000 Uh, I should actually try to bypass, uh, this function. 139 00:17:02,620 --> 00:17:10,840 Uh, so it's changing the p-t-e... so it's changing... 140 00:17:16,810 --> 00:17:17,950 you're right, it's changing the p-t-e function . 141 00:17:17,950 --> 00:17:18,790 Can you hear me? 142 00:17:23,070 --> 00:17:24,850 Oh, now it's okay, yeah. 143 00:17:27,150 --> 00:17:33,550 Uh, so I tried to bypass the, uh, this function, uh, and, uh, it's changed the protection one page. 144 00:17:33,610 --> 00:17:44,970 So, if you allow the shared memory for more than two page, and you only write data to the first page without it doing any other operations, so, um, the operation will fail. 145 00:17:45,270 --> 00:17:56,270 Uh, but the security function, uh, you know, uh, because, uh, the rest of the page doesn't even have the page table, uh, so you can't change the attributes. 146 00:17:57,770 --> 00:18:04,710 Okay, let's, uh, see the vulnerability details, uh, we found in, uh, the region. 147 00:18:04,770 --> 00:18:10,710 Uh, the kernel always do try to alignment the allocation size to one page. 148 00:18:10,810 --> 00:18:21,910 Uh, you can skip the session object, uh, the starting of session, actually, um, it's auto increased, uh, based on the, uh, uh, last region and the offset. 149 00:18:21,910 --> 00:18:24,150 However, the allocation size is unchecked. 150 00:18:24,150 --> 00:18:30,350 So, what about this, um, small security, uh, um, flaw? 151 00:18:30,830 --> 00:18:34,490 This small undiscovered issue can cause, uh, afterwards. 152 00:18:35,410 --> 00:18:39,350 Uh, but you still remember the previous picture, yeah. 153 00:18:39,350 --> 00:18:43,690 Uh, assuming we had located, uh, we already allocated four, uh, region. 154 00:18:43,690 --> 00:18:55,470 Uh, the size of the first region is 0x1000, so the start of, start offset of the second region, uh, is actually, will be one, 0x1000. 155 00:18:55,470 --> 00:19:06,850 Based on the info in the picture, we can know a starting offset of the region three is 0x, uh, 4000, uh, which is pretty easy to understand and, uh, calculate it. 156 00:19:06,850 --> 00:19:16,270 Uh, so based on the, this, uh, info we know, we can see how unchecked section, unchecked, uh, section size, uh, we can do in the following. 157 00:19:17,550 --> 00:19:28,250 Uh, if we allocated, uh, which region was extremely big size, 0x002 is actually minus, uh, FFFE. 158 00:19:28,470 --> 00:19:36,910 Uh, based on the region, uh, and the view granularity, the final offset of region two is actually will be zero. 159 00:19:36,910 --> 00:19:40,330 So, the allocation size, uh, will be still zero. 160 00:19:40,330 --> 00:19:41,910 So, what does this mean? 161 00:19:42,510 --> 00:19:50,990 Uh, uh, this means that the region two will overlap with the region one, and they will be mapping to the same physical address. 162 00:19:51,350 --> 00:20:03,390 Uh, we can use the view one to send and receive the LLPC message, and this view will be protected by the LLPC kernel, by using secure view against the write, uh, function. 163 00:20:03,470 --> 00:20:07,670 But the second view will be left, and the kernel will do nothing on it. 164 00:20:07,770 --> 00:20:17,230 So, because we don't even use it, um, so we can use the address of the second region, it actually change, um, the content. 165 00:20:17,230 --> 00:20:20,790 It's writable, so the double fish will happen again. 166 00:20:20,790 --> 00:20:26,210 Uh, the secure view, uh, write against the write function, uh, can't protect you anymore. 167 00:20:26,910 --> 00:20:31,410 So, it is, uh, there will be many, still many questions, uh, for you. 168 00:20:31,550 --> 00:20:36,850 Uh, as you see in the previous page, uh, the region allocation size is zero. 169 00:20:36,850 --> 00:20:51,770 Uh, so while you still can change the content of the shared memory, um, you know, because, uh, the map view function support mapping size of zero, uh, you allocate a page with size, uh, one page by default, so we don't need to worry about it. 170 00:20:52,030 --> 00:21:00,530 And the second, if you set the map view function, it cannot, uh, cannot, it can't accept zero size? 171 00:21:00,530 --> 00:21:02,050 Why don't you pass zero size? 172 00:21:02,050 --> 00:21:04,330 Uh, because it's unacceptable. 173 00:21:04,330 --> 00:21:12,910 There was a, there's a check, uh, before the allocation, uh, allocate the view, create view, create, uh, section view function. 174 00:21:12,910 --> 00:21:26,870 It's also, um, the region object can't use it in more than two views, uh, but the situation I've never encountered, uh, uh, so let's, uh, rest again on the Windows 11 again. 175 00:21:27,150 --> 00:21:33,930 Uh, based on the custom, uh, PC service, uh, we created, uh, two views with the same section offset. 176 00:21:34,630 --> 00:21:41,270 So, uh, overlap happened, and the kernel only secured the first view, uh, leaving the second view at address writable. 177 00:21:41,270 --> 00:21:49,530 So you can see, we successfully changed the content of the, uh, service, uh, parameter without changing the protection of the, uh, first view. 178 00:21:49,870 --> 00:21:53,090 Uh, the RPC services, uh, will be vulnerable again. 179 00:21:53,170 --> 00:21:55,810 So we have already win the race. 180 00:21:56,750 --> 00:22:06,030 So, from the page table entry, uh, from the win debug, uh, you can see two address pointed to same pages frame, uh, page frame number. 181 00:22:06,030 --> 00:22:09,870 It means that it's been to the, uh, pointed to the same physical memory. 182 00:22:10,430 --> 00:22:16,810 And, uh, we can see from the protection, we break into the debug when server trying to, uh, print the stream from client. 183 00:22:16,810 --> 00:22:25,590 So, the first page is, uh, read only, and it's writable, but it's, uh, the second page is writable, uh, on the same physical memory. 184 00:22:25,590 --> 00:22:30,070 Uh, which will result in confirm our ideas, and the result is the result from the terminal. 185 00:22:31,830 --> 00:22:35,290 So, from the exploitation analyze. 186 00:22:38,290 --> 00:22:44,130 Uh, so let's discuss some, uh, possible exploitation, uh, from the assessment before. 187 00:22:44,270 --> 00:22:46,750 Uh, there's two way to, uh, exploit. 188 00:22:46,830 --> 00:22:55,970 Uh, one is, uh, you can use Windows services, or third party services using, uh, file operations, uh, for exploitation techniques. 189 00:22:56,030 --> 00:23:16,230 Uh, use, uh, created by Jamf Spatial, uh, change to write system DLL, or, and get any, uh, system privilege, or bypass some security check in, and access some functions, uh, which, uh, the main user, uh, can access, or bypass, uh, UAC on, UAC on the Windows 11. 190 00:23:16,970 --> 00:23:23,290 Uh, uh, the, on the other side, we can also use, uh, memory corruption, uh, exploitation techniques. 191 00:23:23,990 --> 00:23:32,570 Uh, firstly, I can almost crush any RPC services, or over ARPC services, and even can get system shell. 192 00:23:33,230 --> 00:23:40,770 So, I must, uh, admit that, uh, I'm lazy sometimes, just want to make the exploitation as easy as possible. 193 00:23:40,770 --> 00:23:44,630 So, unfortunately, uh, Microsoft is also stupid. 194 00:23:44,850 --> 00:23:54,230 Uh, they were deleted the services code, which, uh, several years ago, that Thomas used to exploit, uh, to exploit this type of issue. 195 00:23:54,530 --> 00:23:57,550 Uh, we need to find, uh, another possible way. 196 00:23:57,810 --> 00:24:03,010 But, however, it's likely possible to find the RPC services, uh, meet, uh, these conditions. 197 00:24:03,010 --> 00:24:04,850 It's impossible, I think. 198 00:24:05,050 --> 00:24:14,170 Uh, first, uh, the service need to use the shell memory without copying it to another address, and also need to have some sensitive operations on the file. 199 00:24:14,410 --> 00:24:19,770 So, consider this, uh, situations, it's almost impossible to find this kind of service. 200 00:24:19,770 --> 00:24:22,410 At least, I didn't find one. 201 00:24:22,410 --> 00:24:23,870 Uh, you can try it. 202 00:24:23,870 --> 00:24:28,890 Uh, but I think it's possible on some, uh, third party, uh, services. 203 00:24:31,450 --> 00:24:36,050 Uh, next, we should know what kind of, uh, argument can we use to double fish. 204 00:24:36,050 --> 00:24:43,650 Uh, simple structure or pointed, uh, like, uh, integer pointers, string, uh, double string use, uh, shell memory. 205 00:24:43,670 --> 00:24:52,010 Uh, the context structure is also, you call, uh, you may not call, you may know it's called the longest struct, uh, without copying to heap buffer. 206 00:24:52,690 --> 00:24:58,190 Uh, you may confuse about what is the, uh, complex, uh, or simple structure. 207 00:24:58,190 --> 00:25:05,110 To put it simple, uh, you just remember, if a structure contains a pointer, it will be a complex structure. 208 00:25:06,830 --> 00:25:11,010 Uh, this is the example of the simple complex structure, uh, we've seen. 209 00:25:11,010 --> 00:25:15,010 Uh, and they were, uh, treated differently when RPC unmashered them. 210 00:25:15,130 --> 00:25:21,990 Uh, and above is, uh, Bambi's structure, uh, which we will never use, uh, uh, in the shell memory. 211 00:25:21,990 --> 00:25:28,370 So, which below is the example of the, uh, complex structure ? 212 00:25:28,370 --> 00:25:32,510 Uh , so we need to understand RPC format and the type format first. 213 00:25:32,650 --> 00:25:41,170 And, uh, proc format is, uh, one server function infos, uh, parameter type, and, uh, store the, uh, it's stored offset, uh, inside the parameter. 214 00:25:41,630 --> 00:25:59,030 And, for example, if we have, uh, output one function in server side, uh, the proc format will generate, uh, IDL, uh, compiler from the compiler, uh, storing the parameter into, like, the parameter type offset and the location info of the parameter. 215 00:25:59,210 --> 00:26:01,990 And the IDL compiler also generates the comment for every... 216 00:26:02,950 --> 00:26:03,470 Oh 217 00:26:07,910 --> 00:26:08,730 , I see. 218 00:27:48,830 --> 00:27:59,170 Oh, it's okay now? 219 00:27:59,850 --> 00:28:00,670 Yeah. 220 00:28:01,010 --> 00:28:06,770 And then we can see, uh, the difference between, uh, the simple and, uh, complex structure in, uh, type format. 221 00:28:09,670 --> 00:28:15,950 Okay, the proc mark, uh, give us where the parameter type definition located in the type format string. 222 00:28:15,950 --> 00:28:20,350 So we can see different, uh, between the simple and the complex structure. 223 00:28:21,230 --> 00:28:23,870 In the header flag, you can see them in the comment. 224 00:28:24,690 --> 00:28:29,850 Uh, there's three situation buffer flow I can cause. 225 00:28:30,170 --> 00:28:36,530 Uh, I try to find the exploitation services by code auditing, uh, or faster contents. 226 00:28:36,790 --> 00:28:42,350 Uh, but one, uh, one condition is inside the RPC, uh, string marshal function. 227 00:28:42,350 --> 00:28:44,550 Uh, the pre-memory content we can control. 228 00:28:44,550 --> 00:28:49,050 So one service has multiple output string, uh, result sending to the client. 229 00:28:49,050 --> 00:28:52,830 So it's also, well, we use the shared memory to send to the client. 230 00:28:52,830 --> 00:28:56,910 So we can fill the whole shared memory and the argument gap. 231 00:28:57,210 --> 00:29:04,250 Assuming the first string is 0x50 less and the second is 0x50 less. 232 00:29:04,250 --> 00:29:12,850 So we can fill the argument gap in the memory, uh, after the server finished the subcode and returned to the RPCRT4. 233 00:29:12,850 --> 00:29:16,930 And the client size will be over 0x1000. 234 00:29:17,030 --> 00:29:22,450 So it's the maximum size in shared memory will cause the crash of the service. 235 00:29:24,070 --> 00:29:33,170 And, uh, also another heap operation, uh, which means, uh, uh, which means the size of the string store, uh, in side a pointer. 236 00:29:33,170 --> 00:29:36,090 So it's not easy to find this part of the server. 237 00:29:36,090 --> 00:29:42,250 So we can change the size of the string when the server on marshal, the server resulting in the string, uh, sending to the client. 238 00:29:42,290 --> 00:29:47,770 Uh, however, it's still, uh, uh, possible, not possible to exploit. 239 00:29:47,770 --> 00:29:51,970 You can only cause the shared memory output, uh, outbound read. 240 00:29:51,970 --> 00:29:55,970 Uh, so when calling the pre-memory function, so it's a pity. 241 00:29:56,610 --> 00:30:03,630 And, uh, third exploitation is, uh, spore service, uh, uh, spore server service. 242 00:30:03,630 --> 00:30:08,230 Uh, when it opened a printer, it will double check, access the name of the printer. 243 00:30:08,230 --> 00:30:19,550 And the first time, uh, the server will cause WCs, a string result, uh, offset, uh, can be a large offset and then allocate a string again. 244 00:30:19,650 --> 00:30:22,190 And I recalculated the string length. 245 00:30:22,190 --> 00:30:24,390 So this time the string can be small size. 246 00:30:24,410 --> 00:30:28,970 So you will cause out of bound write a null pointer, a null bytes. 247 00:30:29,130 --> 00:30:31,770 Uh, but this issue is how to exploit. 248 00:30:31,770 --> 00:30:38,830 So we also need to win the race and the doing heap feng shui, uh, to construct some usable target. 249 00:30:39,170 --> 00:30:41,130 So it's really a huge challenge. 250 00:30:41,130 --> 00:30:43,510 So, um, what should I do? 251 00:30:43,510 --> 00:30:47,130 So I decided to, uh, try to do some easy stuff first. 252 00:30:47,690 --> 00:30:48,990 Let's see. 253 00:30:49,150 --> 00:30:51,930 Uh, we're passing UIC. 254 00:30:52,470 --> 00:30:54,150 Uh, how is it works? 255 00:30:54,230 --> 00:31:01,730 Uh, the key function inside the application information service, uh, in a UIC, uh, service. 256 00:31:02,190 --> 00:31:09,070 Uh, luckily the service access the command line argument from the shared memory, uh, without copying it to the heap buffer. 257 00:31:09,070 --> 00:31:12,550 So we can have a chance to use this. 258 00:31:12,550 --> 00:31:19,690 Um, and also the program name and the CMD line argument are also stored in the shared memory. 259 00:31:19,990 --> 00:31:22,670 Uh, the UIC has a special feature. 260 00:31:22,670 --> 00:31:27,730 Uh, when the client executes some special program, you have not launched the save confirm window. 261 00:31:27,730 --> 00:31:35,750 So we can use the features to launch the arbitrary program without any launch any confirm window, uh, from APP info service. 262 00:31:35,910 --> 00:31:37,530 So we can bypass it. 263 00:31:38,570 --> 00:31:41,890 Uh, it's also not the easy as we analyzed. 264 00:31:42,030 --> 00:31:45,310 Uh, there's a white list, uh, inside the service. 265 00:31:45,330 --> 00:31:57,070 Uh, you should know that it is also argument the white list, uh, for some special program, uh, which you can, which you not, not, you not, not need to launch the, uh, confirm window. 266 00:31:58,090 --> 00:32:04,250 Uh, so also the new process, uh, we launched the by IPP info service, uh, will suspend the first. 267 00:32:04,250 --> 00:32:07,250 That means that we still cannot execute our payload. 268 00:32:07,250 --> 00:32:24,470 So server will check the process image section with the program file section, uh, means although we have a launch, uh, malicious program result, confirm window, the IPP info, well, every info service or also, um, launch, launch the, uh, confirm window because the true image are not the same. 269 00:32:24,870 --> 00:32:32,270 So it's, Microsoft is not stupid, stupid, really a good solution to prevent a launching from any malicious program. 270 00:32:32,270 --> 00:32:37,890 So, but unfortunately they, uh, doesn't check the argument program by launch. 271 00:32:37,890 --> 00:32:42,090 Uh, after the launching the program, it doesn't know, doesn't the check the argument. 272 00:32:42,830 --> 00:32:45,330 So we still have to change. 273 00:32:45,690 --> 00:32:58,670 Uh, the good thing is we can create a malicious MSCC file and there's just a research on the MSCC file when MSCC, uh, open and auto-launch the CMT shell, uh, with a malicious strip. 274 00:32:58,670 --> 00:33:05,230 Uh, you know, service.msc is in the white list of the UIC, uh, UIC services. 275 00:33:05,570 --> 00:33:13,340 So, uh, we can see, launch a high integrated command line shell without any other problem. 276 00:33:13,560 --> 00:33:16,840 Uh, but I'm not satisfied in doing this. 277 00:33:16,840 --> 00:33:19,920 Uh, it's even not a vulnerability to Microsoft. 278 00:33:19,920 --> 00:33:25,400 So you should be an administrator first and a main system to the system. 279 00:33:25,400 --> 00:33:28,960 It's not a security boundary as we seen from the, uh, Microsoft. 280 00:33:31,220 --> 00:33:33,580 So last is, uh, get system privilege. 281 00:33:33,620 --> 00:33:37,980 Uh, another good thing is, it's truly exploitable. 282 00:33:38,680 --> 00:33:41,820 Uh, I found a service in DCOM launch. 283 00:33:42,080 --> 00:33:53,080 Uh, the key is that key service in Windows system, uh, interface, uh, normal user can access, uh, the list, uh, the service dual ID, service, uh, uh, pass. 284 00:33:53,380 --> 00:34:01,200 So, and the service function, uh, I used to exploit, uh, it's a game, get game name, uh, config. 285 00:34:01,200 --> 00:34:01,940 Yeah. 286 00:34:02,120 --> 00:34:03,960 It's truly, and it's true. 287 00:34:03,960 --> 00:34:08,760 And the three parameter with simple structure means the service can use the shared memory. 288 00:34:08,760 --> 00:34:12,540 It would obviously get the execution from the start point. 289 00:34:15,000 --> 00:34:17,700 And that's the first parameter is the dual ID stream. 290 00:34:17,700 --> 00:34:21,060 It's come from the registry, uh, representing a game. 291 00:34:21,060 --> 00:34:26,320 As you know, dual ID in the picture, uh, this dual ID represent the battlefield. 292 00:34:26,320 --> 00:34:29,740 I think some of you might played it before. 293 00:34:29,960 --> 00:34:41,820 Uh, most importantly is the key is a key is fully controlled by the current user because every user in the system have the, uh, 80 independent, uh, game store configuration in the user hive. 294 00:34:41,840 --> 00:34:46,420 So you can just traverse the key, current key and the final one. 295 00:34:46,580 --> 00:34:50,000 Uh, next we may start, what can we do in the service? 296 00:34:50,080 --> 00:34:55,280 Uh, because we cannot pass in the, uh, uh, parameters through the shared memory. 297 00:34:55,280 --> 00:34:57,640 So we can, uh, pretty lucky. 298 00:34:57,640 --> 00:35:02,160 We can do memory leak and array buffer or array overflow in this function. 299 00:35:02,440 --> 00:35:10,180 So first the function directly write a string, uh, pointer to the shared memory, which means we can leak the shared memory address mapped in the server side. 300 00:35:10,280 --> 00:35:15,940 Although the memory is unmapped after the request, but the address will never change. 301 00:35:15,940 --> 00:35:25,960 So we can use the shared memory to construct our fake object and the V tables and the plus this stack array buffer floor upon access. 302 00:35:25,960 --> 00:35:37,920 And after the information leak on the share memory, you can see the function directly use the index from the share memory and the writer share memory or the dress a pointer out of a bond on the stack. 303 00:35:37,920 --> 00:35:43,020 Uh, this means that we can do info leak and the stop off for all floor, uh, just in one function. 304 00:35:43,220 --> 00:35:47,640 And, uh, it's a good and, uh, really, and the good right pump primitive. 305 00:35:49,280 --> 00:35:52,660 Uh, this is just a strategy, a strategy I use. 306 00:35:52,660 --> 00:36:05,320 Uh, the first I need to leak the share memory address and we just, uh, call the server function and the, you know, those thread to repeatedly read the share memory so we can get the pointer. 307 00:36:05,820 --> 00:36:08,780 And when we get the share memory, we can create a fake object. 308 00:36:08,780 --> 00:36:12,280 The V table are based on the liquid information in the step one. 309 00:36:12,340 --> 00:36:23,420 And then finally, uh, we can try to change the index of the share memory to trick the stack array, uh, floor, overflow to load our evil DRL to the service and to get system shell. 310 00:36:24,260 --> 00:36:26,840 Uh, I'll show you one step up by step. 311 00:36:26,860 --> 00:36:30,660 And this is, uh, I'll put on the windy bug window. 312 00:36:30,660 --> 00:36:33,680 We can see several right the share memory pointer on the share memory. 313 00:36:33,680 --> 00:36:40,860 We just read it repeatedly from the kind until, uh, we read the, uh, pointer, share, share pointer. 314 00:36:41,380 --> 00:36:43,140 Uh, next the real problem cam. 315 00:36:43,140 --> 00:36:48,920 So we can get a staff or a buffer or floor, but, uh, how and where to write, right. 316 00:36:48,920 --> 00:36:50,160 I don't know what to write. 317 00:36:50,260 --> 00:36:53,480 Uh, I choose to write the RPC message object on the stack. 318 00:36:53,920 --> 00:37:00,520 Uh, first the RPC message is a member in MIT or some message and the object is allocated on the stack. 319 00:37:00,520 --> 00:37:04,800 So before I see you call the server, it's easy to over override it. 320 00:37:04,880 --> 00:37:07,960 And there's all the share memories, uh, not executable. 321 00:37:07,960 --> 00:37:10,580 So we can just overwrite and the return. 322 00:37:10,580 --> 00:37:16,360 If we choose to override the return address, uh, we cannot directly do the ROP. 323 00:37:17,200 --> 00:37:21,880 Uh, uh, let's see what we write from the view of the wind debug. 324 00:37:21,880 --> 00:37:23,780 Uh, RCX is a rain decks. 325 00:37:23,780 --> 00:37:25,660 Uh, we can fully a contrary it. 326 00:37:25,660 --> 00:37:30,340 RX is a shimmer memory address and then we also can't fully control it. 327 00:37:30,340 --> 00:37:34,720 So you can see, uh, we easily override RPC message pointer on the stack. 328 00:37:35,000 --> 00:37:39,820 So when a server you turn to RPC core engine, it will be operated on the fake object. 329 00:37:40,440 --> 00:37:47,700 Uh, so we can see from the engine call NDR get buffer RCX already being the share memory address. 330 00:37:48,220 --> 00:37:50,620 And this is a layout of the share memory. 331 00:37:50,800 --> 00:37:55,200 Uh, there's also some type check, uh, because we can't fully control it. 332 00:37:55,200 --> 00:37:56,260 So it's not a problem. 333 00:37:56,380 --> 00:38:09,560 Uh, I choose to construct that fake RPC binding handle, uh, in the share memory, uh, real problem cam, uh, where you can see finally you arrive to the virtual function calling. 334 00:38:09,560 --> 00:38:11,720 It's a XFG check. 335 00:38:12,040 --> 00:38:26,240 Um, the first, uh, uh, of a table and, um, uh, I want to actually low, uh, uh, directly call to the load library, but you can see, uh, the V table and the, uh, first parameter is overlapped. 336 00:38:26,240 --> 00:38:30,600 So we can directly onto, we can not directly call the load library. 337 00:38:30,720 --> 00:38:35,000 Uh, so, uh, we can always find a way. 338 00:38:35,000 --> 00:38:42,220 Uh, if I can directly call a load library, I can find a legal callable function to, to register pivoting. 339 00:38:42,220 --> 00:38:51,200 So we know there's a technique, uh, called a stack pivoting in CTF exportation techniques where you can directly RP on the current stack. 340 00:38:51,580 --> 00:38:58,440 So for the register pivoting, I just need to find a function which can exchange the content of the register RCX. 341 00:38:58,640 --> 00:39:03,140 And, uh, uh, then the register were appointed to the DRL pass. 342 00:39:03,140 --> 00:39:06,040 And luckily I found this kind of, uh, uh, function. 343 00:39:06,040 --> 00:39:06,980 It can't reach your cage. 344 00:39:06,980 --> 00:39:07,740 It's changed. 345 00:39:07,740 --> 00:39:11,340 The register is inside the combats DRL. 346 00:39:11,340 --> 00:39:11,640 Okay. 347 00:39:11,640 --> 00:39:16,840 Directly called bypass the XFG check is a callback function. 348 00:39:16,840 --> 00:39:18,400 And this is a layout. 349 00:39:19,120 --> 00:39:29,840 Uh, RCX is before we call into the callback, it's pointing to bind handle object and the value in a purple color is the type of information and the callback function. 350 00:39:29,840 --> 00:39:36,530 Uh, we can call low libraries with log in function to with the DRL pass in the second parameter. 351 00:39:36,730 --> 00:39:44,850 So luckily before the control for all check, the validity of the callback function, the function is not the first member of the Vtable is at the 0x70. 352 00:39:44,850 --> 00:39:48,750 So the start location of the Vtable we can use to put out with DRL pass. 353 00:39:49,050 --> 00:39:53,910 Uh, so without worrying about the function validity because we were never used. 354 00:39:54,670 --> 00:39:58,730 So then we can load our custom DRL without any resistance. 355 00:39:58,730 --> 00:39:59,750 Yeah. 356 00:40:00,060 --> 00:40:02,660 And I will show you the demo. 357 00:40:07,430 --> 00:40:09,980 I use a, uh, a normal user. 358 00:40:10,960 --> 00:40:25,900 It's a user group and I write it in all the POC in that person and you can see is a normal user with a medium privilege. 359 00:40:25,900 --> 00:40:28,160 It's not in our administrator group. 360 00:40:30,570 --> 00:40:31,130 Okay. 361 00:40:31,130 --> 00:40:38,050 And then we check the DECOM service to see if we can load our malicious DRL. 362 00:40:41,130 --> 00:40:41,790 Okay. 363 00:40:41,790 --> 00:40:54,970 We can see the shared memory and the COM base and we see we already know that our evil DRL and there's a shell coming and we type who am I and we get a system privilege. 364 00:40:55,470 --> 00:40:57,570 It's all the privilege. 365 00:41:02,160 --> 00:41:03,180 Thank you. 366 00:41:03,180 --> 00:41:03,560 Thank you. 367 00:41:03,560 --> 00:41:04,000 Thank you. 368 00:41:11,410 --> 00:41:12,990 Oh, thank you. 369 00:41:17,530 --> 00:41:19,970 And, uh, a conclusion. 370 00:41:19,970 --> 00:41:20,930 So the voices. 371 00:41:20,930 --> 00:41:30,330 So to be continue, um, I think there's still some research I need to do in the future. 372 00:41:31,230 --> 00:41:37,150 I like the automation info extract from the RPC interface. 373 00:41:37,150 --> 00:41:42,950 I need to find this, um, exportation service and the argument which made the exportation bar. 374 00:41:42,950 --> 00:41:52,810 Uh, if you have any good ideas and you can please share it to me, I also want to know some good ideas for the two develop developing. 375 00:41:52,970 --> 00:42:02,590 And there's a much special, more, uh, special features in RPC and the need to be X mind and the more effective exportation techniques. 376 00:42:02,590 --> 00:42:06,410 If you're on the other, any good ideas, feel free to contact me. 377 00:42:06,410 --> 00:42:07,390 Yeah. 378 00:42:09,190 --> 00:42:09,750 Yeah. 379 00:42:09,750 --> 00:42:12,870 And the right Bob, uh, this is our bunk hunting experience. 380 00:42:12,870 --> 00:42:17,190 I want to share with you and the first don't trust any patches from the render. 381 00:42:17,190 --> 00:42:20,750 It may still not patch the vulnerability effectively. 382 00:42:20,750 --> 00:42:25,310 And also the patch analyze is still more effect in back hunting. 383 00:42:25,590 --> 00:42:31,250 You should be more creative and the criticizing when criticizing, when back hunting. 384 00:42:31,250 --> 00:42:31,850 Yeah. 385 00:42:31,850 --> 00:42:35,990 You should dare to do it and we should be patient. 386 00:42:36,370 --> 00:42:39,030 But bunk hunting is a long way medicine. 387 00:42:39,870 --> 00:42:45,790 And our last, uh, don't meet any, meet any, miss any other, any side effect. 388 00:42:45,790 --> 00:42:49,890 This effect may cause security flaw afterwards. 389 00:42:51,350 --> 00:42:52,630 Yeah. 390 00:42:53,150 --> 00:43:00,650 And, uh, this, uh, for this type of service, uh, we mentioned in the talk, there's still much special feature is the RPC RPC. 391 00:43:00,950 --> 00:43:05,930 Uh, we need to XMI and the security of RPC is actually effect. 392 00:43:05,930 --> 00:43:14,750 The security of the RPC, uh, for Microsoft, uh, we can see it's really done a great tireless works on the security of the RPC services. 393 00:43:14,750 --> 00:43:26,490 Although we cause the double fish in the RPC services, uh, we need to still find the, uh, export both service in the, and the parameters still meet us very strict bars. 394 00:43:27,630 --> 00:43:30,030 And this is a reference of our talk. 395 00:43:31,070 --> 00:43:32,590 And, uh, thank you. 396 00:43:32,590 --> 00:43:33,790 Uh, is there another questions? 397 00:43:33,790 --> 00:43:37,290 Uh, because there is a microphone has any problems and sorry for that. 398 00:43:37,290 --> 00:43:37,810 Yeah. 399 00:43:50,580 --> 00:43:51,660 Oh, thank you.