Cold Hard Cache — Bypassing RPC Interface Security with Cache Abuse
A design flaw in Microsoft Windows RPC security callbacks allows caching to bypass access restrictions on certain functions. An attacker could invoke a permitted function to cache a successful callback, then call restricted functions to escalate privileges or coerce authentication.
Client-Side Protection & Compliance
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
MS-RPC is one of the cornerstones of Windows: the service manager, Lsass, COM and even some domain operations against a domain controller use it. The authors note that although Microsoft's documentation on using RPC is good, little has been published about RPC security, probably because the protocol is complex. Common attack techniques still rely on RPC: T1021.003 runs through MS-COM, T1053.005 is MS-TSCH and T1543.003 is MS-SCMR.
This research focuses on the security callback mechanism of RPC servers, how it can be bypassed through caching, and how the discovery was automated to flag Windows services as potentially vulnerable. Two vulnerabilities were found in Microsoft Windows RPC services, CVE-2022-38034 and CVE-2022-38045, with base scores of 4.3 and 8.8 respectively. They take advantage of a design flaw that allows the bypass of MS-RPC security callbacks through caching. , disclosed it responsibly to Microsoft, and it was addressed in October's Patch Tuesday. A proof of concept and the tools are in the RPC toolkit repository.


Security callbacks let RPC server developers restrict access to an RPC interface: they can apply their own logic to allow access to specific users, enforce authentication or transport types, or prevent access to specific opnums (functions exposed by the server are represented using opnums, that is, operation numbers). The callback is fired by the RPC runtime each time the client invokes an exposed function on the server.

The research covers remote client-server interaction. The implementations of the RPC runtime server-side code differ between an ALPC endpoint and a remote endpoint such as a named pipe.
Setup
The work was done against Windows RPC servers, with confirmation on unpatched Windows 10 and Windows 11. The tooling is the authors' own RPC toolkit, published in the Akamai security research GitHub repository, together with its raw output and links to references and work by other researchers. For enumerating interfaces from running processes the authors mention Impacket's rpcmap and rpcdump for remote endpoint mapper queries, and RpcView or RpcEnum locally. For the filesystem approach they wrote scraping scripts and used disassemblers with cross-reference functionality, and they mention Yara or regular expressions for locating interface structures. The scraped interface lists were produced from Windows Server 2012 and Server 2022.
The main precondition for the attack is that caching must be enabled, which requires an authenticated binding and therefore a security context for the client. Both the server and the client need to register and set authentication info. Where the target service does not register authentication info itself, the authors rely on SSPI multiplexing (described below) to force it.
Finding it
The caching mechanism
The RPC runtime caches the security callback's result for performance and utilisation, so it tries to use a cached entry before calling the security callback each time. Before RPC_INTERFACE::DoSyncSecurityCallback invokes the security callback, it first checks whether a cache entry exists by calling OSF_SCALL::FindOrCreateCacheEntry, which does the following:
- It fetches the client's security context from the SCALL (an object that represents a client call).
- It fetches the caching dictionary from the client's security context.
- It uses the interface pointer as a key to the dictionary. The value is the cache entry.
- If no cache entry exists, it creates one.

A cache entry has three important fields: the number of procedures in the interface, a bitmap, and the interface generation. During the lifetime of an RPC server the interface can change, for example if the server calls RpcServerRegisterIf3 on an existing interface. That calls RPC_INTERFACE::UpdateRpcInterfaceInformation, which updates the interface and increments the interface generation, so the caching knows it needs to reset because cache entries might be from the old interface.
Caching works in two modes: on an interface basis (the default) and on a call basis.
In interface-based caching there is no difference, from a caching point of view, between two calls to two different functions as long as they are on the same interface. To decide whether the cache entry can be used instead of calling the security callback, the runtime compares the interface generation saved in the cache entry with the actual interface generation. Initialisation of the cache entry zeroes the interface generation, so the first comparison finds them different and the security callback is called. If the callback returns successfully, the runtime updates the cache entry's interface generation, marking it as a successful entry that allows access to the interface without calling the security callback again. The next call to a function on the same interface uses the cache entry.
Call-based caching is used when the RPC interface is registered with the RPC_IF_SEC_CACHE_PER_PROC flag. Here caching is based on a bitmap that tracks to which procedures the security callback allowed access: if the client invoked function Foo and the callback returned successfully, there is a cache entry for Foo, and invoking Bar calls the security callback again.
Caching requirements and multiplexing
MS-RPC represents a logical connection between a client and a server using a binding handle, and the client and server can manipulate the binding data with designated functions. A binding is authenticated when the server registers authentication info (by calling RpcServerRegisterAuthInfo) and the client sets authentication info on the binding, which lets the server retrieve information about the client's identity. The output of this authentication is a security context object created for the client. The whole caching mechanism is based on this security context, so an unauthenticated binding has no security context and no caching. Both the server and client need to register and set authentication info.
If the server did not register authentication info, caching can still be enabled through multiplexing. Until Windows 10, version 1703, a service could share the same svchost process with other services, and some RPC runtime objects are shared between all interfaces. When registering an endpoint such as TCP port 7777, that endpoint can be used to access all interfaces running under the same process, so services that expect to be accessed locally can also be accessed remotely. Microsoft documents this on its page about being wary of other RPC endpoints running in the same process.
The authors present a second, similar behaviour: SSPI multiplexing. When registering authentication info the server must specify the authentication service, a Security Support Provider (SSP) that processes the authentication info received from the client, usually the NTLM SSP, the Kerberos SSP, or the Microsoft Negotiate SSP, which chooses the best available option between Kerberos and NTLM. The RPC runtime saves the authentication info globally, so if two RPC servers share the same process and one registers authentication info, the other server also has authentication info. A client can then authenticate the binding when accessing each of the servers. Servers that did not register authentication info, and therefore might not have expected clients to authenticate the binding or for caching to take place, can have those forced upon them.
Exploitation
Step 1: read srvsvc's security callback
The authors returned to srvsvc, where they had already found an off-by-one vulnerability in the past. Srvsvc exposes the MS-SRVS interface; the Server service (LanmanServer) manages SMB shares, which are resources such as files, printers and directory trees made accessible over the network by a CIFS server. Looking at the security callback, they noticed it might have another vulnerability, different from the one already found.

The callback logic is:
- If a remote client tries to access a function in the range of 64 to 73 (inclusive), deny access.
- If a remote client that is not a cluster account tries to access a function in the range of 58 to 63 (inclusive), deny access.
Remote clients are therefore prevented from accessing these particular functions, and the range check hints that the restricted functions are sensitive and should be invoked only by expected (local) processes.
Step 2: bypass the check with a cached result
A remote attacker can bypass the check by abusing caching. First, the attacker invokes a function that is not in this range, a remotely available function. Since the security callback returns RPC_S_OK, the runtime caches the result as a successful one. The interface is not registered with the RPC_IF_SEC_CACHE_PER_PROC flag, so caching is on an interface basis. The next time the attacker calls any function on the same interface, the cache entry is used and access is granted, so the attacker can invoke the local functions they should not have access to and the security callback is not called at all.

Srvsvc does not register authentication info, so under normal circumstances clients cannot authenticate the binding and caching is not enabled. However, Srvsvc shares the same svchost process with other services when the server machine has less than 3.5 GB of RAM. The services "AD Harvest Sites and Subnets Service" and "Remote Desktop Configuration service" register authentication info, so srvsvc becomes vulnerable to cache attacks. In this scenario an attacker can access restricted functions with the opnums 58 to 74, and one of the things they can do with those functions is coerce the authentication of the remote machine.
Step 3: hunt for other vulnerable interfaces
To find other interfaces vulnerable to a caching attack, the authors automated the search. There are two approaches: through current running processes or through the file system.
With running processes, they can look at RPC servers already loaded in memory, either on a remote server by querying the remote endpoint mapper (with Impacket's rpcmap or rpcdump, for example) or locally (using tools like RpcView or RpcEnum). The problem is that this misses any interface not currently loaded, and client interfaces cannot be examined because they are not registered.
Alternatively, they scrape the Windows file system and look for RPC interfaces compiled inside files. For each interface they parse its registration information by analysing the arguments passed to RpcServerRegisterIf, a similar approach to RpcEnum but scraping the file system instead of memory. They chose the filesystem method to include interfaces not necessarily loaded in memory, and wrote scripts and tools to automate the process, available in the RPC toolkit repository.
To find interfaces with caching enabled they do not really need to parse the RPC interface itself, because all the required information can be extracted from the RPC server registration call: the registration function accepts the RPC interface structure, registration flags and the security callback pointer. Parsing the RPC interface structure still provides useful information, such as the functions exposed by the interface or whether it is used by an RPC server or client. RPC servers are the main interest because a vulnerability may exist there, while RPC clients give insight into calling the server, which can be referenced for exploitation.
The RPC server interface structure is documented, so its fields do not have to be guessed. The size field and the transfer syntax are constant; there are actually two possible transfer syntaxes, DCE NDR and NDR64, but the authors have only ever stumbled upon DCE NDR.

Finding all RPC interface structures is trivial by looking for those two constants with Yara or regular expressions. Once found, the interpreter info field shows what functionality the server implements.
Information about the interface's security callback (if it exists) and whether it is cached requires a disassembler. Every self-respecting disassembler has an xref functionality, so finding all interface registration function calls in an RPC server is trivial. From there the authors parse the function call arguments to extract the interface structure address (to cross-reference with the scraped RPC server data), the security callback address (if it exists) and the RPC interface flags.

The scraping scripts are published in the RPC toolkit alongside their output from Windows Server 2012 and Server 2022.
The result: there are more than 120 interfaces with both a security callback and caching, many of them undocumented. That alone is no reason to panic, because most times the security callback will not be affected much by the caching. Commonly the checks are performed on values that are not cacheable, such as the transport protocol sequence (for example TCP) or the authentication level. Any change there requires a new security context anyway, since a new connection has to be established, which resets the cache and nullifies any possible caching bypass. The authors found a few vulnerabilities through this approach and could only discuss two at the time of writing, since the rest were still in the disclosure process.
Step 4: WksSvc, CVE-2022-38034
CVE-2022-38034 has a CVSS score of 4.3. WksSvc exposes the MS-WKST interface and is responsible for managing domain memberships, computer names and connections to SMB network redirectors, such as SMB printer servers. In the interface's security callback, a few functions are treated differently from the rest.
Functions whose opnum is between 8 and 11 are also checked to be invoked by a local client, so calling them remotely is not allowed. With caching, calling a different function that is allowed remotely first and then calling one of the restricted functions allows the locally restricted functions to be called remotely, because the result of the first call is cached. The exposed functions are NetrUseAdd, NetrUseGetInfo, NetrUseDel and NetrUseEnum, which are accessible through netapi32.dll (see NetUseAdd, for example). This gives a clue about the attack: the remote server can be connected to a network shared folder of the attacker's choosing, and even mapped to a logical drive letter of the attacker's choosing, similarly to net use.
There are two attack scenarios:
-
Require authentication on the shared folder, then either relay it to a different server for an NTLM relay attack, or store the tokens and crack the password offline.
-
Masquerade an existing file server (or pretend to be a new one) with interesting or useful files. Since those files are in the attacker's control, they can be weaponised as the attacker sees fit, hopefully allowing the target user to be infected.

Those two scenarios, and being able to remotely call locally restricted functions, were enough for Microsoft to categorise this vulnerability as EoP with a score of 4.3.
Step 5: overcome the security context limitation
The RPC server under WksSvc does not do any authentication registration by itself. If the service runs on its own, no client-side authentication is possible and it results in the error RPC_S_UNKNOWN_AUTHN_SERVICE. The service therefore needs to run with other services to abuse SSPI multiplexing. This limits the affected Windows versions to those before Windows 10, version 1703, or newer versions running with less than 3.5 GB of RAM.
Step 6: overcome the logon session limitation
Network mapped folders are limited to the logon session of the user creating them. Because a logon is needed to get security binding and caching, the attacker always creates a different logon session than the existing interactive session on the target machine. For all intents and purposes the vulnerability then has no effect: the network mapping is created under the short-lived logon session and not the one created by a regular user when they logged into the machine, so it is not visible.

Digging deeper into the code of NetrUseAdd, the authors found flags that direct it to create the mapping in the Global namespace, which affects all users. Those flags are found in the available header file LMUse.h:

With the flags, the code successfully creates a global mapping that affects the interactive session, finishing the exploitation attempt.

Root cause
The RPC runtime caches the result of the security callback to improve performance. In interface-based caching, which is the default, a successful callback for one function on an interface marks the whole interface as allowed, so subsequent calls to any function on that interface skip the callback entirely. A security callback that restricts individual opnums, as srvsvc and WksSvc do, therefore only enforces its restriction on the first call. The interface generation check only resets the cache when the interface is re-registered, and the per-procedure bitmap that would track access per function is only used when the interface is registered with RPC_IF_SEC_CACHE_PER_PROC, which these interfaces are not.
The existing defence, the security callback, is bypassed rather than broken: it is simply not invoked. The precondition that would normally prevent this, an authenticated binding, is supplied by other services in the same svchost process through SSPI multiplexing, because the RPC runtime stores authentication info globally per process. The logon session scoping of network mappings is a separate limitation of the mapped-folder feature, which the Global namespace flags in NetrUseAdd overcome.
Impact
On srvsvc, an attacker can access restricted functions with the opnums 58 to 74, and one of the things they can do with those functions is coerce the authentication of the remote machine. On WksSvc, an attacker can connect the remote server to a network shared folder of their choosing and map it to a logical drive letter of their choosing, similarly to net use. This enables NTLM relay or offline password cracking against a shared folder that requires authentication, or serving weaponised files from a masqueraded or new file server to infect the target user. Microsoft categorised the WksSvc issue as EoP with a score of 4.3; CVE-2022-38045 (srvsvc) has a base score of 8.8.
Exploitation depends on conditions: the target service must share an svchost process with a service that registers authentication info, which limits affected versions to those before Windows 10, version 1703, or newer versions running with less than 3.5 GB of RAM. For WksSvc, the global mapping flags are needed for the mapping to be visible in the interactive session.
Fix
Microsoft addressed the vulnerabilities in October's Patch Tuesday. The report does not describe the code change. From the analysis, the durable fix is for the runtime or the affected interfaces not to treat a successful callback for one opnum as authorisation for every opnum on the interface, for example by registering interfaces that restrict individual functions with RPC_IF_SEC_CACHE_PER_PROC so that caching is tracked per procedure.
Variants to test
- Scrape binaries for RPC interface structures using the constant size field and DCE NDR transfer syntax, then cross-reference RpcServerRegisterIf call arguments in a disassembler to find interfaces that have both a security callback and caching. A positive result is an interface whose callback restricts specific opnums but which is not registered with RPC_IF_SEC_CACHE_PER_PROC.
- For each such interface, check whether the callback's decisions depend on cacheable values. If the callback only checks the transport protocol sequence or authentication level, a change requires a new security context and resets the cache, so the bypass likely fails; if it checks opnums or client identity, the bypass is worth testing.
- Check whether the target service registers authentication info itself. If not, look for other services in the same svchost process that do, and try authenticating the binding to the target through SSPI multiplexing. A positive result is a successful authenticated call to a service that never registered authentication info.
- Call a permitted function first and then a restricted opnum on the same interface, and observe whether the security callback is invoked for the second call. A positive result is the restricted function executing without the callback being called.
- For services that create network mappings, test the Global namespace flags in NetrUseAdd and check with WinObj and Explorer whether the mapping is visible in the interactive session. A positive result is a global drive mapping visible to logged-on users.

What happened, in plain words
Two security researchers at Akamai, Ben Barnea and Stiv Kupchik, spent time looking at a part of Windows that almost nobody writes about publicly: the way Windows programs talk to each other over the network through a system called MS-RPC. Microsoft fixed the problems in October 2022 and gave them the identifiers CVE-2022-38034 and CVE-2022-38045.
Think of it like a nightclub with a bouncer. The bouncer checks your ID once, then puts a stamp on your hand so he does not have to check you again every time you walk past. That is sensible and fast. The flaw here is that the stamp was being handed out for the whole club after checking you for one room, so you could then walk into rooms you were never checked for. The researchers found that Windows does exactly this with one of its internal security checks, and they showed two real Windows services where the consequence is a security impact.


Along the way they explain the conditions an attacker needs, and two obstacles they had to solve before the attack actually did anything useful.
Background: what MS-RPC is and why it matters
MS-RPC stands for Microsoft Remote Procedure Call. A "procedure call" is just a program asking another piece of code to run a function, for example "add these two numbers" or "list the files in this folder". "Remote" means the code being asked can be on another machine across the network. So MS-RPC is the plumbing that lets one computer ask another computer to run a specific function and send back the result.
An everyday comparison: ordering at a restaurant. You (the client) do not walk into the kitchen and cook. You tell the waiter what you want from the menu, the kitchen (the server) prepares it, and the waiter brings it back. MS-RPC is the waiter, the menu and the kitchen rules all in one.
The authors point out that MS-RPC is everywhere in Windows. The service manager uses it. Lsass, the process that handles logins and security, uses it. COM, the component system that many Windows programs are built on, uses it. Even some operations against a domain controller use it. Because it is so widespread, you might expect it to have been studied to death. The authors say that is not the case: Microsoft's documentation on using RPC is good, but very little has been written about RPC security, probably because the protocol is genuinely complicated.
They also note that attackers already rely on RPC in the real world. They cite three examples by their MITRE ATT&CK technique numbers: T1021.003 runs through MS-COM, T1053.005 is MS-TSCH, and T1543.003 is MS-SCMR. You do not need to memorise these; the point is that RPC is not an obscure corner, it is a road attackers already drive on.
The security check: security callbacks
When a developer writes an RPC server (the kitchen), they can attach a piece of their own code that runs before any request is served. This is called a security callback. A callback is simply a function that the system calls back into your code at a particular moment, so you get a say in what happens.
In this case the developer's code can do things like: allow only certain users, require that the client proved who it is (authentication), require a particular kind of network connection, or block specific functions. The functions a server exposes are numbered, and those numbers are called opnums (operation numbers). So a callback can say "opnum 5 is fine, opnum 9 is not".
The RPC runtime, which is the Windows component that actually carries the messages, fires this callback every time a client invokes an exposed function on the server.

The image illustrates the RPC security callback.
The authors focused on remote client-server interaction, meaning a client on one machine talking to a server on another. They note this matters because the server-side RPC code is implemented differently for a local connection (an ALPC endpoint, which is Windows' mechanism for processes on the same machine to talk) than for a remote one such as a named pipe (a channel that can be reached across the network).
The caching mechanism
Calling the security callback on every single request costs time. So the RPC runtime keeps the callback's answer and reuses it. That is the cache. The authors describe the code path: before RPC_INTERFACE::DoSyncSecurityCallback invokes the security callback, it first checks whether a cache entry exists, by calling OSF_SCALL::FindOrCreateCacheEntry. Those long names are internal Windows function names; you do not need to remember them, only the sequence.
OSF_SCALL::FindOrCreateCacheEntry does the following:
- It fetches the client's security context from the SCALL (an object that represents a client call).
- It fetches the caching dictionary from the client's security context.
- It uses the interface pointer as a key to the dictionary. The value is the cache entry.
- If no cache entry exists, it creates one.

In plain words: a security context is the record of who the client is, created when the client proves its identity. A dictionary is a lookup table, like a phone book: you give it a key and it gives you a value. Here the key is the interface (which set of functions is being called) and the value is the saved answer. If there is no entry yet, one is created.
A cache entry has three important fields: the number of procedures in the interface, a bitmap, and the interface generation. A bitmap here is a row of on/off switches, one per function, recording which functions were allowed. The interface generation is a counter that goes up whenever the interface is redefined.
Why does the generation exist? During the lifetime of an RPC server the interface can change, for example if the server calls RpcServerRegisterIf3 on an existing interface. That in turn calls RPC_INTERFACE::UpdateRpcInterfaceInformation, which updates the interface and increments the interface generation. The cache can then notice the number changed and reset itself, because old entries might describe an interface that no longer exists. It is like a menu being reprinted: the old prices on your notes are no longer valid.
The caching works in two modes: on an interface basis (the default) and on a call basis.
Interface-based caching
In this mode there is no difference, from a caching point of view, between two calls to two different functions as long as they are on the same interface. To decide whether the cache entry can be used instead of calling the security callback, the runtime compares the interface generation saved in the cache entry with the actual interface generation.
When a cache entry is first created, its interface generation is zeroed. So the first comparison finds them different, and the security callback is called. If the callback returns successfully, the runtime updates the cache entry's interface generation, marking it as a successful entry that allows access to the interface without calling the security callback again. The next call to a function on the same interface uses the cache entry.
This is the heart of the whole story. The stamp on your hand was issued after checking you for one room, but it lets you into every room on the same floor.
Call-based caching
This mode is used when the RPC interface is registered with the RPC_IF_SEC_CACHE_PER_PROC flag. A flag is an option you switch on when registering something. Here the caching is based on a bitmap that tracks to which procedures the security callback allowed access. If the client invoked function Foo and the callback returned successfully, there is a cache entry for Foo. If the client then invokes Bar, the security callback is called again.
So call-based caching is the careful version: each function gets its own stamp. Interface-based caching is the fast version: one stamp for the whole interface. The vulnerable services use the fast version.
What caching needs to work
MS-RPC represents a logical connection between a client and a server using a binding handle. Think of it as a ticket that identifies a particular conversation. The client and server can manipulate the binding data with designated functions.
A binding is authenticated when the server registers authentication info (by calling RpcServerRegisterAuthInfo) and the client sets authentication info on the binding. Authentication means proving who you are, like showing your passport. This lets the server retrieve information about the client's identity. The output of this authentication is a security context object created for the client.
The whole caching mechanism is based on this security context. So if the binding is not authenticated, there is no security context, and therefore no caching. For caching to work, both the server and client need to register and set authentication info.
That sounds like a solid precondition. If a service never asks for authentication, an attacker cannot get a cache entry, and the flaw is unreachable. The next section is about how that precondition gets satisfied anyway.
Multiplexing: sharing a process
Until Windows 10, version 1703, a Windows service could share the same svchost process with other services. Svchost is a generic host process: instead of every service having its own program, several services can be loaded into one shared process to save memory. The authors note that some RPC runtime objects are shared between all interfaces in that process. For example, when registering an endpoint such as TCP port 7777, that endpoint can be used to access all of the interfaces running under the same process. So services that expect to be accessed only locally can also be accessed remotely. Microsoft documents this on its page about being wary of other RPC endpoints running in the same process.
The authors then present a second, similar behaviour that they call SSPI multiplexing. When registering authentication info, the server must specify the authentication service to be used. That service is a Security Support Provider (SSP), a package that processes the authentication info received from the client. In most cases this will be the NTLM SSP, the Kerberos SSP, or the Microsoft Negotiate SSP, which chooses the best available option between Kerberos and NTLM. NTLM and Kerberos are two different ways Windows machines prove identity to each other; Negotiate just picks one.
The key detail: the RPC runtime saves the authentication info globally, per process. So if two RPC servers share the same process, and one of them registers authentication info, the other server also has authentication info. A client can then authenticate the binding when accessing each of the servers. Servers that did not register authentication info, and therefore might not have expected clients to authenticate the binding or for caching to take place, can have those forced upon them.
In restaurant terms: one kitchen in a shared building signs up for a doorman. Now every restaurant in that building has a doorman, whether they asked for one or not, and the doorman's stamp works everywhere in the building.
CVE-2022-38045: srvsvc
With that background, the authors went looking for real services to abuse. They returned to srvsvc, a service where they had already found an off-by-one vulnerability in the past. An off-by-one is a classic programming mistake where a loop or a check is wrong by exactly one item, for example allowing 1 to 10 when it should allow 1 to 9.
Srvsvc exposes the MS-SRVS interface. The Server service, also called LanmanServer, manages SMB shares. A share is a resource such as files, printers or directory trees made accessible over the network by a CIFS server. CIFS and SMB are the Windows file-sharing protocols; in everyday life this is the "network drive" or "shared folder" you see in File Explorer. Shares let users use other devices on the network for daily tasks.
When the authors looked at the security callback of srvsvc, they noticed it might have another vulnerability, different from the one they had already found. Here is the callback logic:

The image shows srvsvc's security callback logic. In plain words, the logic is:
- If a remote client tries to access a function in the range of 64 to 73 (inclusive), deny access.
- If a remote client that is not a cluster account tries to access a function in the range of 58 to 63 (inclusive), deny access.
A cluster account is the account used by a Windows failover cluster, a group of servers that act as one. The callback treats it as trusted for those functions.
So remote clients are prevented from accessing these particular functions. The range check hints that the restricted functions are sensitive and should be invoked only by expected, local processes. The developer clearly intended "outsiders cannot touch these".
Bypassing the check with a cached result
A remote attacker can bypass the check by abusing caching. The steps are:
- First, the attacker invokes a function that is not in this range, a remotely available function.
- Since the security callback returns
RPC_S_OK, the runtime caches the result as a successful one.RPC_S_OKis simply the "success" return code. - The interface is not registered with the
RPC_IF_SEC_CACHE_PER_PROCflag, so caching is on an interface basis. - The next time the attacker calls any function on the same interface, the cache entry is used and access is granted.
So the attacker can now invoke the local functions they should not have access to, and the security callback is not called at all.

The image illustrates the RPC security callback cache bypass process.
There is still the authentication precondition. Srvsvc does not register authentication info, so under normal circumstances clients cannot authenticate the binding and caching is not enabled. However, srvsvc shares the same svchost process with other services when the server machine has less than 3.5 GB of RAM. The services "AD Harvest Sites and Subnets Service" and "Remote Desktop Configuration service" register authentication info, so srvsvc becomes vulnerable to cache attacks through the SSPI multiplexing described earlier.
In this scenario an attacker can access restricted functions with the opnums 58 to 74. One of the things they can do with those functions is coerce the authentication of the remote machine. Coercion means tricking a machine into authenticating to a server the attacker controls, which hands the attacker credentials it can then use or attack.
Going on a treasure hunt: automating the search
After understanding that abusing the security callback's caching can yield actual vulnerabilities, the authors wanted to find other interfaces with the same weakness. Doing that by hand would be long and arduous, so they automated it.
There are two approaches to looking for RPC interfaces: through currently running processes, or through the file system.
With running processes, they can look at RPC servers already loaded in memory, either on a remote server by querying the remote endpoint mapper (with Impacket's rpcmap or rpcdump, for example) or locally (using tools like RpcView or RpcEnum). The endpoint mapper is the directory that tells a client which network address a given RPC service is listening on. Impacket is a well-known collection of Python tools for network protocols. The problem with this approach: it misses any interface that is not currently loaded, and client interfaces cannot be examined because they are not registered.
Alternatively, they scrape the Windows file system and look for RPC interfaces compiled inside files. Scraping here means automatically reading through many files and extracting the interesting parts. For each interface they parse its registration information by analysing the arguments passed to RpcServerRegisterIf. This is similar to what RpcEnum does, but they scrape the file system instead of memory. They chose the filesystem method so that interfaces not necessarily loaded in memory are included, and they wrote scripts and tools to automate the process, available in their RPC toolkit repository.
To find interfaces with caching enabled they do not really need to parse the RPC interface itself, because all the required information can be extracted from the RPC server registration call. The registration function accepts the RPC interface structure, registration flags and the security callback pointer. A pointer is a memory address, the number that says where something lives in memory. Parsing the RPC interface structure still provides useful information, such as the functions exposed by the interface or whether it is used by an RPC server or client. RPC servers are the main interest because a vulnerability may exist there, while RPC clients give insight into how the server is called, which can be referenced for exploitation.
The RPC server interface structure is documented, so its fields do not have to be guessed. The size field and the transfer syntax are constant. There are actually two possible transfer syntaxes, DCE NDR and NDR64, but the authors have only ever stumbled upon DCE NDR. A transfer syntax is the agreed format for encoding data on the wire, like agreeing whether to speak English or French before a phone call.

Finding all RPC interface structures is therefore trivial by looking for those two constants with Yara or regular expressions. Yara is a tool for describing patterns and searching files for them; a regular expression is a text pattern for matching strings. Once found, the interpreter info field shows what functionality the server implements.
Information about the interface's security callback (if it exists) and whether it is cached requires a disassembler. A disassembler is a tool that turns compiled machine code back into readable assembly instructions, the low-level steps a processor executes. Every self-respecting disassembler has an xref functionality, short for cross-reference, which shows every place in the code that refers to a given thing. So finding all interface registration function calls in an RPC server is trivial. From there the authors parse the function call arguments to extract the interface structure address (to cross-reference with the scraped RPC server data), the security callback address (if it exists) and the RPC interface flags.

The image shows RPC server registration disassembly.
The scraping scripts are published in the RPC toolkit alongside their output from Windows Server 2012 and Server 2022.
The result: there are more than 120 interfaces with both a security callback and caching, many of them undocumented. That alone is no reason to panic, because most times the security callback will not be affected much by the caching. Commonly the checks are performed on values that are not cacheable, such as the transport protocol sequence (for example TCP) or the authentication level. Any change there requires a new security context anyway, since a new connection has to be established, which resets the cache and nullifies any possible caching bypass.
In plain words: if the callback's decision depends on something that cannot change without starting a brand new conversation, the cached answer is still correct, so there is nothing to abuse. The flaw only bites when the callback's decision depends on something that varies between calls on the same connection, such as which function is being called.
The authors found a few vulnerabilities through this approach and could only discuss two at the time of writing, since the rest were still in the disclosure process. Disclosure is the process of telling the vendor, giving them time to fix, and then publishing.
WksSvc, CVE-2022-38034
CVE-2022-38034 has a CVSS score of 4.3. CVSS is a standard scoring system for the severity of a vulnerability; 4.3 is in the medium range.
WksSvc exposes the MS-WKST interface. The service is responsible for managing domain memberships, computer names and connections to SMB network redirectors, such as SMB printer servers. A redirector is the client-side component that makes a remote share look like a local folder. In the interface's security callback, a few functions are treated differently from the rest.
With caching, calling a different function that is allowed remotely first and then calling one of the restricted functions allows the locally restricted functions to be called remotely, because the result of the first call is cached. Same trick as srvsvc.
The exposed functions are NetrUseAdd, NetrUseGetInfo, NetrUseDel and NetrUseEnum, which are accessible through netapi32.dll (see NetUseAdd, for example). netapi32.dll is the Windows library that programs use to work with network resources. These are the functions behind the net use command you may have typed in a command prompt to map a network drive.
This gives a clue about the attack: the remote server can be connected to a network shared folder of the attacker's choosing, and even mapped to a logical drive letter of the attacker's choosing, similarly to net use. A logical drive letter is the letter like Z: that Windows shows for a drive.
There are two attack scenarios:
- Require authentication on the shared folder, then either relay it to a different server for an NTLM relay attack, or store the tokens and crack the password offline.
An NTLM relay attack works like this: the victim machine tries to log in to the attacker's server, and the attacker forwards that login attempt to a third server, letting the attacker act as the victim there. Cracking offline means capturing the login material and guessing the password on your own machine, with no time limit and no lockout.
- Masquerade an existing file server (or pretend to be a new one) with interesting or useful files. Since those files are in the attacker's control, they can be weaponised as the attacker sees fit, hopefully allowing the target user to be infected.

The image shows using a malicious web server as a man-in-the-middle or phishing server, serving weaponised documents or malware to unsuspecting users.
Those two scenarios, and being able to remotely call locally restricted functions, were enough for Microsoft to categorise this vulnerability as EoP with a score of 4.3. EoP stands for elevation of privilege: doing something you should not be allowed to do.
Obstacle 1: the security context
The RPC server under WksSvc does not do any authentication registration by itself. If the service runs on its own, no client-side authentication is possible, and it results in the error RPC_S_UNKNOWN_AUTHN_SERVICE. The service therefore needs to run with other services to abuse SSPI multiplexing. This limits the affected Windows versions to those before Windows 10, version 1703, or newer versions running with less than 3.5 GB of RAM.
Why does this matter? Because without authentication there is no security context, and without a security context there is no cache, and without a cache there is no bypass. The attack only works when the service happens to share a process with a service that does register authentication info.
Obstacle 2: logon sessions
Network mapped folders are limited to the logon session of the user creating them. A logon session is the period and context of one login; everything you do belongs to that session, and another login is a separate world.
Because a logon is needed to get security binding and caching, the attacker always creates a different logon session than the existing interactive session on the target machine. Interactive session means the session of the person actually sitting at the machine. For all intents and purposes the vulnerability then has no effect: the network mapping is created under the short-lived logon session and not the one created by a regular user when they logged into the machine, so it is not visible.

The image shows WinObj with the created logical drive letter existing only in the context of the attack logon session and not in the interactive session.
Digging deeper into the code of NetrUseAdd, the authors found flags that direct it to create the mapping in the Global namespace, which affects all users. A namespace here is a scope: a local namespace is visible only to one session, a global one is visible to everyone. Those flags are found in the available header file LMUse.h:

The image shows the global mapping flag as seen in LMUse.h.
With the flags, the code successfully creates a global mapping that affects the interactive session, finishing the exploitation attempt.

Root cause
The RPC runtime caches the result of the security callback to improve performance. In interface-based caching, which is the default, a successful callback for one function on an interface marks the whole interface as allowed, so subsequent calls to any function on that interface skip the callback entirely. A security callback that restricts individual opnums, as srvsvc and WksSvc do, therefore only enforces its restriction on the first call. The interface generation check only resets the cache when the interface is re-registered, and the per-procedure bitmap that would track access per function is only used when the interface is registered with RPC_IF_SEC_CACHE_PER_PROC, which these interfaces are not.
The existing defence, the security callback, is bypassed rather than broken: it is simply not invoked. The precondition that would normally prevent this, an authenticated binding, is supplied by other services in the same svchost process through SSPI multiplexing, because the RPC runtime stores authentication info globally per process. The logon session scoping of network mappings is a separate limitation of the mapped-folder feature, which the Global namespace flags in NetrUseAdd overcome.
Impact
On srvsvc, an attacker can access restricted functions with the opnums 58 to 74, and one of the things they can do with those functions is coerce the authentication of the remote machine. On WksSvc, an attacker can connect the remote server to a network shared folder of their choosing and map it to a logical drive letter of their choosing, similarly to net use. This enables NTLM relay or offline password cracking against a shared folder that requires authentication, or serving weaponised files from a masqueraded or new file server to infect the target user. Microsoft categorised the WksSvc issue as EoP with a score of 4.3; CVE-2022-38045 (srvsvc) has a base score of 8.8.
Exploitation depends on conditions: the target service must share an svchost process with a service that registers authentication info, which limits affected versions to those before Windows 10, version 1703, or newer versions running with less than 3.5 GB of RAM. For WksSvc, the global mapping flags are needed for the mapping to be visible in the interactive session.
Fix
Microsoft addressed the vulnerabilities in October's Patch Tuesday. Patch Tuesday is Microsoft's monthly day for releasing security updates. The report does not describe the code change. From the analysis, the durable fix is for the runtime or the affected interfaces not to treat a successful callback for one opnum as authorisation for every opnum on the interface, for example by registering interfaces that restrict individual functions with RPC_IF_SEC_CACHE_PER_PROC so that caching is tracked per procedure.
Variants to test
If you want to look for more of these yourself, the authors' method translates into these checks:
- Scrape binaries for RPC interface structures using the constant size field and DCE NDR transfer syntax, then cross-reference
RpcServerRegisterIfcall arguments in a disassembler to find interfaces that have both a security callback and caching. A positive result is an interface whose callback restricts specific opnums but which is not registered withRPC_IF_SEC_CACHE_PER_PROC. - For each such interface, check whether the callback's decisions depend on cacheable values. If the callback only checks the transport protocol sequence or authentication level, a change requires a new security context and resets the cache, so the bypass likely fails; if it checks opnums or client identity, the bypass is worth testing.
- Check whether the target service registers authentication info itself. If not, look for other services in the same svchost process that do, and try authenticating the binding to the target through SSPI multiplexing. A positive result is a successful authenticated call to a service that never registered authentication info.
- Call a permitted function first and then a restricted opnum on the same interface, and observe whether the security callback is invoked for the second call. A positive result is the restricted function executing without the callback being called.
- For services that create network mappings, test the Global namespace flags in
NetrUseAddand check with WinObj and Explorer whether the mapping is visible in the interactive session. A positive result is a global drive mapping visible to logged-on users.

Glossary
- API: a defined set of functions one program offers to another, so they can work together without knowing each other's internals.
- Authentication: proving who you are, for example with a password or a certificate.
- Binding handle: the object that represents a logical connection between an RPC client and an RPC server.
- Bitmap: a row of on/off bits used to record a set of yes/no facts, such as which functions were allowed.
- Cache: a store of previous answers kept so the same question does not have to be worked out again.
- Callback: a function that the system calls back into your code at a particular moment so you can make a decision.
- CIFS/SMB: the Windows family of protocols for sharing files, printers and folders over a network.
- Cluster account: the account used by a Windows failover cluster, a group of servers acting as one.
- Coercion: tricking a machine into authenticating to a server the attacker controls.
- CVSS: a standard scoring system for the severity of a vulnerability.
- DCE NDR / NDR64: the agreed data encoding formats (transfer syntaxes) used by MS-RPC; the authors only encountered DCE NDR.
- Dictionary: a lookup table that maps a key to a value.
- Disassembler: a tool that turns compiled machine code back into readable assembly instructions.
- Disclosure: the process of reporting a vulnerability to the vendor, allowing time to fix, then publishing.
- Endpoint mapper: the directory that tells a client which network address an RPC service listens on.
- EoP (elevation of privilege): doing something you should not be allowed to do.
- Flag: an option switched on when registering or calling something, which changes its behaviour.
- Interface: a named set of functions an RPC server exposes, each identified by an opnum.
- Interface generation: a counter incremented when an interface is redefined, used to invalidate old cache entries.
- Interactive session: the logon session of the person actually sitting at the machine.
- Logon session: the context created by one login; resources created in it are normally visible only within it.
- Logical drive letter: the letter such as
Z:that Windows shows for a drive or mapped folder. - MS-RPC: Microsoft Remote Procedure Call, the plumbing that lets one computer ask another to run a function.
- Multiplexing: sharing one process or endpoint among several services, so one service's settings affect the others.
- Named pipe: a channel for inter-process communication that can also be reached across the network.
- Namespace (local/global): a scope of visibility; local means one session, global means all users.
- NTLM / Kerberos: two authentication protocols Windows machines use to prove identity to each other.
- NTLM relay attack: forwarding a victim's login attempt to a third server so the attacker can act as the victim there.
- Off-by-one: a programming mistake where a limit is wrong by exactly one item.
- Opnum: the number identifying a function exposed by an RPC interface.
- Patch Tuesday: Microsoft's monthly day for releasing security updates.
- Pointer: a memory address saying where something lives in memory.
- Redirector: the client-side component that makes a remote share look like a local folder.
- Regular expression: a text pattern used to match strings.
- RPC_S_OK: the success return code of an RPC call.
- RPC_S_UNKNOWN_AUTHN_SERVICE: the error returned when a client tries to authenticate to a service that registered no authentication service.
- Scraping: automatically reading through many files and extracting the interesting parts.
- Security callback: developer code the RPC runtime calls before serving a request, to allow or deny it.
- Security context: the record of an authenticated client's identity, created during authentication.
- Share: a folder, printer or directory tree made available over the network.
- SSP (Security Support Provider): a package that processes authentication info, such as NTLM, Kerberos or Negotiate.
- SSPI multiplexing: authentication info registered by one service in a shared process becoming available to the others.
- Svchost: the generic Windows host process that can load several services at once.
- Transfer syntax: the agreed format for encoding data on the wire.
- Xref (cross-reference): a disassembler feature listing every place in the code that refers to a given thing.
- Yara: a tool for describing patterns and searching files for them.