WEBVTT

00:00.000 --> 00:01.180
Hello everyone.

00:01.180 --> 00:06.960
My name is Ron Ben Yitzhak and I'm very excited to be here today and give you my talk.

00:06.960 --> 00:08.280
You snooze, you lose.

00:08.280 --> 00:12.360
RPC Racer winning RPC end points against services.

00:12.640 --> 00:18.080
This year, this is the fourth year in a row I'm speaking here at DEF CON.

00:24.590 --> 00:26.790
I'll introduce myself first.

00:26.790 --> 00:31.570
I'm a security researcher at SafeBridge where I do vulnerability research.

00:31.570 --> 00:35.390
I also like playing music and going to concerts.

00:36.250 --> 00:38.670
This is our agenda for today.

00:38.670 --> 00:43.110
At the beginning I'll explain some basic terms regarding RPC.

00:43.130 --> 00:49.170
Then I'll expose some serious flaws in this very widely used protocol.

00:49.170 --> 01:07.810
I'll take you step by step showing how I manipulated a core component of RPC and masqueraded as a legitimate built in service to force a protected process to authenticate against an arbitrary server and disclosing the NTLM hash of the machine account.

01:08.870 --> 01:13.110
We're going to talk a lot today about the RPC protocol.

01:13.110 --> 01:16.490
So let's first understand what it is.

01:16.570 --> 01:23.470
The remote procedure call is used for inter process communication between clients and servers.

01:23.470 --> 01:28.570
The server exposes functionalities, certain actions and logics.

01:28.570 --> 01:33.230
And the client can request the server to execute them on its behalf.

01:33.290 --> 01:39.450
The server can run on the same machine as the client or on another computer on the network.

01:40.510 --> 01:47.890
Both RPC clients and servers use an interface definition language file or IDL file.

01:47.890 --> 01:58.130
It contains the properties of the RPC interface like definitions of structs, functions and most importantly the UUID.

01:58.130 --> 02:06.950
This unique identifier is used by the server when it registers to the machine and used by the client when it looks for its server.

02:07.950 --> 02:14.270
Before a client can communicate with a server, it first needs to create a binding handle.

02:14.270 --> 02:16.730
It is composed of three parts.

02:16.810 --> 02:19.730
The first part is the protocol sequence.

02:19.730 --> 02:24.690
This determines which protocol will encapsulate the RPC communication.

02:24.770 --> 02:35.470
The three most common protocols are TCP, named pipes over SMB and the advanced local procedure call or LPC for short.

02:35.470 --> 02:44.150
This protocol is used to transfer messages efficiently and securely between processes running on the same machine only.

02:45.410 --> 02:51.730
The second component is the network address which can be an IP address or computer name.

02:52.250 --> 02:55.170
And the last part is the end point.

02:55.190 --> 02:59.050
The meaning of it is different for every protocol sequence.

02:59.050 --> 03:01.310
For TCP it is the port number.

03:01.310 --> 03:03.910
For SMB it is the name of the pipe.

03:03.910 --> 03:08.030
And for LPC it is a unique string for that server.

03:08.090 --> 03:11.850
Two RPC servers cannot have the same end point.

03:12.330 --> 03:20.150
The examples in this talk are based on LPC end points because that is what most of the RPC servers in Windows use.

03:20.290 --> 03:24.630
But what I'm about to show you is relevant for other protocols as well.

03:26.030 --> 03:32.630
When an RPC server registers itself, it can either specify an end point or not.

03:32.750 --> 03:38.510
If it does, then the communication with it will be based on a well known end point.

03:38.510 --> 03:43.850
The client will have a hard coded string that it knows will match the server.

03:43.950 --> 03:50.210
If the server doesn't register with an end point, a unique string will be generated for it instead.

03:50.210 --> 03:52.810
This is called a dynamic end point.

03:52.810 --> 03:55.670
In this screen shot we can see three names.

03:56.670 --> 03:59.790
The first one starts with OLE.

03:59.830 --> 04:06.890
And although this is a unique string with a generated characters, it isn't the dynamic end point we are talking about.

04:06.890 --> 04:12.710
These end points are related to distributed com objects and are irrelevant for this talk.

04:13.330 --> 04:19.190
The second name is a well known end point that is registered by the local session manager.

04:20.590 --> 04:26.530
End points that start with LRPC are dynamic and contain generated characters.

04:27.010 --> 04:34.490
But the question is, if a dynamic end point is random, how does the client know who to communicate with?

04:34.490 --> 04:37.550
This is where the end point mapper comes in.

04:38.770 --> 04:46.850
The end point mapper or EPM maps between an interface UUID and the end points that expose it.

04:47.050 --> 04:54.890
If a server decides to use a dynamic end point, it needs to make sure it can be found by its clients.

04:54.890 --> 04:58.730
The way to do it is by registering to the end point mapper.

05:00.270 --> 05:08.330
After the registration of the server, the client will be able to establish an RPC connection using only a UUID.

05:08.670 --> 05:13.730
The EPM will connect it to the first server that registered that interface.

05:13.730 --> 05:17.230
There are two important tools the EPM works by.

05:17.230 --> 05:24.770
First, entries can be removed only if the original process unregisters or terminates.

05:24.810 --> 05:30.570
Second, the EPM will always use the first end point registered for an interface.

05:30.570 --> 05:32.970
The order cannot be modified.

05:33.750 --> 05:41.050
The EPM is managed by the DLL RPC EPM map which is loaded into the service RPC SS.

05:41.050 --> 05:45.230
Once it is loaded, it can be reached using multiple protocols.

05:45.230 --> 05:48.310
TCP, named pipes and LPC.

05:48.310 --> 05:51.350
Each one has its own known end points.

05:52.350 --> 05:58.810
The end point mapper can be queried locally or remotely using tools like RPC dump from impact.

05:59.070 --> 06:03.270
It behaves very much like a DNS server.

06:03.270 --> 06:06.470
It resolves UUID to an end point.

06:06.710 --> 06:08.730
This gave me an idea.

06:08.830 --> 06:12.870
Can an attack like DNS poisoning be applied to the EPM?

06:13.730 --> 06:21.530
Can we masquerade as a legitimate RPC server and have clients connect to us instead of the real one?

06:21.610 --> 06:24.130
We're going to create a new attack.

06:24.130 --> 06:25.870
EPM poisoning.

06:27.550 --> 06:38.050
Looking back at famous RPC experts, they usually target vulnerable coding servers to achieve remote code execution or privilege escalation.

06:38.470 --> 06:45.510
We're going to make a U-turn and target vulnerable code in RPC clients instead.

06:46.610 --> 06:51.690
The first step to achieve our goal is to figure out how to poison the EPM.

06:51.790 --> 06:58.670
Once it will forward RPC connections to us, we'll need to act like a built in legitimate service.

06:58.670 --> 07:04.130
Then send a malicious response to clients that will achieve privilege escalation.

07:04.330 --> 07:08.350
We're going to perform this attack without admin privileges.

07:08.350 --> 07:10.790
As a medium integrity process.

07:11.650 --> 07:17.170
To poison the EPM, the first thing we need to do is to register to it.

07:17.170 --> 07:21.170
We can do that with the API RPC EP register.

07:21.230 --> 07:25.670
But we don't want to just register any interface.

07:25.670 --> 07:28.550
We need to behave like a known server.

07:28.550 --> 07:31.470
And copy exactly what it does.

07:31.470 --> 07:35.030
Which means registering its interface.

07:35.550 --> 07:43.010
I was expecting another hard day of battling with error codes and diving into security mitigations.

07:43.010 --> 07:52.370
But then I just tried to register an interface that belongs to a built in service and apparently it worked.

07:52.370 --> 07:56.550
Moreover, it didn't even require admin privileges.

07:57.690 --> 08:07.510
I was shocked to discover that nothing stopped me from registering built in and known interfaces that belong to core services.

08:07.730 --> 08:16.770
I would expect that if Windows Defender, for example, has a unique identifier, then no other process will be able to register it.

08:16.770 --> 08:18.850
But that is not the case.

08:19.250 --> 08:23.130
Even though I achieved that, clients didn't connect to me.

08:23.830 --> 08:31.470
I didn't receive a connection because the original service registered an end point to its interface before me.

08:31.470 --> 08:39.250
When I tried registering an interface of a service that is turned off, its client connected to me instead.

08:39.570 --> 08:41.550
This is crazy.

08:41.550 --> 08:44.910
There are no security checks done by the EPM.

08:44.910 --> 08:51.130
It connected clients to an unknown process that isn't even running with admin privileges.

08:52.870 --> 08:58.070
EPM poisoning is possible and it doesn't even require elevation.

08:58.190 --> 09:03.250
As far as I can tell, this attack vector has never been explored before.

09:03.250 --> 09:07.050
Now, let's see how we can weaponize it.

09:08.430 --> 09:11.590
At this point, we made a proof of concepts.

09:11.590 --> 09:14.230
We know that the goal we set is possible.

09:14.370 --> 09:17.830
Now it's time to gather data and find our candidates.

09:17.990 --> 09:25.530
Our discovery proves that every RPC server that isn't launched on boots is prone to a hijack.

09:25.710 --> 09:28.510
Look at how many services there are.

09:28.650 --> 09:34.530
The next step is to gather lists of all the interfaces that aren't mapped to an end point.

09:36.190 --> 09:44.210
Like I mentioned before, dynamic end points can be retrieved from the EPM remotely or locally using win API.

09:44.590 --> 09:49.250
To be thorough, we need to also find the well-known end points.

09:49.250 --> 09:51.010
Several tools do that.

09:51.010 --> 09:53.470
Most notably, RPC view.

09:53.590 --> 10:02.990
It scans the memory of every process, locates the module RPC RT4 and passes internal structures to list the information shown here.

10:04.690 --> 10:10.430
I needed a comprehensive tool that knows how to retrieve both types of end points.

10:10.430 --> 10:13.190
So I developed RPC recon.

10:13.190 --> 10:19.570
The purpose of it is to find interfaces that can be registered right after the system boots.

10:19.570 --> 10:22.250
Before most services are launched.

10:23.810 --> 10:28.090
It is designed to be launched with a scheduled task when a user logs on.

10:28.090 --> 10:37.570
It will query the EPM and scan the memory of processes to gather a list of all the interfaces that are registered early in the boot process.

10:38.510 --> 10:44.210
After the first scan, it waits for several minutes until the late services starts.

10:44.250 --> 10:51.110
Then it performs the same retrieval again to gather a list of all the interfaces that are registered late.

10:52.250 --> 10:55.270
The last step is comparing the results.

10:55.470 --> 11:00.870
The difference shows interfaces that can be registered before the original service.

11:01.090 --> 11:11.270
Since this tool is used for gathering information and not for the attack itself, we'll execute it with admin permissions so it can scan the memory of elevated processes.

11:11.790 --> 11:15.570
And of course, this tool is now publicly available on GitHub.

11:18.170 --> 11:22.470
We'll start by executing RPC recon with the flag register.

11:22.490 --> 11:28.330
This will make it create a scheduled task that will be executed with elevated privileges when we log on.

11:28.410 --> 11:32.230
Then we'll restart to make sure most services aren't running.

11:34.850 --> 11:38.610
The tool will scan the system twice and compare the results.

11:38.670 --> 11:44.390
After the comparison is made, we'll get a list of all the interfaces that are registered late.

11:45.690 --> 11:48.530
Now we have a list of potential targets.

11:48.530 --> 11:51.730
There are many interfaces that we can hijack.

11:55.280 --> 12:01.420
My first surprise was that I can register to the EPM with any interface I want.

12:01.420 --> 12:07.040
No matter if it is critical to system functionality or belongs to a core component.

12:07.200 --> 12:16.080
I developed a generic RPC server that registers many interfaces and gathers information on the clients connecting to it.

12:17.000 --> 12:24.260
Then I started receiving connections from various processes on multiple interfaces.

12:25.340 --> 12:37.720
And when my server showed that those processes are services running as the local system account, I was sure I'm about to achieve the easiest privilege escalation ever.

12:38.820 --> 12:48.920
The most intuitive method to leverage the connection for privilege escalation is calling RPC impersonate clients and spawn a new console with our token.

12:48.920 --> 12:51.500
But it failed.

12:51.620 --> 12:59.260
I was able to get a new token but creating a new process with it resulted in the error bad impersonation level.

12:59.720 --> 13:02.520
Apparently MSRPC is broken.

13:02.520 --> 13:05.060
But not that broken.

13:05.240 --> 13:08.300
There is a policy for impersonation scenarios.

13:08.300 --> 13:14.180
It prevents medium integrity threads from impersonating a token with a higher integrity.

13:14.420 --> 13:19.220
To understand this mechanism better, let's go over the meaning of the levels.

13:20.060 --> 13:25.380
The anonymous level means the server cannot know who connected to it.

13:25.380 --> 13:28.300
The identification level is what I got.

13:28.300 --> 13:32.840
It lets the server query the client's privileges and security identifier.

13:33.060 --> 13:37.540
It is used to check if the client is allowed to access certain resources.

13:37.920 --> 13:41.380
The impersonation level is what I wished I had.

13:41.380 --> 13:46.940
It lets the server perform actions on the local machine with the client's security context.

13:47.140 --> 13:54.160
If the client is more privileged than the server, the server can use the impersonation for privilege escalation.

13:55.920 --> 14:01.720
Another idea I had is to leverage the connection for NTLM authentication.

14:01.780 --> 14:07.880
I try to use my new token to authenticate against an SMB server that belongs to me.

14:08.020 --> 14:11.700
That will usually disclose the NTLM hash.

14:11.700 --> 14:14.760
But again, the impersonation policy prevents it.

14:14.760 --> 14:21.700
To access remote resources over the network, we need the highest impersonation level, which is delegation.

14:23.220 --> 14:26.580
We hit our first obstacle in this race.

14:26.580 --> 14:29.120
Time to think what is our next move.

14:34.850 --> 14:39.110
At this point, I understood that I can't abuse the RPC connection.

14:39.350 --> 14:45.390
But maybe I can take advantage of the functionality the RPC server offers.

14:45.450 --> 14:52.210
If I masquerade as a server used for authentication, the clients will provide me with sensitive credentials.

14:52.330 --> 15:00.370
Out of all the vulnerable interfaces, I looked for ones with keywords such as credentials, identity and accounts.

15:00.370 --> 15:03.110
And ended up with these three interfaces.

15:03.630 --> 15:09.470
The vault service, Microsoft account signing assistant and the sync host service.

15:09.630 --> 15:14.830
When I launch my rogue server and use their clients, none of them connected to me.

15:14.830 --> 15:17.850
This is because of another security mechanism.

15:18.910 --> 15:24.690
One of the properties a binding handle can have is security quality of service.

15:24.710 --> 15:37.150
If the client is expecting the server to run as anti-authority system, it can specify a security identifier and that will prevent the connection to a server running as another user.

15:37.350 --> 15:39.690
This is what the RPC clients did.

15:39.690 --> 15:42.070
And this is why they didn't connect to me.

15:43.290 --> 15:54.970
For example, we can see that the RPC client of Microsoft account signing assistant create a security quality of service structure with the security identifier of the local system account.

15:54.970 --> 15:57.970
And then applies it to the binding handle.

15:59.190 --> 16:03.490
I was sure this time I will win the race.

16:03.490 --> 16:05.930
But I hit another obstacle.

16:07.810 --> 16:10.450
Let's have a short recap of our attempts.

16:10.490 --> 16:14.950
We received RPC connections from highly privileged services.

16:14.950 --> 16:21.750
But we couldn't impersonate them because of the policy that determines we can only identify who the client is.

16:21.750 --> 16:23.810
But not impersonate it.

16:23.950 --> 16:28.070
We saw that there are authentication services that are launched late.

16:28.090 --> 16:32.930
But their clients will only connect to a server that is running as a local system account.

16:33.230 --> 16:37.890
At this point, I needed to go to the pit stop and strategize.

16:38.030 --> 16:41.070
I knew the potential of EPM poisoning.

16:41.250 --> 16:44.710
I just needed to find the right way to abuse it.

16:44.870 --> 16:47.890
Then I had an idea.

16:49.250 --> 16:55.250
Another way to achieve privilege escalation is performing an action we aren't allowed to do natively.

16:55.250 --> 16:58.810
Such as writing to the system 32 directory.

16:58.950 --> 17:09.750
I thought that if I would masquerade as a file system service, another privileged service will ask me for data or file that it will then copy somewhere.

17:09.890 --> 17:14.630
Looking through my vulnerable interfaces list, I found a storage service.

17:14.630 --> 17:20.430
It is implemented in the file storage.dll and it is set to delayed start.

17:21.710 --> 17:25.550
The next step was launching my rogue server again.

17:25.550 --> 17:30.050
But this time registering only the interface of the storage service.

17:30.330 --> 17:37.790
I monitored the machine for RPC connections that happened naturally and gathered data on the clients of storage we see.

17:37.850 --> 17:42.430
The first service that connected to me was Windows updates.

17:42.430 --> 17:49.930
This is a highly privileged service in the operating system that can modify drivers and core DLL files.

17:49.930 --> 17:55.170
And it just connected to an unknown process running with low privileges.

17:55.290 --> 17:58.350
This security gap is just insane.

17:59.550 --> 18:08.390
Then I got a connection from storage service which doesn't make sense because that's who I'm pretending to be.

18:08.550 --> 18:14.590
Apparently this service uses its own RPC client to connect to itself.

18:14.630 --> 18:19.590
But since I registered the interface first, it connected to me instead.

18:20.530 --> 18:32.590
The last connection I got was from the delivery optimization service which is responsible for downloading updates and packages from alternative sources to make the distribution more efficient.

18:33.070 --> 18:38.550
Something interesting about this service is that it runs as a protected process light.

18:38.670 --> 18:42.230
This shows the impact EPM poisoning has.

18:42.230 --> 18:45.850
And the choosing storage we see is the right path forward.

18:46.050 --> 18:49.770
Even the most protected services will connect to us.

18:51.610 --> 18:58.190
The way to manipulate the process is to understand what it receives as inputs and what it is used for.

18:58.450 --> 19:03.950
Out of 36 methods that the interface exposes, only three were invoked.

19:03.950 --> 19:05.970
All of them are undocumented.

19:05.970 --> 19:09.330
So it is difficult to understand what they are used for.

19:09.390 --> 19:13.690
But two out of three return an integer back to the clients.

19:13.690 --> 19:17.250
And this is very unlikely to have a major impact.

19:17.350 --> 19:22.110
The third method on the other hand returns an undocumented structure.

19:22.190 --> 19:24.630
That has more potential.

19:26.490 --> 19:33.430
We want to understand what is the definition of the structure returned by the method gate storage device info.

19:33.510 --> 19:39.110
One way to do that is to look at functions on the client side that receive this structure.

19:39.330 --> 19:45.430
The call stack that led to the RPC call went through a DLL called app X deployment clients.

19:45.570 --> 19:55.070
When I disassembled it, I was surprised to see its public symbols contain a lot of information about the interface of storage service.

19:56.250 --> 20:01.730
It had enums, variable names, basically everything I needed.

20:01.870 --> 20:06.950
And the best part was, it revealed our struct contains a path.

20:07.190 --> 20:15.850
At this point, all I had to do is to apply this definition on the disassembly of other clients to see what they are doing with this path.

20:17.530 --> 20:29.350
After digging through the disassembly of all the clients, I found out that the delivery optimization service performs a few sanity checks on the path it receives that I was able to bypass.

20:29.390 --> 20:33.550
And then it creates a directory based on that path.

20:33.550 --> 20:36.750
We found an action we can manipulate.

20:36.970 --> 20:43.390
Our low privilege process can return a path that will be used by a highly privileged process.

20:43.790 --> 20:49.370
The delivery optimization service is running as a user and authority network service.

20:49.510 --> 20:56.330
And the easiest way to exploit this vulnerability is to create a directory in the home folder of this user.

20:57.230 --> 21:00.910
As you can see in the screen shots, it works.

21:00.930 --> 21:11.230
We returned a network share to the C drive of the local machine to bypass the security, the sanity checks and the directory hello DEF CON 33 was created.

21:11.690 --> 21:13.970
But that's not enough.

21:14.250 --> 21:16.230
Let's see what more we can do.

21:17.550 --> 21:26.390
To gain the most out of this vulnerability, we first need to understand what is this user and what it is used for.

21:26.670 --> 21:32.590
Processes running as network service have a token with a very high integrity level.

21:32.590 --> 21:35.550
The same as the local system accounts.

21:35.770 --> 21:39.110
But still, there is a difference between them.

21:39.190 --> 21:43.370
The network service is not part of the administrator's group.

21:43.370 --> 21:51.150
It means that it doesn't have right access to most of the sensitive directories, registry keys and processes on the machine.

21:51.290 --> 21:59.430
The purpose of this user is to have a few privileges locally, but to be able to authenticate to remote machines.

21:59.430 --> 22:02.370
And it does that with the machine accounts.

22:02.470 --> 22:05.210
Now let's understand what is this account.

22:06.770 --> 22:15.250
When a computer joins an active directory domain, an account is created in the NTTS database that represents this computer.

22:15.610 --> 22:20.370
This account can be easily identified by the dollar character at the end of its name.

22:20.710 --> 22:30.770
Like any domain user, it has a password , group memberships and can be used to access remote, to access resources in the domain network.

22:32.090 --> 22:37.950
The machine account is often abused in pen testing, depending on the configuration of the domain.

22:38.070 --> 22:44.110
And logged on users cannot authenticate to remote resources with those credentials.

22:44.130 --> 22:48.670
They are only used by the local system and network service accounts.

22:48.870 --> 22:52.470
That is where our vulnerability comes in.

22:53.470 --> 22:59.890
We can bypass the limitation applied on logged on users and authenticate with the machine accounts.

22:59.910 --> 23:07.690
Previously I showed you my RPC server returned a network share of the C drive to the delivery optimization service.

23:07.730 --> 23:21.030
If I return a network share of an external server, the delivery optimization service will authenticate against it with the machine account credentials and I'll be able to relay the NTLM authentication.

23:22.250 --> 23:26.790
We successfully crossed the security boundary and won the race.

23:28.350 --> 23:30.590
Time to recap our attack.

23:30.610 --> 23:38.010
As a medium integrity process, we can create a schedule task that will be executed when the current user logs in.

23:38.050 --> 23:42.710
At this point, most of the RPC servers haven't launched yet.

23:42.850 --> 23:47.070
Our first step will be to register the interface of the storage service.

23:47.170 --> 23:54.070
Then we'll trigger the delivery optimization service to send an RPC request to the storage service.

23:54.070 --> 23:56.970
It will connect to it with a dynamic end point.

23:56.970 --> 24:02.670
Which means it will query the EPM and get the end points that we registered.

24:02.750 --> 24:06.930
Then it will invoke the method get storage device info.

24:06.930 --> 24:12.050
And in return, it will receive an SMB share to a server that we launched.

24:12.090 --> 24:19.130
The final step will be the delivery optimization service authenticating to us with the machine account credentials.

24:19.130 --> 24:21.770
And us relaying this authentication.

24:23.070 --> 24:28.630
This attack is done by another new tool called RPC Racer.

24:28.630 --> 24:30.470
And it is now available.

24:30.550 --> 24:38.650
In addition to forcing the authentication of the machine account, RPC Racer is designed to launch rogue RPC interfaces.

24:38.670 --> 24:41.990
It will print information about the clients connecting to it.

24:41.990 --> 24:46.430
This is helpful for researching vulnerabilities in other servers.

24:46.630 --> 24:50.570
The vulnerability in the storage service was acknowledged by Microsoft.

24:50.570 --> 24:53.590
And a fix was released on July 8th.

24:54.690 --> 24:58.610
We execute our tool without admin privileges.

24:58.610 --> 25:00.830
As a medium integrity process.

25:00.990 --> 25:09.070
If we could relay the machine account authentication back to the computer we are running on, we would escalate our privileges.

25:09.170 --> 25:13.130
But that is not possible due to security mitigation.

25:13.290 --> 25:18.510
An MTLM authentication can't be relayed back to the computer that originated it.

25:18.510 --> 25:22.570
Therefore, we need to find another server in the domain.

25:22.930 --> 25:31.030
To understand the impact of forcing and relaying a machine account authentication, we look at the machine account of the domain controller.

25:31.190 --> 25:40.630
If we would execute our tool as a low privilege user on the domain controller, we can use authentication for an attack called ESC 8.

25:42.070 --> 25:51.550
ESC 8 is an attack that achieves privilege escalation by leveraging the Active Directory Certificate Service or ADCS.

25:51.550 --> 25:54.230
This server is part of the domain.

25:54.230 --> 25:59.590
And the certificate it generates are recognized by other computers in the network.

25:59.590 --> 26:07.150
Also, those certificates can be used for authentication against instead of plain text credentials.

26:07.470 --> 26:13.550
To be specific, ESC 8 targets the web enrollment feature of ADCS.

26:13.610 --> 26:21.690
This feature allows a user to log into a web server managed by ADCS and request to generate a certificate.

26:21.790 --> 26:33.430
What happens in ESC 8 is that the attack relays an MTLM authentication to request from the web server a certificate that represents a privileged user in the domain.

26:34.470 --> 26:40.870
Like I said before, MTLM authentication cannot be relayed back to the same computer.

26:40.870 --> 26:47.270
We want to use the privileges of the DC machine account, but we need another form of authentication.

26:47.830 --> 26:55.910
The first step to achieve that will be to relay the authentication created by RPC racer to the web server of ADCS.

26:56.230 --> 27:01.290
It will generate for us a certificate that represents the machine account of the domain controller.

27:01.430 --> 27:05.870
This is done by the tool MTLM relay X from in packets.

27:07.270 --> 27:12.050
We cannot authenticate anywhere across the domain with this certificate yet.

27:12.090 --> 27:19.010
Our next step will be to request from the domain controller a ticket granting tickets or TGT.

27:19.150 --> 27:25.170
This is a legitimate Kerberos ticket that can be used to request access to resources in the domain.

27:25.370 --> 27:29.050
This step is done by a tool called certify.

27:30.550 --> 27:37.510
Once we have the TGT of the domain controller machine account, we can use it to execute several attacks.

27:37.630 --> 27:42.830
The most common one will be to dump the password hashes of all the users in the domain.

27:43.150 --> 27:46.050
For this, we will use in packets again.

27:46.050 --> 27:48.750
But this time the tool secrets dump.

27:50.070 --> 27:52.530
Let's see how it all comes together.

27:53.390 --> 28:00.570
We'll launch a rogue SMB server with MTLM relay X and tell it to relay the authentication to the ADCS.

28:01.070 --> 28:04.970
Then we log on to the server as an unprivileged user.

28:07.090 --> 28:10.850
As you can see, we are running as a medium integrity process.

28:11.150 --> 28:14.010
At this point, the storage service is running.

28:14.110 --> 28:23.230
So, we'll execute RPC racer with the IP address of the relay server and tell it to register a schedule task that will start when we log on.

28:24.910 --> 28:28.890
Our moment to strike will be after the machine reboots.

28:35.460 --> 28:45.220
We can see that the delivery optimization service requested a path from us and that our SMB server received the authentication and relayed it to get a certificate.

28:45.980 --> 28:50.980
Then we'll use certify to request a TGT based on that certificate.

28:51.520 --> 28:57.560
Once we have a TGT of the machine account, we can dump all of the domain controller secrets.

29:08.090 --> 29:12.450
Like I said before, EPM poisoning is a real attack.

29:12.450 --> 29:15.530
And we saw just one way to abuse it.

29:15.550 --> 29:17.790
There are a lot more to get out of it.

29:17.950 --> 29:28.090
We can perform many in the middle by forwarding the request we received to the original service and filtering out calls to hide our foothold on the machine.

29:29.470 --> 29:33.750
An additional option for us is to just cause denial of service.

29:33.750 --> 29:40.350
By registering many interfaces and denying the requests, a lot of functionalities will be disabled.

29:40.390 --> 29:43.290
This is a much more sophisticated method.

29:43.310 --> 29:50.970
Instead of terminating processes or spamming them with packets, we can just register the RPC interface first.

29:52.170 --> 29:55.610
Another thing I talked about is stealing credentials.

29:55.810 --> 29:59.110
I looked at a few services that might be exploited for that.

29:59.110 --> 30:01.310
But there are probably more.

30:02.950 --> 30:06.730
We exposed some serious security issues at this talk.

30:06.730 --> 30:09.750
And there are a few lessons that should be learned from that.

30:09.750 --> 30:15.950
The first one is that the integrity of servers should be checked in every protocol.

30:16.090 --> 30:26.950
Just like SSL pinning verifies that the certificate is not only valid but uses a specific public key, the identity of RPC servers should be checked.

30:27.090 --> 30:31.030
The current design of the EPM doesn't perform this verification.

30:31.130 --> 30:34.090
Therefore, it must be done by the clients.

30:35.410 --> 30:41.310
The second point I want to leave you with is the danger of setting services to delayed start.

30:41.450 --> 30:49.150
Software developers of RPC servers should be aware of the implications of launching the programs late in the boot process.

30:50.110 --> 30:54.430
Services are often set to delayed start to make the boot process faster.

30:54.530 --> 30:58.030
But performance cannot come at the expense of security.

30:58.030 --> 31:04.090
Any stage where untrusted code can be executed should be considered unsafe.

31:05.750 --> 31:09.190
The patch to this vulnerability was released on July 8th.

31:09.190 --> 31:11.850
The fix was made to the RPC clients.

31:11.850 --> 31:14.030
Storage usage dot DLL.

31:14.130 --> 31:17.050
It improved how the binding was made.

31:17.230 --> 31:22.630
Instead of creating a simple binding handle, a security quality of service was applied to it.

31:22.630 --> 31:29.890
Now, the RPC connection will be made only if the RPC server is running as a local system account.

31:31.330 --> 31:42.530
Since the patch was made only to the RPC client of storage service, it means that there are many other clients and interfaces that are vulnerable to EPM poisoning.

31:42.570 --> 31:46.390
So, I have a, I have some suggestions to detect it.

31:46.430 --> 31:52.030
Security products can use hooking to monitor calls to RPC EP register.

31:52.030 --> 32:01.890
If a process wants to register a built in known interface to the EPM and it isn't a legitimate service, it should be detected.

32:03.150 --> 32:08.750
Another detection technique is to use event tracing for Windows or ETW.

32:08.870 --> 32:14.550
The operating system automatically generates events for many actions that occur in the machine.

32:14.590 --> 32:21.170
The provider named Microsoft Windows RPC logs a lot of useful information in this case.

32:21.170 --> 32:34.270
In these events, we can see the correlation between the process ID of RPC racer, the process ID of the delivery optimization service, and the interface of the storage service that we hijacked.

32:34.270 --> 32:41.830
We can even see the exact procedure number that was invoked, which correlates to get storage device info.

32:42.070 --> 32:46.550
These event types can be used to detect cases of EPM poisoning.

32:46.710 --> 32:51.890
An unknown process received an RPC connection on a known interface.

32:53.510 --> 32:58.550
I exploited the vulnerability I found to force the authentication of the machine accounts.

32:58.550 --> 33:03.270
But I think it could even lead to an even stronger impact.

33:03.450 --> 33:12.570
The password return to the delivery optimization service will be used as a private folder of the service where it will look for config files.

33:12.670 --> 33:21.810
This means that if we can point it to a directory with poisoned configs, that will affect the behavior of the service.

33:21.950 --> 33:26.010
One of the config files is key value LKG.dat.

33:26.010 --> 33:28.550
It contains many URLs.

33:28.790 --> 33:38.550
Regarding future work for this research, we would gain a lot more out of this vulnerability if we could change them to download payloads to the machine.

33:39.750 --> 33:45.250
Another interesting config file is dosvcstate.dat.

33:45.250 --> 33:51.550
This is a standalone registry hive used to manage jobs assigned to the delivery optimization service.

33:51.550 --> 33:59.110
There are some values that definitely catch the eye, such as CDN URL and working directory.

33:59.110 --> 34:06.350
Creating a key with certain values might result in the service downloading files to protected directories.

34:06.810 --> 34:15.550
And of course, the most prominent attack vector I suggest you to chase is to find more vulnerable RPC servers.

34:15.550 --> 34:17.270
There are so many.

34:17.270 --> 34:19.710
I just began scratching the surface.

34:19.910 --> 34:24.390
For example, Windows Security Center is set to delayed starts.

34:24.390 --> 34:27.110
And Windows Defender interacts with it.

34:27.110 --> 34:32.890
Maybe it is possible to neutralize Defender by sending it back a malicious response.

34:33.970 --> 34:41.490
To conclude this talk, I presented a serious security issue in a core component of the RPC protocol.

34:41.570 --> 34:49.750
There are no verifications on who is registering an interface that will be used by crucial services of the operating system.

34:50.350 --> 34:56.210
I showed you how to map the operating system to find vulnerable RPC servers.

34:56.210 --> 35:00.550
And RPC recon is now available for you to do it by yourself.

35:02.170 --> 35:07.650
After the target is found, I described how to analyze and exploit the clients.

35:07.870 --> 35:08.890
Here is

35:21.790 --> 35:27.390
the link to the repository of the tools.

35:27.390 --> 35:29.690
Feel free to reach out and contact me.

35:29.690 --> 35:30.670
Thank you.

