[00:02.180 --> 00:08.320] Hey everybody, how's it going? My name is Michael Torres. I'm going to be talking about, uh, [00:08.320 --> 00:14.340] pseudo for Windows. Title of talk is Pseudos and Pseudonts. Here's a quick overview of what [00:14.340 --> 00:17.820] I'm going to talk about. You can read so I'm not going to bore you too much, but first we're [00:17.820 --> 00:21.680] going to go over what pseudo for Windows is because it sounds weird. Then we're going to [00:21.680 --> 00:27.500] hit, uh, some research, initial research on it, how it all works. Talk about some non-security [00:27.500 --> 00:31.720] issues according to MSRC. I'm supposed to use those words. Uh, then we're going to talk about [00:31.720 --> 00:35.780] some security issues that we found. One of them is unfortunately still under embargo. Talk [00:35.780 --> 00:43.740] more about how I found that one later, uh, but let's hit it. So who am I? Uh, I do operational [00:43.740 --> 00:48.700] technology security at Google. I also sort of do cyber depending on who you ask for the [00:48.700 --> 00:52.920] United States Marine Corps Reserve. I also volunteer my time with VETSEC which is a profit [00:52.920 --> 00:57.700] focused on helping, uh, veterans of the armed services for the U.S. and allied countries get [00:57.700 --> 01:02.180] careers in cyber security. I also just do random research projects like this that are not [01:02.180 --> 01:10.300] related to any of that when I get bored. So here I am. So what is pseudo for Windows? They, uh, [01:10.300 --> 01:15.020] Microsoft announced that they're going to introduce this utility in Windows 11 in the H2 [01:15.020 --> 01:19.320] update which usually drops around September, so in a month or so. It's currently an insider [01:19.320 --> 01:23.860] preview which is how I got access to test all this good stuff. The way it works at a very high [01:23.860 --> 01:29.560] level is it uses UAC, that standard process elevation thing to support the type of command [01:29.560 --> 01:33.580] line features you're probably used to if you use pseudo on Linux. So taking your input, your [01:33.580 --> 01:38.060] output, all that, putting it back into the prompt that you originally ran it in. Uh, that's [01:38.060 --> 01:41.820] both console input and output which are different on Windows than standard in, standard out, [01:41.820 --> 01:46.840] and standard error. It does this via fancy pipes and redirection and all that good stuff. It's [01:46.840 --> 01:51.340] written in Rust. It is now fully open source. At the time they just, at the time I did this [01:51.340 --> 01:55.400] research, they said it was open source but it wasn't published yet. Uh, which meant that I did [01:55.480 --> 01:59.620] a lot more work than I actually had to do but that's alright. That's what, that's what's fun I [01:59.620 --> 02:05.460] guess. Uh, I found two issues with, again, according to MSRC, no security impact. I have to [02:05.460 --> 02:09.420] use those words over and over again. One is a memory corruption issue which is fun cause like [02:09.420 --> 02:13.940] I said it's written in Rust. Uh, and the other one was a search order confusion issue. I found [02:13.940 --> 02:19.540] two issues with security impact. One allowed, uh, cross user code execution which, kind of [02:19.540 --> 02:23.500] sad, you don't really want other users to run code as you if you like your secrets being [02:23.500 --> 02:29.900] yours. And the other one allows you to data tamper the input and output data for sudo. And [02:29.900 --> 02:35.900] again I can't go into too much detail on that one but we'll talk more about it later. Most of [02:35.900 --> 02:40.600] my research was conducted against sudo version 1. Uh, you'll note that both of these bullet [02:40.600 --> 02:45.560] points say sudo version 1 but have different signature dates. I can't help you. They didn't [02:45.560 --> 02:49.860] increment the version number so I just had to use the signature date on the binary to [02:49.860 --> 02:55.060] distinguish the two. Uh, one is from February, one's from March. I don't know if they've [02:55.060 --> 02:59.580] released a more recent update cause I haven't checked in the last three weeks. So they might [02:59.580 --> 03:07.280] have but three weeks ago it was still the version from March. So precursor things to know. [03:07.280 --> 03:11.960] User account control. If you use Windows, which I assume most of you do cause you came to a [03:11.960 --> 03:15.980] talk about sudo for Windows, you've seen a user account control prompt, right? You always [03:15.980 --> 03:20.000] just hit yes cause you don't care what you're doing you just want it to work. Uh, the way it [03:20.000 --> 03:25.000] works is normal processes without elevation run in what's called medium integrity. That's [03:25.000 --> 03:30.500] pretty much everything except for processes or systems that are designed to use low integrity [03:30.500 --> 03:35.280] which quick shorthand is basically just web browsers in your PDF reader because they want [03:35.280 --> 03:40.520] that to have the absolute least privilege they can. Elevated processes, so the thing that [03:40.520 --> 03:44.600] runs once you hit that yes button cause you don't care you just want it to work. Uh, run as [03:44.600 --> 03:51.040] high integrity. Only processes running in high integrity are allowed to modify system [03:51.040 --> 03:56.200] resources which implicitly means that they can get system level permissions which is roughly [03:56.200 --> 04:00.620] equivalent to root on Windows, right? It's considered a defense in depth measure by [04:00.620 --> 04:06.000] Microsoft. They do not consider it a primary control. They do not consider UAC bypasses a [04:06.000 --> 04:09.480] security issue. They won't service them. They don't consider them part of bug bounty. [04:09.480 --> 04:15.820] Importantly for why sudo for Windows needs to exist, you can't spawn a process with UAC and [04:15.820 --> 04:21.160] inherit the standard in standard out standard error or console input and console output into [04:21.160 --> 04:26.220] the privileged process meaning that if you're in a command prompt and you try to run you know [04:26.220 --> 04:31.480] reg query as a privileged process, you can't then pipe that into another command or redirect [04:31.480 --> 04:36.280] it into a text file or something like that. It'll spawn it as a new process that can't put it [04:36.280 --> 04:44.220] back into your same window. Other things to know about uh the ALPC interface. It's an [04:44.220 --> 04:48.680] inter-process communications framework. It is officially undocumented and only used by [04:48.680 --> 04:53.960] Microsoft internal systems. The way it works is the server listens on a port which is just an [04:53.960 --> 04:59.580] object cause everything in Windows is an object. That port is just a string name. Sometimes [04:59.580 --> 05:04.520] it's a string as is the case with sudo. You can see the example there. Uh sometimes it's a [05:04.520 --> 05:10.340] GUID if it's a com object or things like that. The way that security is supposed to be [05:10.340 --> 05:15.420] implemented on ALPC is that the server can query attributes of the client like the process [05:15.420 --> 05:21.880] ID, the uh SID, the principal name and all of that of the caller. And the client is able to [05:21.880 --> 05:28.560] say I only want to connect to an ALPC server if it's also this SID or some other properties [05:28.560 --> 05:31.260] that I don't remember frankly and they're not in the slide so I'm not gonna remember them [05:31.260 --> 05:36.880] right now. Um the other thing to know is that in Rust if you want to use Windows native APIs [05:36.880 --> 05:41.680] like create process or shell execute X which are important if you're trying to run a process [05:41.680 --> 05:47.100] as an elevated user. Um you have to use one or you don't have to but Microsoft released two [05:47.100 --> 05:51.300] crates for it. Windows and Windows sys so those are first party owned by Microsoft. They [05:51.300 --> 05:57.340] both require you to run in unsafe Rust meaning that now we can get memory issues and buffer [05:57.340 --> 06:01.600] overreads and buffer overruns and all that good stuff. Um the only difference between Windows [06:01.600 --> 06:08.000] and Windows sys is the Windows crate does type coercion for you. So if you have a Rust string [06:08.000 --> 06:12.280] and you want to call a Windows API if you use the Windows crate you just give it the Rust [06:12.280 --> 06:16.000] string and magic happens. I don't really know Rust that well so sorry it just magically [06:16.000 --> 06:20.560] happens to me. Uh whereas with Windows sys you have to explicitly cast things into the right [06:20.560 --> 06:28.640] data type to get it to work in Rust. So Microsoft's blog post did actually include a fair [06:28.640 --> 06:34.180] bit of detail uh which was cool to see uh both from a security research perspective and just a [06:34.180 --> 06:38.380] curiosity perspective. It's cool to see them publish information about their tools like this. [06:38.380 --> 06:43.200] Uh there are three modes that Sudo for Windows supports. Those are new window, input closed [06:43.200 --> 06:48.340] and inline. The new window one is basically just the same as if you ran run as and then the [06:48.340 --> 06:53.100] command. So there's not really much novelty there. Uh the input closed and inline modes do [06:53.100 --> 06:57.640] this weird client server thing which you can see at the bottom uh right there. That sort of [06:57.640 --> 07:01.420] high level thing. We'll go into that more in a second. The difference between inline and input [07:01.420 --> 07:07.300] closed is in input closed the elevated process can't see the un-elevated console's standard [07:07.300 --> 07:12.560] end. So if you were to pipe the result of a command into a Sudo execution and your system is [07:12.560 --> 07:18.300] configured to run it in input closed mode, your elevated process won't be able to see it. They [07:18.300 --> 07:24.400] say that those are in order by most secure to least secure so new window being the most [07:24.400 --> 07:28.440] secure and inline being the least secure. Um they don't really go into a lot of details about [07:28.440 --> 07:36.040] that other than that it's it keeps things open for longer. Um again I mentioned earlier it in [07:36.040 --> 07:40.200] the blog post they say it's open source. They link to a GitHub repo. That GitHub repo was [07:40.200 --> 07:44.560] empty when I was doing this research so I just got to look at Rust code in Ghidra which if you [07:44.560 --> 07:49.480] haven't done it I don't recommend it. Um but now it's open source. You can go on GitHub and [07:49.480 --> 07:53.380] look at all their stuff. Um they included that diagram as I mentioned to explain the request [07:53.380 --> 07:57.400] flow. We'll go into that more in a second but you can see that there's a client server thing in [07:57.400 --> 08:05.760] there. So off the rip like this was actually found after the rest of this research because I [08:05.760 --> 08:10.280] was finally able to look at the source code. The new window mode still creates that RPC [08:10.280 --> 08:16.220] server so you're still able to do fun things with the RPC server. Um it doesn't always do [08:16.220 --> 08:21.140] what's on the tin. Sometimes it does actually pull in your standard in, standard out, standard [08:21.140 --> 08:26.360] error in your console input and console out and pipe it into the new process. Um again it's [08:26.360 --> 08:32.040] supposed to be the most secure uh but it does always get the standard in handle unlike the [08:32.040 --> 08:37.300] input disabled one. I don't know of any ways that that's necessarily a security issue but it's [08:37.300 --> 08:41.380] kind of an odd novelty because they describe it as being the most isolated from the [08:41.380 --> 08:48.820] unprivileged process perspective. So I started looking into this because I saw on Hacker News [08:48.820 --> 08:53.640] that veritable Y Combinator uh news aggregator that one of my co-workers at Google actually [08:53.640 --> 08:56.920] which I didn't know at the time made a blog post about Sudo for Windows and published some [08:56.920 --> 09:03.200] research. Um he pulled apart the RPC server some and found that at the time that RPC client [09:03.200 --> 09:08.600] server thing had zero authentication which is obviously very bad. That means you can just tell [09:08.600 --> 09:13.020] the server you would like to run a privileged command and it'll happily do it. Um that was [09:13.020 --> 09:18.800] fixed by the time I was testing it. Note that that's in quotes. Talk more about that in a [09:18.800 --> 09:24.100] minute. So I talked to again it pulled apart that RPC like client server API if you will and [09:24.100 --> 09:28.340] highlighted the methods of interest to call. Specifically that server do elevation API. [09:28.500 --> 09:33.780] That's what actually is called by the client into the server to coordinate execution. Passes [09:33.780 --> 09:38.060] handles that the process binds to and then you can get all your input and output and all that [09:38.060 --> 09:43.080] good stuff. It also passes a bunch of parameters relevant to the command being ran like the [09:43.080 --> 09:47.420] command to run, arguments to the command, the current working directory and optionally the [09:47.420 --> 09:56.260] environment depending on the flags you pass to sudo. Here is a more detailed look at run mode [09:56.260 --> 10:00.980] three in line mode. This is the one I did most of my research with because it is listed as the [10:00.980 --> 10:06.760] most insecure so it's probably the easiest target right? I'm lazy. Um you can see on the far [10:06.760 --> 10:12.100] side there you have the actual unprivileged console where the person runs sudo who am I and [10:12.100 --> 10:16.820] they're trying to run it as that elevated user. The way that works is it first spawns an [10:16.820 --> 10:21.640] elevated process to host that RPC service using normal run as. The user gets a prompt again [10:21.640 --> 10:26.100] they click yes like everyone does because they just want the thing to work. Um the client then [10:26.100 --> 10:31.880] sends an RPC into that privileged process telling it what command it wants to run. The [10:31.880 --> 10:35.400] privileged process binds to the handles that gets passed in there so that all your input [10:35.400 --> 10:41.040] output and standard error stuff just flows naturally. Privileged process that the user [10:41.040 --> 10:45.540] specified gets spawned and then magic happens you can do all your normal command line pipes [10:45.540 --> 10:52.720] and stuff. So summarizing everything we just talked about sort of high level notes. Uh it's [10:52.720 --> 10:57.500] written in Rust it's open source. Uh Rust requires you to enter into unsafe mode so again [10:57.500 --> 11:02.640] memory safety issues can happen. Uh to call Windows native APIs which things like this kind [11:02.640 --> 11:08.200] of have to do. Um and ALPC is what's used to coordinate the actual execution of the user [11:08.200 --> 11:16.380] specified process. So our first issue the memory safety issue in Rust. Um sort of odd right but [11:16.380 --> 11:22.220] as I just mentioned you have to use unsafe APIs. Uh they've removed this functionality before [11:22.220 --> 11:28.080] they published it to GitHub so I can't tell you exactly how it happened but at a high at a from [11:28.080 --> 11:34.360] my analysis what happened was if you gave a path that rewrote from the beginning meaning that [11:34.360 --> 11:41.080] you had a leading like backslash or C colon backslash right? It would write your path to the [11:41.080 --> 11:46.240] start and then when it passed it to an API function it didn't truncate at the end of where your [11:46.240 --> 11:51.380] path was it just read until the end of the buffer to the first null byte. I think that that [11:51.380 --> 11:58.240] happened because they assumed that a path as string would point to a null terminated buffer as [11:58.240 --> 12:03.420] you would kind of expect it to if you're used to C when in fact it just points to a vector of U8s [12:03.420 --> 12:10.780] that may or may not include a null byte at the end. Um here's sort of my mock up of the code uh [12:10.780 --> 12:14.200] you can pull these slides off the Defcon media server if you want to take a better look at it [12:14.200 --> 12:18.620] but this is just sort of demonstrating what I just talked about where if you assume that you [12:18.620 --> 12:24.620] can take the path as a string and then just get a pointer to it and pass it to the Windows API [12:24.620 --> 12:29.540] function you'll end up very sad because it'll just read until the first null byte not [12:29.540 --> 12:36.300] necessarily until the end of your target string meaning you have buffer over read in heap uh for [12:36.820 --> 12:40.480] arbitrary numbers of bytes that you can't necessarily control but because you can control [12:40.480 --> 12:48.060] the path you can control approximately how far into that heap buffer you read. Uh so like I [12:48.060 --> 12:53.460] just said you can read everything up to the first non-null byte you don't control which heap [12:53.460 --> 12:59.920] allocation you're reading and it doesn't let you write memory into arbitrary things that are [12:59.920 --> 13:04.380] outside of your heap boundary because it is rust it's a vector uh so it'll reallocate if you [13:04.380 --> 13:10.420] reach the capacity of the current heap allocation um but still you get to read things from [13:10.420 --> 13:15.660] previous heap allocations which in my testing tended to just be paths but it could be [13:15.660 --> 13:22.360] something like a token or something like that. Um it says at the bottom there why uh it's not [13:22.360 --> 13:27.860] really a security issue uh the main problem being this is only noticeable if you run [13:27.860 --> 13:34.360] pseudo with an unpro or a untrusted input which you shouldn't do anyway so it's not really [13:34.360 --> 13:39.600] security impacting if you run pseudo with arbitrary things someone you don't trust supplied [13:39.600 --> 13:44.360] and then you can read other memory because you shouldn't be doing that in the first place [13:44.360 --> 13:49.700] because you're going to execute someone else's code. This screenshot shows what I was [13:49.700 --> 13:53.980] talking about so you can see on the left there I run pseudo with a leading slash and then a [13:53.980 --> 13:59.300] path and then you can see in process monitor that at the end of the day a create file [13:59.300 --> 14:04.980] operation or trying to read the file um ends up re trying to read a file that's the thing [14:04.980 --> 14:09.520] that I was trying to read and then a bunch of things from presumably a previous heap [14:09.520 --> 14:13.120] allocation because that's the path that's the current working directory and then some [14:13.120 --> 14:20.430] garbage at the end until it reaches the first null byte. So the second issue uh search [14:20.430 --> 14:24.910] order inconsistency so in Windows just like actually I shouldn't say that I don't know if it's [14:24.910 --> 14:30.550] true in Linux but in Windows if you run a command without a path it is supposed to execute [14:31.130 --> 14:35.190] that command in the current working directory if it's present and then search your path. [14:35.570 --> 14:40.810] So if you run pseudoprogram.exe you expect it to run the program.exe in the current working [14:40.810 --> 14:48.310] directory not some other random program.exe. Path resolution didn't work that way the way it [14:48.310 --> 14:52.770] worked is again because of that client server thing it would try to resolve the path in the [14:52.770 --> 14:56.730] context of the privilege process which had a different current working directory meaning [14:56.730 --> 15:01.850] that you could end up running a command you didn't expect to run. Uh says up there it's a [15:01.850 --> 15:06.570] somewhat contrived example but if you had compiled your own binary and named it cmd.exe and [15:06.570 --> 15:12.850] then you tried to run pseudocmd.exe it wouldn't run your command.exe it would run the [15:12.850 --> 15:17.050] system32 command.exe. According to Microsoft it's not a vulnerability I have their exact [15:17.050 --> 15:25.650] response quoted there at the bottom. But they fixed it anyway. Um so they more or less [15:25.650 --> 15:30.710] looked up the in the unprivileged process they looked up the command you gave them and [15:30.710 --> 15:36.810] resolved it and then passed the fully resolved path into the privileged process. Um they [15:36.810 --> 15:42.030] fixed it I'm not going to complain too much but it's kind of odd that you accept input from [15:42.030 --> 15:45.150] people on what issues are fix them and then tell them yeah but we don't think it's a real [15:45.150 --> 15:53.970] issue. And this is a very well drawn I'm an artist if you didn't know uh example of how that [15:53.970 --> 15:59.890] would work from an attacker's perspective so you try to run command.exe you expect it to [15:59.890 --> 16:05.510] run yours it ends up running some other command in the privileged process path which isn't [16:05.510 --> 16:13.930] the one you wanted. So let's talk more about that RPC server again it's ALPC um source [16:13.930 --> 16:17.350] code wasn't available so I had to look in Giger to figure out what all these parameters [16:17.350 --> 16:23.530] meant. Uh I got pretty good results out of it I didn't know what those handles were or how [16:23.530 --> 16:28.350] to deal with them necessarily but luckily I didn't have to you can just bind to input and [16:28.350 --> 16:33.890] output without dealing or without worrying about the handles too much. Um importantly the [16:33.890 --> 16:38.690] unprivileged process ID so the one that you run before you hit that yes prompt as quick as [16:38.690 --> 16:44.950] humanly possible is what is used to create the socket name so it's predictable as long as you [16:44.950 --> 16:50.130] know the process ID that's uh trying to run sudo. And again I mentioned earlier after James [16:50.130 --> 16:55.930] Forshaw's blog post they added an authentication check which was checking that the client's [16:55.930 --> 17:01.110] process path so that unprivileged process was the same as the server's process path meaning [17:01.110 --> 17:08.670] both are running sudo.exe see windows system 32 sudo.exe right? Um over on the right side [17:08.690 --> 17:12.590] overview of that that off check on the right right just is the image name of my calling [17:12.590 --> 17:20.630] process the same as my image name if it is good to go we'll run your command. Which brings us [17:20.630 --> 17:24.910] to our first security issue. Um it turns out that that's not really a good authentication [17:24.910 --> 17:33.070] check. Um any user can issue elevation requests to that RPC server meaning that any user of a [17:33.070 --> 17:37.750] multi-user windows system to include you know unprivileged users because anyone can call an [17:37.750 --> 17:44.690] LPC socket like your web browser um can go ahead and run commands in the context of a user uh [17:44.690 --> 17:49.390] when they run sudo. So it's not latent I and a privileged user would have to try to run sudo [17:49.390 --> 17:55.690] and then you'd be able to exploit this to run it in the context of that user. Exploitation [17:55.690 --> 18:00.770] requires two things so like I mentioned insufficient authentication um the way I did [18:00.770 --> 18:07.110] that is I just injected a DLL into a sudo.exe sudo process that I controlled so that I could [18:07.750 --> 18:13.250] do whatever I want in the context of a process whose image name is the legitimate sudo.exe um [18:13.250 --> 18:17.430] and the other part of this was that predictable uh port name that predictable RPC control [18:17.430 --> 18:23.290] port name. Because users can view the process IDs of other users in Windows uh pretty much no [18:23.290 --> 18:26.850] matter what there are some types of tokens that can't do that. Uh you can get that [18:26.850 --> 18:32.870] information very easily and then you can just call the target sudo privileged sudo process [18:32.870 --> 18:38.530] and have it run whatever you command you want and gain execution in that user's context. [18:39.250 --> 18:44.310] This was patched in the version in the second version one of sudo the one that was uh code [18:44.310 --> 18:49.990] signed on the 4th of March. So again high level attack diagram you see at the top there we [18:49.990 --> 18:53.510] have our victim who's just trying to run sudo and get on with their day. We have we have our [18:53.510 --> 19:00.090] attacker with again I'm an artist very well drawn horns thank you. Um the attacker starts [19:00.090 --> 19:06.710] their code that's just waiting and find trying to find a victim sudo that is running and then as [19:06.710 --> 19:14.530] soon as it notices one it spawns its own sudo with a hooked method to connect to the target RPC [19:14.530 --> 19:20.410] server instead of one that it spawned uh to run whatever command the attacker wants. From the [19:20.410 --> 19:25.470] victim's perspective what this looks like is they ran sudo they as fast as humanly possible [19:25.470 --> 19:29.530] because again they're just trying to get the job done hit the yes button on the UAC prompt and [19:29.530 --> 19:34.270] then nothing happens from their perspective but in reality the attacker was able to run whatever [19:34.270 --> 19:45.160] command they wanted. Uh demo I think? Do I have that wrong? Hopefully it plays. Alright well [19:45.160 --> 19:54.460] that was surprising. So here I'm just showing there's nothing up my sleeve um uh the left [19:54.460 --> 20:02.160] prompt is gonna be our victim user so who am I? I'm MTU um it can run sudo just fine. The right [20:02.160 --> 20:07.380] prompt is now my unprivileged user or my non-administrative user not MTU. Right now I'm [20:07.380 --> 20:13.600] gonna show that uh sudo works and then that the base prompt is not running elevated. And then on [20:13.600 --> 20:21.600] the right on the right we're running that implant code that's just gonna spawn some stuff uh to [20:21.600 --> 20:26.860] try to target that victim sudo process. We are racing because if we don't beat the legitimate [20:26.860 --> 20:33.360] process um the RPC socket closes and we can't run our command. So we go slowly insane trying to [20:33.360 --> 20:37.620] win the race. I did test this in a debugger first so I was pretty confident it was supposed to [20:37.620 --> 20:43.920] work but man recording this video and just sitting there doing this for 2 minutes was not fun. Um [20:44.560 --> 20:50.020] at the end there you can see that it worked on the right side our unprivileged process again we [20:50.020 --> 20:55.880] were able to inject into that victim server process and run command.exe as this as the [20:55.880 --> 21:00.180] unprivileged user. We run whoami and we see that we're now running as that other user who is [21:00.180 --> 21:08.090] just trying to run something with sudo. Well I already played the video but we can play it [21:08.090 --> 21:18.790] again if you want. Oh nothing showing up there? Neat. Let's try it this way. Can you see this? [21:18.790 --> 21:40.690] This video now? So again uh again left prompt is the uh privileged user who's just trying to [21:40.690 --> 21:45.030] run sudo uh the right prompt that's about to spawn is the unprivileged user not MTU some [21:45.030 --> 21:55.910] evil attacker man. Um user runs command everything works. Let's see if I can skip this bit a bit. Um [21:55.910 --> 22:00.090] user keeps running command they keep working because you'll notice on the other side the [22:00.090 --> 22:04.350] attacker process is failing it's not winning that race. Uh like I mentioned I confirmed this [22:04.350 --> 22:09.370] in a debugger but still very frustrating watching it fail over and over and over again. Um but [22:09.370 --> 22:14.070] eventually it does work and we can see on that right side now we just got a command prompt back [22:14.070 --> 22:18.830] from the attacker's perspective. We run whoami and we see that we are running as a user other [22:18.830 --> 22:35.600] than ourselves which is not good I think is what it's called in the business. Alright. Uh work [22:35.600 --> 22:46.740] with me here. Nope. Yeah it's perfect. Um so I did find out after I tested this again after they [22:46.740 --> 22:51.800] made the source code available that they made that race window really short. So I assumed that the [22:51.800 --> 22:58.560] way it worked was the victim process ran its command successfully and then went ahead and uh [22:58.560 --> 23:03.200] then went ahead and closed the socket after it was done. In fact as soon as you called that [23:03.200 --> 23:08.680] elevation request API it locked all future calls of it. Which would explain why I had to run the [23:08.680 --> 23:14.640] command over and over again going slowly and sane until it worked. But I don't know not not [23:14.640 --> 23:20.980] really security control but good for them for locking out other users and thinking about it. So [23:20.980 --> 23:25.620] the second vulnerability I mentioned it's still under embargo unfortunately. Um I reported it [23:25.620 --> 23:31.560] 13th of June while the rest of this research was done April May time frame. Um sort of [23:31.560 --> 23:36.320] interesting story for you since I can't talk too much about the details of this one. The reason I [23:36.320 --> 23:43.080] thought of this was I was on a run trying to avoid working on the slides and I realized that there [23:43.080 --> 23:48.340] was some other issues with how they do that client server thing. So I was able to prove it out [23:48.340 --> 23:53.920] and get data tampering and information disclosure from again the process or the perspective of a [23:53.920 --> 24:02.140] non-privileged user on the privileged user's stuff. So public issues again it is a GitHub repo [24:02.140 --> 24:06.340] there are public issues uh that I think are sort of notable to talk about when we talk about [24:06.340 --> 24:10.760] Sudo for Windows. The first one um the elevation prompt is confusing. So there's a screenshot [24:10.760 --> 24:15.500] of it on the right you saw it earlier in the video. You don't know what hitting yes will do [24:15.500 --> 24:19.760] cause it's just telling you it's a Sudo invocation right? It doesn't tell you oh Sudo's actually [24:19.760 --> 24:24.700] gonna spawn this other process over here maybe you don't wanna do that it just says hi I'm [24:24.700 --> 24:30.620] Microsoft I'm a legitimate binary would you like me to run? Um not great from a security's [24:30.620 --> 24:34.140] perspective right? Admittedly again most of us probably just click yes as fast as humanly [24:34.140 --> 24:39.980] possible anyway or type in our credentials if we have that version of UAC enabled but um I [24:39.980 --> 24:45.480] believe that they committed to trying to figure out how to make it so it was more obvious what [24:45.480 --> 24:49.900] the actual command that's gonna run is instead of just saying yeah it's it says it's legitimate [24:49.900 --> 24:54.540] I'm just gonna hit yes and hope everything's okay. And the second issue uh which is critical [24:54.540 --> 25:01.620] to me because I like my computers to insult me is um Sudo for Linux or Unix if you will has a [25:01.620 --> 25:06.660] mode to have it insult you if you don't have legitimate access to run a command. Uh I want [25:06.660 --> 25:15.120] that in Windows cause I like my computers to be mean to me when I'm silly. So summary of [25:15.120 --> 25:19.260] everything we just talked about. Sudo for Windows is coming soon. Again it is scheduled to be in [25:19.260 --> 25:25.160] mainline Windows 11 and I think Windows server don't quote me on that one uh end of [25:25.160 --> 25:30.820] September-ish in the in the H2 update. Uh it's open source again we we love to see that it [25:30.820 --> 25:34.720] makes it so people like me or people like anyone in this audience can go look at the source [25:34.720 --> 25:39.060] code and pull it apart and understand not only how it works but maybe find some more [25:39.060 --> 25:44.040] security issues in it so we're not shipping products that are enabling bad things to happen [25:44.040 --> 25:48.100] on Windows. Or if you're on the other side of it using it to make bad things happen on [25:48.100 --> 25:54.120] Windows I don't know I don't judge. Um it is meant to be a drop in replacement for the way [25:54.120 --> 25:57.800] Sudo works on Linux so it lets you actually have standard in, standard out, standard air, [25:57.800 --> 26:01.420] piped and redirected and all that stuff within your command prompt or your PowerShell [26:01.420 --> 26:07.680] prompt. Um and it does all of that using user account control to elevate processes and [26:07.680 --> 26:13.540] inter-process uh communication to actually coordinate that across the not a trust boundary [26:13.540 --> 26:19.140] because that's not what Microsoft calls it of UAC. Uh sort of the big take away for me and [26:19.140 --> 26:24.520] it's informing some more stuff I'm looking into is you cannot call a Windows native API [26:24.520 --> 26:32.040] without going into unsafe rust. If you want to do that or for anything that uses a Windows [26:32.040 --> 26:36.740] API that means there is now the potential for you to get memory corruption act vulnerabilities [26:36.740 --> 26:42.900] in something written in rust which is counter to what everyone tells you about rust so be on [26:42.900 --> 26:45.840] the lookout for that if you're a bug hunter that if you see something calling a Windows [26:45.840 --> 26:51.900] native API from a rust program somewhere in that code it is unsafe. Poke at that boundary. And [26:51.900 --> 26:57.720] then I'll show some references and if anyone has any questions you can step up to that mic in [26:57.720 --> 27:02.500] the middle and I'll be happy to answer them. I don't know how much time I have left but I'll [27:02.500 --> 27:16.360] try to answer as many questions as I can. Thank you. Cool. Thanks everyone.