1 00:00:02,180 --> 00:00:03,660 Hey everybody, how's it going? 2 00:00:05,420 --> 00:00:06,740 My name is Michael Torres. 3 00:00:06,740 --> 00:00:09,360 I'm going to be talking about, uh, pseudo for Windows. 4 00:00:09,400 --> 00:00:11,960 Title of talk is Pseudos and Pseudonts. 5 00:00:13,060 --> 00:00:15,300 Here's a quick overview of what I'm going to talk about. 6 00:00:15,300 --> 00:00:21,180 You can read so I'm not going to bore you too much, but first we're going to go over what pseudo for Windows is because it sounds weird. 7 00:00:21,260 --> 00:00:25,680 Then we're going to hit, uh, some research, initial research on it, how it all works. 8 00:00:25,680 --> 00:00:29,100 Talk about some non-security issues according to MSRC. 9 00:00:29,100 --> 00:00:30,580 I'm supposed to use those words. 10 00:00:30,700 --> 00:00:33,280 Uh, then we're going to talk about some security issues that we found. 11 00:00:33,280 --> 00:00:35,540 One of them is unfortunately still under embargo. 12 00:00:35,580 --> 00:00:39,600 Talk more about how I found that one later, uh, but let's hit it. 13 00:00:40,920 --> 00:00:42,020 So who am I? 14 00:00:42,020 --> 00:00:45,480 Uh, I do operational technology security at Google. 15 00:00:45,480 --> 00:00:50,040 I also sort of do cyber depending on who you ask for the United States Marine Corps Reserve. 16 00:00:50,280 --> 00:00:56,320 I also volunteer my time with VETSEC which is a profit focused on helping, uh, veterans of the armed services for the U.S. 17 00:00:56,320 --> 00:00:59,520 and allied countries get careers in cyber security. 18 00:00:59,700 --> 00:01:04,400 I also just do random research projects like this that are not related to any of that when I get bored. 19 00:01:04,400 --> 00:01:05,660 So here I am. 20 00:01:07,920 --> 00:01:09,640 So what is pseudo for Windows? 21 00:01:09,640 --> 00:01:18,260 They, uh, Microsoft announced that they're going to introduce this utility in Windows 11 in the H2 update which usually drops around September, so in a month or so. 22 00:01:18,360 --> 00:01:22,280 It's currently an insider preview which is how I got access to test all this good stuff. 23 00:01:22,340 --> 00:01:32,360 The way it works at a very high level is it uses UAC, that standard process elevation thing to support the type of command line features you're probably used to if you use pseudo on Linux. 24 00:01:32,380 --> 00:01:37,320 So taking your input, your output, all that, putting it back into the prompt that you originally ran it in. 25 00:01:37,440 --> 00:01:42,880 Uh, that's both console input and output which are different on Windows than standard in, standard out, and standard error. 26 00:01:42,940 --> 00:01:46,240 It does this via fancy pipes and redirection and all that good stuff. 27 00:01:46,560 --> 00:01:47,620 It's written in Rust. 28 00:01:47,620 --> 00:01:49,380 It is now fully open source. 29 00:01:49,380 --> 00:01:54,140 At the time they just, at the time I did this research, they said it was open source but it wasn't published yet. 30 00:01:54,180 --> 00:01:58,400 Uh, which meant that I did a lot more work than I actually had to do but that's alright. 31 00:01:58,400 --> 00:02:00,220 That's what, that's what's fun I guess. 32 00:02:00,660 --> 00:02:05,160 Uh, I found two issues with, again, according to MSRC, no security impact. 33 00:02:05,160 --> 00:02:07,000 I have to use those words over and over again. 34 00:02:07,040 --> 00:02:10,840 One is a memory corruption issue which is fun cause like I said it's written in Rust. 35 00:02:10,840 --> 00:02:13,480 Uh, and the other one was a search order confusion issue. 36 00:02:13,480 --> 00:02:15,720 I found two issues with security impact. 37 00:02:15,720 --> 00:02:24,040 One allowed, uh, cross user code execution which, kind of sad, you don't really want other users to run code as you if you like your secrets being yours. 38 00:02:24,040 --> 00:02:29,600 And the other one allows you to data tamper the input and output data for sudo. 39 00:02:29,600 --> 00:02:33,360 And again I can't go into too much detail on that one but we'll talk more about it later. 40 00:02:35,340 --> 00:02:38,780 Most of my research was conducted against sudo version 1. 41 00:02:38,780 --> 00:02:43,860 Uh, you'll note that both of these bullet points say sudo version 1 but have different signature dates. 42 00:02:44,080 --> 00:02:45,260 I can't help you. 43 00:02:45,260 --> 00:02:51,080 They didn't increment the version number so I just had to use the signature date on the binary to distinguish the two. 44 00:02:51,280 --> 00:02:54,100 Uh, one is from February, one's from March. 45 00:02:54,100 --> 00:02:58,940 I don't know if they've released a more recent update cause I haven't checked in the last three weeks. 46 00:02:58,940 --> 00:03:02,780 So they might have but three weeks ago it was still the version from March. 47 00:03:05,680 --> 00:03:07,280 So precursor things to know. 48 00:03:07,280 --> 00:03:08,400 User account control. 49 00:03:08,400 --> 00:03:15,660 If you use Windows, which I assume most of you do cause you came to a talk about sudo for Windows, you've seen a user account control prompt, right? 50 00:03:15,660 --> 00:03:18,540 You always just hit yes cause you don't care what you're doing you just want it to work. 51 00:03:18,780 --> 00:03:24,440 Uh, the way it works is normal processes without elevation run in what's called medium integrity. 52 00:03:24,520 --> 00:03:38,200 That's pretty much everything except for processes or systems that are designed to use low integrity which quick shorthand is basically just web browsers in your PDF reader because they want that to have the absolute least privilege they can. 53 00:03:38,860 --> 00:03:43,480 Elevated processes, so the thing that runs once you hit that yes button cause you don't care you just want it to work. 54 00:03:43,480 --> 00:03:45,840 Uh, run as high integrity. 55 00:03:46,540 --> 00:03:58,000 Only processes running in high integrity are allowed to modify system resources which implicitly means that they can get system level permissions which is roughly equivalent to root on Windows, right? 56 00:03:58,820 --> 00:04:01,320 It's considered a defense in depth measure by Microsoft. 57 00:04:01,320 --> 00:04:03,240 They do not consider it a primary control. 58 00:04:03,240 --> 00:04:06,740 They do not consider UAC bypasses a security issue. 59 00:04:06,740 --> 00:04:07,640 They won't service them. 60 00:04:07,640 --> 00:04:09,480 They don't consider them part of bug bounty. 61 00:04:09,480 --> 00:04:28,660 Importantly for why sudo for Windows needs to exist, you can't spawn a process with UAC and inherit the standard in standard out standard error or console input and console output into the privileged process meaning that if you're in a command prompt and you try to run you know reg query as a privileged process, 62 00:04:28,660 --> 00:04:33,860 you can't then pipe that into another command or redirect it into a text file or something like that. 63 00:04:33,860 --> 00:04:37,920 It'll spawn it as a new process that can't put it back into your same window. 64 00:04:40,280 --> 00:04:44,020 Other things to know about uh the ALPC interface. 65 00:04:44,020 --> 00:04:46,060 It's an inter-process communications framework. 66 00:04:46,060 --> 00:04:50,640 It is officially undocumented and only used by Microsoft internal systems. 67 00:04:50,740 --> 00:04:56,880 The way it works is the server listens on a port which is just an object cause everything in Windows is an object. 68 00:04:56,920 --> 00:04:59,340 That port is just a string name. 69 00:04:59,340 --> 00:05:01,760 Sometimes it's a string as is the case with sudo. 70 00:05:01,760 --> 00:05:03,380 You can see the example there. 71 00:05:03,380 --> 00:05:06,900 Uh sometimes it's a GUID if it's a com object or things like that. 72 00:05:07,800 --> 00:05:20,120 The way that security is supposed to be implemented on ALPC is that the server can query attributes of the client like the process ID, the uh SID, the principal name and all of that of the caller. 73 00:05:20,120 --> 00:05:32,040 And the client is able to say I only want to connect to an ALPC server if it's also this SID or some other properties that I don't remember frankly and they're not in the slide so I'm not gonna remember them right now. 74 00:05:32,300 --> 00:05:43,160 Um the other thing to know is that in Rust if you want to use Windows native APIs like create process or shell execute X which are important if you're trying to run a process as an elevated user. 75 00:05:43,320 --> 00:05:48,040 Um you have to use one or you don't have to but Microsoft released two crates for it. 76 00:05:48,040 --> 00:05:50,940 Windows and Windows sys so those are first party owned by Microsoft. 77 00:05:50,940 --> 00:05:59,620 They both require you to run in unsafe Rust meaning that now we can get memory issues and buffer overreads and buffer overruns and all that good stuff. 78 00:05:59,740 --> 00:06:05,840 Um the only difference between Windows and Windows sys is the Windows crate does type coercion for you. 79 00:06:05,840 --> 00:06:13,480 So if you have a Rust string and you want to call a Windows API if you use the Windows crate you just give it the Rust string and magic happens. 80 00:06:13,480 --> 00:06:16,820 I don't really know Rust that well so sorry it just magically happens to me. 81 00:06:16,880 --> 00:06:23,220 Uh whereas with Windows sys you have to explicitly cast things into the right data type to get it to work in Rust. 82 00:06:25,840 --> 00:06:34,800 So Microsoft's blog post did actually include a fair bit of detail uh which was cool to see uh both from a security research perspective and just a curiosity perspective. 83 00:06:34,800 --> 00:06:38,020 It's cool to see them publish information about their tools like this. 84 00:06:38,120 --> 00:06:41,120 Uh there are three modes that Sudo for Windows supports. 85 00:06:41,120 --> 00:06:43,920 Those are new window, input closed and inline. 86 00:06:43,920 --> 00:06:48,760 The new window one is basically just the same as if you ran run as and then the command . 87 00:06:48,760 --> 00:06:50,680 So there's not really much novelty there. 88 00:06:50,680 --> 00:06:56,820 Uh the input closed and inline modes do this weird client server thing which you can see at the bottom uh right there. 89 00:06:56,920 --> 00:06:58,320 That sort of high level thing. 90 00:06:58,320 --> 00:06:59,700 We'll go into that more in a second. 91 00:06:59,700 --> 00:07:07,720 The difference between inline and input closed is in input closed the elevated process can't see the un-elevated console's standard end. 92 00:07:07,720 --> 00:07:17,500 So if you were to pipe the result of a command into a Sudo execution and your system is configured to run it in input closed mode, your elevated process won't be able to see it. 93 00:07:17,900 --> 00:07:26,220 They say that those are in order by most secure to least secure so new window being the most secure and inline being the least secure. 94 00:07:26,360 --> 00:07:33,120 Um they don't really go into a lot of details about that other than that it's it keeps things open for longer. 95 00:07:33,600 --> 00:07:37,560 Um again I mentioned earlier it in the blog post they say it's open source. 96 00:07:37,560 --> 00:07:38,760 They link to a GitHub repo. 97 00:07:39,080 --> 00:07:46,320 That GitHub repo was empty when I was doing this research so I just got to look at Rust code in Ghidra which if you haven't done it I don't recommend it. 98 00:07:46,540 --> 00:07:48,700 Um but now it's open source. 99 00:07:48,700 --> 00:07:50,600 You can go on GitHub and look at all their stuff. 100 00:07:50,700 --> 00:07:53,760 Um they included that diagram as I mentioned to explain the request flow. 101 00:07:53,760 --> 00:07:58,060 We'll go into that more in a second but you can see that there's a client server thing in there. 102 00:08:00,940 --> 00:08:07,560 So off the rip like this was actually found after the rest of this research because I was finally able to look at the source code. 103 00:08:07,560 --> 00:08:13,640 The new window mode still creates that RPC server so you're still able to do fun things with the RPC server. 104 00:08:13,980 --> 00:08:17,220 Um it doesn't always do what's on the tin. 105 00:08:17,220 --> 00:08:24,820 Sometimes it does actually pull in your standard in, standard out, standard error in your console input and console out and pipe it into the new process. 106 00:08:25,020 --> 00:08:33,440 Um again it's supposed to be the most secure uh but it does always get the standard in handle unlike the input disabled one. 107 00:08:33,660 --> 00:08:43,060 I don't know of any ways that that's necessarily a security issue but it's kind of an odd novelty because they describe it as being the most isolated from the unprivileged process perspective. 108 00:08:45,080 --> 00:08:57,740 So I started looking into this because I saw on Hacker News that veritable Y Combinator uh news aggregator that one of my co-workers at Google actually which I didn't know at the time made a blog post about Sudo for Windows and published some research. 109 00:08:57,800 --> 00:09:07,020 Um he pulled apart the RPC server some and found that at the time that RPC client server thing had zero authentication which is obviously very bad. 110 00:09:07,020 --> 00:09:11,740 That means you can just tell the server you would like to run a privileged command and it'll happily do it. 111 00:09:12,040 --> 00:09:14,880 Um that was fixed by the time I was testing it. 112 00:09:14,880 --> 00:09:15,900 Note that that's in quotes. 113 00:09:15,900 --> 00:09:18,940 Talk more about that in a minute. 114 00:09:18,940 --> 00:09:26,160 So I talked to again it pulled apart that RPC like client server API if you will and highlighted the methods of interest to call. 115 00:09:26,160 --> 00:09:28,340 Specifically that server do elevation API. 116 00:09:28,500 --> 00:09:33,240 That's what actually is called by the client into the server to coordinate execution. 117 00:09:33,300 --> 00:09:38,600 Passes handles that the process binds to and then you can get all your input and output and all that good stuff. 118 00:09:38,600 --> 00:09:49,660 It also passes a bunch of parameters relevant to the command being ran like the command to run, arguments to the command, the current working directory and optionally the environment depending on the flags you pass to sudo. 119 00:09:54,360 --> 00:09:57,820 Here is a more detailed look at run mode three in line mode. 120 00:09:57,820 --> 00:10:04,020 This is the one I did most of my research with because it is listed as the most insecure so it's probably the easiest target right? 121 00:10:04,020 --> 00:10:04,820 I'm lazy. 122 00:10:05,000 --> 00:10:14,100 Um you can see on the far side there you have the actual unprivileged console where the person runs sudo who am I and they're trying to run it as that elevated user. 123 00:10:14,100 --> 00:10:20,400 The way that works is it first spawns an elevated process to host that RPC service using normal run as. 124 00:10:20,400 --> 00:10:24,620 The user gets a prompt again they click yes like everyone does because they just want the thing to work. 125 00:10:24,940 --> 00:10:31,220 Um the client then sends an RPC into that privileged process telling it what command it wants to run. 126 00:10:31,400 --> 00:10:39,060 The privileged process binds to the handles that gets passed in there so that all your input output and standard error stuff just flows naturally. 127 00:10:39,520 --> 00:10:46,780 Privileged process that the user specified gets spawned and then magic happens you can do all your normal command line pipes and stuff. 128 00:10:48,940 --> 00:10:52,540 So summarizing everything we just talked about sort of high level notes. 129 00:10:52,540 --> 00:10:54,240 Uh it's written in Rust it's open source. 130 00:10:54,240 --> 00:10:59,160 Uh Rust requires you to enter into unsafe mode so again memory safety issues can happen. 131 00:10:59,160 --> 00:11:03,320 Uh to call Windows native APIs which things like this kind of have to do. 132 00:11:03,480 --> 00:11:09,780 Um and ALPC is what's used to coordinate the actual execution of the user specified process. 133 00:11:11,740 --> 00:11:15,140 So our first issue the memory safety issue in Rust. 134 00:11:15,240 --> 00:11:19,380 Um sort of odd right but as I just mentioned you have to use unsafe APIs. 135 00:11:19,380 --> 00:11:38,820 Uh they've removed this functionality before they published it to GitHub so I can't tell you exactly how it happened but at a high at a from my analysis what happened was if you gave a path that rewrote from the beginning meaning that you had a leading like backslash or C colon backslash right? 136 00:11:38,820 --> 00:11:49,880 It would write your path to the start and then when it passed it to an API function it didn't truncate at the end of where your path was it just read until the end of the buffer to the first null byte. 137 00:11:49,940 --> 00:12:06,300 I think that that happened because they assumed that a path as string would point to a null terminated buffer as you would kind of expect it to if you're used to C when in fact it just points to a vector of U8s that may or may not include a null byte at the end. 138 00:12:06,440 --> 00:12:45,980 Um here's sort of my mock up of the code uh you can pull these slides off the Defcon media server if you want to take a better look at it but this is just sort of demonstrating what I just talked about where if you assume that you can take the path as a string and then just get a pointer to it and pass it to the Windows API function you'll end up very sad because it'll just read until the first null byte not necessarily until the end of your target string meaning you have buffer over read in heap uh for arbitrary numbers of bytes that you can't necessarily control but because you can control the path you can control approximately how far into that heap buffer you read. 139 00:12:47,080 --> 00:13:18,200 Uh so like I just said you can read everything up to the first non-null byte you don't control which heap allocation you're reading and it doesn't let you write memory into arbitrary things that are outside of your heap boundary because it is rust it's a vector uh so it'll reallocate if you reach the capacity of the current heap allocation um but still you get to read things from previous heap allocations which in my testing tended to just be paths but it could be something like a token or something like that. 140 00:13:19,180 --> 00:13:46,760 Um it says at the bottom there why uh it's not really a security issue uh the main problem being this is only noticeable if you run pseudo with an unpro or a untrusted input which you shouldn't do anyway so it's not really security impacting if you run pseudo with arbitrary things someone you don't trust supplied and then you can read other memory because you shouldn't be doing that in the first place because you're going to execute someone else's code. 141 00:13:48,180 --> 00:14:15,020 This screenshot shows what I was talking about so you can see on the left there I run pseudo with a leading slash and then a path and then you can see in process monitor that at the end of the day a create file operation or trying to read the file um ends up re trying to read a file that's the thing that I was trying to read and then a bunch of things from presumably a previous heap allocation because that's the path that's the current working directory and then some garbage at the end until it reaches the first null byte. 142 00:14:18,130 --> 00:14:35,190 So the second issue uh search order inconsistency so in Windows just like actually I shouldn't say that I don't know if it's true in Linux but in Windows if you run a command without a path it is supposed to execute that command in the current working directory if it's present and then search your path. 143 00:14:35,570 --> 00:14:45,270 So if you run pseudoprogram.exe you expect it to run the program.exe in the current working directory not some other random program.exe. 144 00:14:46,130 --> 00:15:00,110 Path resolution didn't work that way the way it worked is again because of that client server thing it would try to resolve the path in the context of the privilege process which had a different current working directory meaning that you could end up running a command you didn't expect to run. 145 00:15:00,430 --> 00:15:14,270 Uh says up there it's a somewhat contrived example but if you had compiled your own binary and named it cmd.exe and then you tried to run pseudocmd.exe it wouldn't run your command.exe it would run the system32 command.exe. 146 00:15:14,270 --> 00:15:18,850 According to Microsoft it's not a vulnerability I have their exact response quoted there at the bottom. 147 00:15:20,210 --> 00:15:22,230 But they fixed it anyway. 148 00:15:22,690 --> 00:15:34,990 Um so they more or less looked up the in the unprivileged process they looked up the command you gave them and resolved it and then passed the fully resolved path into the privileged process. 149 00:15:35,250 --> 00:15:46,010 Um they fixed it I'm not going to complain too much but it's kind of odd that you accept input from people on what issues are fix them and then tell them yeah but we don't think it's a real issue. 150 00:15:48,050 --> 00:16:06,750 And this is a very well drawn I'm an artist if you didn't know uh example of how that would work from an attacker's perspective so you try to run command.exe you expect it to run yours it ends up running some other command in the privileged process path which isn't the one you wanted. 151 00:16:08,950 --> 00:16:18,030 So let's talk more about that RPC server again it's ALPC um source code wasn't available so I had to look in Giger to figure out what all these parameters meant. 152 00:16:18,030 --> 00:16:31,170 Uh I got pretty good results out of it I didn't know what those handles were or how to deal with them necessarily but luckily I didn't have to you can just bind to input and output without dealing or without worrying about the handles too much. 153 00:16:31,330 --> 00:16:47,230 Um importantly the unprivileged process ID so the one that you run before you hit that yes prompt as quick as humanly possible is what is used to create the socket name so it's predictable as long as you know the process ID that's uh trying to run sudo. 154 00:16:47,910 --> 00:17:05,990 And again I mentioned earlier after James Forshaw's blog post they added an authentication check which was checking that the client's process path so that unprivileged process was the same as the server's process path meaning both are running sudo.exe see windows system 32 sudo.exe right? 155 00:17:06,170 --> 00:17:17,870 Um over on the right side overview of that that off check on the right right just is the image name of my calling process the same as my image name if it is good to go we'll run your command. 156 00:17:19,690 --> 00:17:22,570 Which brings us to our first security issue. 157 00:17:22,570 --> 00:17:25,770 Um it turns out that that's not really a good authentication check. 158 00:17:25,770 --> 00:17:45,670 Um any user can issue elevation requests to that RPC server meaning that any user of a multi -user windows system to include you know unprivileged users because anyone can call an LPC socket like your web browser um can go ahead and run commands in the context of a user uh when they run sudo. 159 00:17:45,670 --> 00:17:53,570 So it's not latent I and a privileged user would have to try to run sudo and then you'd be able to exploit this to run it in the context of that user. 160 00:17:55,190 --> 00:18:18,190 Exploitation requires two things so like I mentioned insufficient authentication um the way I did that is I just injected a DLL into a sudo.exe sudo process that I controlled so that I could do whatever I want in the context of a process whose image name is the legitimate sudo.exe um and the other part of this was that predictable uh port name that predictable RPC control port name. 161 00:18:18,450 --> 00:18:25,910 Because users can view the process IDs of other users in Windows uh pretty much no matter what there are some types of tokens that can't do that. 162 00:18:25,910 --> 00:18:38,530 Uh you can get that information very easily and then you can just call the target sudo privileged sudo process and have it run whatever you command you want and gain execution in that user's context. 163 00:18:39,250 --> 00:18:45,830 This was patched in the version in the second version one of sudo the one that was uh code signed on the 4th of March. 164 00:18:47,090 --> 00:18:52,970 So again high level attack diagram you see at the top there we have our victim who's just trying to run sudo and get on with their day. 165 00:18:52,970 --> 00:18:57,030 We have we have our attacker with again I'm an artist very well drawn horns thank you. 166 00:18:57,090 --> 00:19:19,850 Um the attacker starts their code that's just waiting and find trying to find a victim sudo that is running and then as soon as it notices one it spawns its own sudo with a hooked method to connect to the target RPC server instead of one that it spawned uh to run whatever command the attacker wants. 167 00:19:19,850 --> 00:19:35,610 From the victim's perspective what this looks like is they ran sudo they as fast as humanly possible because again they're just trying to get the job done hit the yes button on the UAC prompt and then nothing happens from their perspective but in reality the attacker was able to run whatever command they wanted. 168 00:19:37,920 --> 00:19:40,300 Uh demo I think? 169 00:19:40,420 --> 00:19:41,640 Do I have that wrong? 170 00:19:42,020 --> 00:19:43,340 Hopefully it plays. 171 00:19:44,380 --> 00:19:46,600 Alright well that was surprising. 172 00:19:50,660 --> 00:19:57,480 So here I'm just showing there's nothing up my sleeve um uh the left prompt is gonna be our victim user so who am I? 173 00:19:57,480 --> 00:20:01,760 I'm MTU um it can run sudo just fine. 174 00:20:01,760 --> 00:20:06,260 The right prompt is now my unprivileged user or my non-administrative user not MTU. 175 00:20:06,260 --> 00:20:12,880 Right now I'm gonna show that uh sudo works and then that the base prompt is not running elevated. 176 00:20:13,000 --> 00:20:24,220 And then on the right on the right we're running that implant code that's just gonna spawn some stuff uh to try to target that victim sudo process. 177 00:20:24,220 --> 00:20:31,520 We are racing because if we don't beat the legitimate process um the RPC socket closes and we can't run our command. 178 00:20:31,520 --> 00:20:34,000 So we go slowly insane trying to win the race. 179 00:20:34,000 --> 00:20:43,600 I did test this in a debugger first so I was pretty confident it was supposed to work but man recording this video and just sitting there doing this for 2 minutes was not fun. 180 00:20:43,620 --> 00:20:56,520 Um at the end there you can see that it worked on the right side our unprivileged process again we were able to inject into that victim server process and run command.exe as this as the unprivileged user. 181 00:20:56,640 --> 00:21:02,080 We run whoami and we see that we're now running as that other user who is just trying to run something with sudo. 182 00:21:05,870 --> 00:21:09,110 Well I already played the video but we can play it again if you want. 183 00:21:10,390 --> 00:21:12,030 Oh nothing showing up there? 184 00:21:12,050 --> 00:21:12,870 Neat. 185 00:21:14,810 --> 00:21:16,570 Let's try it this way. 186 00:21:17,870 --> 00:21:18,790 Can you see this? 187 00:21:18,790 --> 00:21:19,950 This video now? 188 00:21:36,350 --> 00:21:46,370 So again uh again left prompt is the uh privileged user who's just trying to run sudo uh the right prompt that's about to spawn is the unprivileged user not MTU some evil attacker man. 189 00:21:46,870 --> 00:21:52,250 Um user runs command everything works. 190 00:21:52,310 --> 00:21:54,990 Let's see if I can skip this bit a bit. 191 00:21:55,430 --> 00:22:02,710 Um user keeps running command they keep working because you'll notice on the other side the attacker process is failing it's not winning that race. 192 00:22:02,710 --> 00:22:08,490 Uh like I mentioned I confirmed this in a debugger but still very frustrating watching it fail over and over and over again. 193 00:22:08,790 --> 00:22:15,390 Um but eventually it does work and we can see on that right side now we just got a command prompt back from the attacker's perspective. 194 00:22:15,410 --> 00:22:23,430 We run whoami and we see that we are running as a user other than ourselves which is not good I think is what it's called in the business. 195 00:22:31,700 --> 00:22:32,560 Alright. 196 00:22:34,520 --> 00:22:36,300 Uh work with me here. 197 00:22:36,300 --> 00:22:36,940 Nope. 198 00:22:40,360 --> 00:22:42,180 Yeah it's perfect. 199 00:22:42,380 --> 00:22:50,840 Um so I did find out after I tested this again after they made the source code available that they made that race window really short. 200 00:22:50,840 --> 00:23:01,520 So I assumed that the way it worked was the victim process ran its command successfully and then went ahead and uh then went ahead and closed the socket after it was done. 201 00:23:01,520 --> 00:23:06,300 In fact as soon as you called that elevation request API it locked all future calls of it. 202 00:23:06,300 --> 00:23:12,440 Which would explain why I had to run the command over and over again going slowly and sane until it worked. 203 00:23:12,440 --> 00:23:19,000 But I don't know not not really security control but good for them for locking out other users and thinking about it. 204 00:23:20,500 --> 00:23:24,320 So the second vulnerability I mentioned it's still under embargo unfortunately. 205 00:23:24,700 --> 00:23:30,300 Um I reported it 13th of June while the rest of this research was done April May time frame. 206 00:23:30,340 --> 00:23:35,380 Um sort of interesting story for you since I can't talk too much about the details of this one. 207 00:23:35,380 --> 00:23:46,320 The reason I thought of this was I was on a run trying to avoid working on the slides and I realized that there was some other issues with how they do that client server thing. 208 00:23:46,320 --> 00:23:57,040 So I was able to prove it out and get data tampering and information disclosure from again the process or the perspective of a non -privileged user on the privileged user's stuff. 209 00:23:59,320 --> 00:24:06,920 So public issues again it is a GitHub repo there are public issues uh that I think are sort of notable to talk about when we talk about Sudo for Windows. 210 00:24:06,920 --> 00:24:10,080 The first one um the elevation prompt is confusing. 211 00:24:10,080 --> 00:24:13,040 So there's a screenshot of it on the right you saw it earlier in the video. 212 00:24:13,360 --> 00:24:17,860 You don't know what hitting yes will do cause it's just telling you it's a Sudo invocation right? 213 00:24:17,860 --> 00:24:28,120 It doesn't tell you oh Sudo's actually gonna spawn this other process over here maybe you don't wanna do that it just says hi I'm Microsoft I'm a legitimate binary would you like me to run? 214 00:24:28,480 --> 00:24:31,440 Um not great from a security's perspective right? 215 00:24:31,460 --> 00:24:52,100 Admittedly again most of us probably just click yes as fast as humanly possible anyway or type in our credentials if we have that version of UAC enabled but um I believe that they committed to trying to figure out how to make it so it was more obvious what the actual command that's gonna run is instead of just saying yeah it's it says it's legitimate I'm just gonna hit yes and hope everything's okay. 216 00:24:52,440 --> 00:25:05,940 And the second issue uh which is critical to me because I like my computers to insult me is um Sudo for Linux or Unix if you will has a mode to have it insult you if you don't have legitimate access to run a command. 217 00:25:05,940 --> 00:25:10,520 Uh I want that in Windows cause I like my computers to be mean to me when I'm silly. 218 00:25:14,060 --> 00:25:16,160 So summary of everything we just talked about. 219 00:25:16,160 --> 00:25:17,460 Sudo for Windows is coming soon. 220 00:25:17,460 --> 00:25:28,180 Again it is scheduled to be in mainline Windows 11 and I think Windows server don't quote me on that one uh end of September-ish in the in the H2 update. 221 00:25:28,360 --> 00:25:44,880 Uh it's open source again we we love to see that it makes it so people like me or people like anyone in this audience can go look at the source code and pull it apart and understand not only how it works but maybe find some more security issues in it so we're not shipping products that are enabling bad things to happen on Windows. 222 00:25:44,880 --> 00:25:49,640 Or if you're on the other side of it using it to make bad things happen on Windows I don't know I don't judge. 223 00:25:49,980 --> 00:26:02,200 Um it is meant to be a drop in replacement for the way Sudo works on Linux so it lets you actually have standard in, standard out, standard air, piped and redirected and all that stuff within your command prompt or your PowerShell prompt. 224 00:26:02,440 --> 00:26:16,240 Um and it does all of that using user account control to elevate processes and inter-process uh communication to actually coordinate that across the not a trust boundary because that's not what Microsoft calls it of UAC. 225 00:26:16,380 --> 00:26:26,960 Uh sort of the big take away for me and it's informing some more stuff I'm looking into is you cannot call a Windows native API without going into unsafe rust. 226 00:26:27,200 --> 00:26:49,700 If you want to do that or for anything that uses a Windows API that means there is now the potential for you to get memory corruption act vulnerabilities in something written in rust which is counter to what everyone tells you about rust so be on the lookout for that if you're a bug hunter that if you see something calling a Windows native API from a rust program somewhere in that code it is unsafe. 227 00:26:49,700 --> 00:26:50,860 Poke at that boundary. 228 00:26:51,780 --> 00:26:59,440 And then I'll show some references and if anyone has any questions you can step up to that mic in the middle and I'll be happy to answer them. 229 00:26:59,580 --> 00:27:03,960 I don't know how much time I have left but I'll try to answer as many questions as I can. 230 00:27:08,850 --> 00:27:09,970 Thank you. 231 00:27:14,180 --> 00:27:15,100 Cool. 232 00:27:15,140 --> 00:27:16,360 Thanks everyone.