Skip to content
Access control Write-up Advanced

CVE-2022-30216 - Authentication coercion of the Windows “Server” service

An off-by-one error in the Windows Server service's RPC security callback left a newly added certificate-mapping function accessible to remote clients. An attacker with domain credentials could invoke it to coerce the server into authenticating to an attacker-controlled machine, enabling an NTLM relay attack that, combined with AD CS, could lead to remote code execution on the domain controller.

Ben Barnea Follow

Published on akamai.com

Cloud Manager Manage your cloud computing services

Ben Barnea (@nachoskrnl), on akamai.com

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.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 5 min read.

Context

The target of this research is the Windows Server service, also known as LanmanServer. It is the service that manages SMB shares: resources such as files, printers and directory trees that a Common Internet File System server makes available over the network. Because shares are core functionality, the service runs by default on every Windows machine.

Remote machines can create, configure, query and delete shares through RPC over a named pipe, \\pipe\srvsvc. Throughout the research the service is referred to as srvsvc.

From Windows 10 20H2 onwards, Microsoft added SMB over QUIC, which lets clients reach SMB shares over the QUIC transport protocol. In a QUIC interaction the client verifies the identity of the server by checking the certificate the server presents, and with SMB over QUIC the Server service became responsible for managing those certificates. The vulnerability sits in that certificate-mapping functionality.

RPC servers in Windows can implement a security callback, whose purpose is to restrict access to an RPC interface. The callback is written by the server developer, so each server applies its own logic to allow specific users or block specific functions. Functions exposed by an RPC server are identified by opnums (operation numbers), and srvsvc's callback uses those opnums to decide what a remote client may call.

Setup

The research was carried out against unpatched Windows 11 and Windows Server 2022 machines, where the vulnerability was confirmed to exist. The work is part of a broader study of Microsoft's remote procedure calls (MS-RPC), which rely on a standard client-server model and are among the most widely used protocols in Windows.

Triggering the vulnerability requires that the attacker have access to a machine in the domain. For the NTLM relay scenario described below, the Active Directory Certificate Services (AD CS) role needs to be installed, together with one of its services that are prone to NTLM relay: Certificate Authority Web Enrollment or Certificate Enrollment Web Service.

A proof of concept is published in the Akamai Security Research GitHub repository.

Finding it

The starting point was the observation that many RPC servers implement a security callback, each with its own logic, and that Windows services make extensive use of RPC. Looking at srvsvc's callback in an older build, Windows 10 19H2, the logic was:

  • If a remote client tries to access a function in the range 64 to 69 inclusive, deny access.
  • If a remote client that is not a cluster account tries to access a function in the range 58 to 63 inclusive, deny access.

In other words, remote clients are kept away from those particular functions, which suggests the restricted functions are sensitive and should only be invoked by expected, local processes.

When SMB over QUIC arrived in Windows 10 20H2, four new functions were added to srvsvc:

  • LocalrServerCertificateMappingGet
  • LocalrServerCertificateMappingSet
  • LocalrServerCertificateMappingEnum
  • LocalrServerCertificateMappingRemove

These were not meant to be reachable remotely, so they were folded into the local range: the first range was widened from 64 to 69 to 64 to 73, extending the callback's access control over the new opnums.

In Windows 11 and Windows Server 2022, Microsoft added another function, LocalrServerCertificateMappingModify. This time the restricted range was not updated to cover it. The function was therefore not covered by the security callback and was accessible to remote RPC clients.

Exploitation

Step 1: Reach the unprotected function

Because LocalrServerCertificateMappingModify falls outside the ranges the callback denies, a remote client can invoke it. Calling it lets an attacker change the configuration of certificate mappings on the server. A certificate mapping is a symbolic link between a server's QUIC certificate and a certificate in the certificate store. The function does not add or modify a certificate in the Windows certificate store; it changes which store certificate the QUIC server's certificate is mapped to.

Step 2: Abuse the store location for server spoofing

The struct the function receives contains the certificate's store location. By supplying a UNC path as the storeLocation variable, an attacker can make LocalrServerCertificateMappingModify trigger an RPC request from the victim server to a machine the attacker controls. The call flow that fires the request is:

LocalrServerCertificateMappingModify → SsValidCertandUpdateCertinfo → CertOpenStore → _CertDllOpenSystemStoreProvW → EnumPhysicalStore → FormatSystemRegPath → RegConnectRegistryExW → BaseBindToMachine → Rpc_OpenPredefHandle → NdrClientCall3

Step 3: Coerce authentication and relay it

During the RPC request the server sends to the attacker's machine, the server authenticates against the attacker's server. The attacker can then use the victim's credentials in an NTLM relay attack. By exploiting the vulnerability and running the NTLM relay flow, the researchers replicated the PetitPotam attack scenario of abusing AD CS and took over the domain controller.

Root cause

The bug is an off-by-one error in a security callback procedure that srvsvc implements. The callback denies remote access to a fixed range of opnums, and when LocalrServerCertificateMappingModify was introduced in Windows 11 and Windows Server 2022 the range was not extended to include it. The new function was consequently treated as remotely callable, even though the other certificate-mapping functions had been deliberately placed inside the denied range.

The vulnerability lay not in the implementation of SMB over QUIC but in the way the older callback restricted access to the RPC interface.

Impact

The vulnerability was assigned CVE-2022-30216 with a base score of 8.8. An attacker with domain credentials and access to a machine in the domain can, by combining the flaw with an NTLM relay attack on AD CS, run code remotely on the domain controller. The researchers also believe an attacker might be able to use the technique to modify a server's certificate mapping and perform server spoofing. The relay path additionally depends on the AD CS role being installed with a relay-prone service such as Certificate Authority Web Enrollment or Certificate Enrollment Web Service.

Fix

Microsoft patched the vulnerability in July's Patch Tuesday. The fix did two things:

  1. Corrected the range of local functions in the security callback, preventing remote access to LocalrServerCertificateMappingModify.
  2. Added an access check in each of the newly added local functions.

For detection, an NTLM relay attack that abuses AD CS often involves a TGT request. Event ID 4768 records the requesting machine's IP address, so a TGT requested for a domain controller from a machine that is not itself a domain controller is a useful signal of malicious activity.

Variants to test

  • A positive result is a function that responds to a remote call despite sitting outside the ranges the callback is expected to protect.
  • A positive result is an inbound authenticated connection from the target to your listener.
  • A mismatch between the documented local functions and the denied ranges is the signal.
  • A positive result is a certificate issued for the coerced machine account.

Written with AI from the full original report and checked against it passage by passage; anything it could not back up was removed or toned down. The original is the record. 12 min read.

What happened, in plain words

Microsoft Windows has a background program called the Server service. It is the part of Windows that shares files and printers with other computers on a network. Because sharing is something almost every Windows machine does, this service is switched on by default everywhere.

A researcher at Akamai, Ben Barnea, looked closely at how this service decides who is allowed to ask it to do things. He found a mistake in that decision-making. The mistake meant that one particular action, which was supposed to be usable only by programs running on the same machine, could in fact be triggered by someone sitting at another computer on the network.

That action deals with certificates, which are digital identity documents. By abusing it, an attacker could make a Windows server contact a machine the attacker controls and prove its identity to it. The attacker could then take that proof and use it somewhere else, a trick called an NTLM relay. Combined with a second Microsoft feature called Active Directory Certificate Services, this was enough to run code on a domain controller, the most important server in a Windows network.

Microsoft gave the problem the identifier CVE-2022-30216 and a severity score of 8.8 out of 10. The flaw was reported responsibly, fixed in July 2022, and a proof of concept is available in the Akamai Security Research repository.

Introduction: why anyone was looking here

Over several months the Akamai team studied Microsoft's remote procedure calls, shortened to MS-RPC. An RPC is a way for one program to ask another program, possibly on a different computer, to run a function for it. Think of it as a waiter carrying your order from your table to the kitchen and bringing the dish back: you do not walk into the kitchen yourself, you just ask, and the kitchen does the work. RPC is one of the most widely used ways for pieces of Windows to talk to each other.

One part of the RPC design caught the team's attention: the security callback. A security callback is a checkpoint at the door of an RPC server. Before a request is carried out, the server runs this checkpoint code, which looks at who is asking and what they want, and decides whether to let the request through. Each RPC server writes its own checkpoint, with its own rules.

Windows services lean heavily on RPC to expose what they can do. That made the team curious about how different services write their checkpoints. In one of them, the Server service, they found a flaw that lets an attacker impersonate a server or force a victim to authenticate to the attacker.

What is the Windows Server service?

The Server service, also called LanmanServer, manages SMB shares. A share is a resource, such as a folder of files, a printer or a directory tree, that a Common Internet File System server makes available over the network. In everyday terms, a share is the shared folder you see on another computer at home or at work: you open it and use the files as if they were on your own machine.

The Server service lets a remote machine create, configure, query and delete shares through RPC over a named pipe, \\pipe\srvsvc. A named pipe is a channel for passing messages between programs, and here it is the specific channel this service listens on. For the rest of the article the service is called srvsvc.

A bug in srvsvc matters because the service provides core functionality and therefore runs by default on every Windows machine.

SMB over QUIC

Starting with Windows 10 version 20H2, Microsoft added a feature called SMB over QUIC. It lets clients reach SMB shares through QUIC, a newer transport protocol. A transport protocol is the set of rules two computers follow to send data to each other; QUIC was designed to be more reliable and secure and to cope better with common internet problems such as delay and lost packets.

In a QUIC conversation the client checks the identity of the server by looking at the certificate the server presents. A certificate is like a passport for a machine: it is issued by someone trusted and it says who the machine is. With SMB over QUIC, the Server service became responsible for managing those certificates.

The vulnerability sits in that certificate-management functionality. To understand it, we first need to look at one of the ways RPC servers control access.

Security callbacks

Many Windows services, srvsvc among them, run an RPC server so that other programs can talk to them and use their features. Windows RPC has several security mechanisms; the one in focus is the security callback.

A security callback's job is to restrict access to an RPC interface. An interface is simply the list of functions a server offers, like a menu in a restaurant. The callback is written by whoever wrote the server, so each server applies its own rules about which users may get in and which functions they may call. In RPC, each function on that menu has a number, called an opnum (operation number). We will see opnums used in srvsvc's callback shortly.

A chronicle of a security callback

To understand the bug, first look at an older version of srvsvc's security callback, from before SMB over QUIC existed.

srvsvc security callback, Windows 10 19H2

The callback's logic was:

  • If a remote client tries to access a function in the range 64 to 69 inclusive, deny access.
  • If a remote client that is not a cluster account tries to access a function in the range 58 to 63 inclusive, deny access.

In plain words: a remote client is kept away from those particular functions. A range check like this is a hint that the restricted functions are sensitive and should be invoked only by expected, local processes, meaning programs running on the same machine rather than someone across the network.

When SMB over QUIC arrived in Windows 10 20H2, four new functions were added to srvsvc:

  • LocalrServerCertificateMappingGet
  • LocalrServerCertificateMappingSet
  • LocalrServerCertificateMappingEnum
  • LocalrServerCertificateMappingRemove

These functions were not meant to be reachable from another machine, so they were placed inside the local range. The first range was widened from 64 to 69 to 64 to 73, which extended the callback's access control over the new opnums. So far, so good.

srvsvc security callback, Windows 10 20H2

In Windows 11 and Windows Server 2022, Microsoft added another function called LocalrServerCertificateMappingModify:

This time, however, the range of restricted functions was not changed in the newer version to include the newly added function:

srvsvc security callback, Windows 11/Server 2022

So when this function was added, it was not covered by the security callback, and was therefore accessible to remote RPC clients. Picture a nightclub with a guest list at the door: a new person was hired to work inside, but nobody added them to the list of people the bouncer should stop, so they walked straight in.

Exploitation opportunities

By invoking this function, an attacker can change the configuration of certificate mappings on the server. A certificate mapping is a symbolic link between a server's QUIC certificate and a certificate in the certificate store. The certificate store is Windows' organised collection of certificates, like a filing cabinet of identity documents. The function does not add or modify a certificate in that cabinet; it changes which certificate in the cabinet the QUIC server's certificate is linked to.

We believe an attacker might be able to use this function to add their own certificate mapping and therefore perform server spoofing, meaning pretending to be a server that they are not.

While assessing the impact of the vulnerability, the team noticed that the struct the function receives contains the certificate's store location. A struct is a bundle of related pieces of data passed together, like a form with several fields. One of those fields is storeLocation, which says where the certificate store is.

By supplying a UNC path as the storeLocation variable, an attacker can cause LocalrServerCertificateMappingModify to trigger an RPC request from the victim server to a machine that the attacker controls. A UNC path is the Windows way of writing the address of something on the network, the kind of address that starts with two backslashes and a computer name. The chain of function calls that fires the request is:

LocalrServerCertificateMappingModify → SsValidCertandUpdateCertinfo → CertOpenStore → _CertDllOpenSystemStoreProvW → EnumPhysicalStore → FormatSystemRegPath → RegConnectRegistryExW → BaseBindToMachine → Rpc_OpenPredefHandle → NdrClientCall3

Read the arrow chain as a relay race: the attacker's call enters the first function, which hands off to the next, and so on down the line until the last one, NdrClientCall3, actually sends a network request out. The important point is that the address the attacker put in storeLocation is followed all the way to that final network call.

During the RPC request that the server sends to the attacker's machine, the server performs authentication against the attacker's server. Authentication here means proving who it is, and During the RPC request the server performs authentication against the attacker's server, and the attacker can leverage the victim's credentials in an NTLM relay attack. The attacker can now take that proof and use it to log in elsewhere, which is an NTLM relay attack: rather than cracking the password, the attacker simply passes the victim's proof along to a different service that accepts it.

By exploiting the vulnerability and running the NTLM relay flow, the researchers replicated the PetitPotam attack scenario of abusing AD CS and took over the domain controller. Active Directory Certificate Services, or AD CS, is Microsoft's system for issuing certificates inside a Windows network, and a domain controller is the server that holds the keys to that network.

Triggering the vulnerability requires that the attacker have access to a machine in the domain. For the NTLM relay scenario, the AD CS role needs to be installed, along with one of its services that are prone to NTLM relay: Certificate Authority Web Enrollment or Certificate Enrollment Web Service.

Fix

Microsoft released a patch for this vulnerability in July's Patch Tuesday, the monthly day on which Microsoft ships security updates. The issue was fixed by:

  • Correcting the range of local functions in the security callback, thus preventing remote access to LocalrServerCertificateMappingModify
  • Adding an access check in each of the newly added local functions

In plain words: the bouncer's list was corrected so the new function is stopped at the door, and each of the new functions was also given its own check, so the protection no longer depends on the list alone.

Disclosure timeline

  • April 26, 2022: A report has been sent to Microsoft
  • April 26, 2022: Status changed from New to Review / Repro
  • May 9, 2022: Status changed from Review / Repro to Develop
  • July 12, 2022: Patch has been released

These status labels are Microsoft's internal tracking stages: the report is received, then reviewed and reproduced by their engineers, then moved into development of a fix, and finally the fix ships.

Mitigation and detection

The following are the recommendations to mitigate NTLM relay:

Often, an NTLM relay attack that abuses the AD CS will involve a TGT request. A TGT, or ticket-granting ticket, is the pass a Windows account gets at login and then uses to obtain access to individual services; requesting one leaves a trace. The event log records it as Event ID 4768, and that entry includes the IP address of the machine that made the request. Malicious TGT requests can therefore be detected if a TGT is requested for a domain controller from a machine that is not a domain controller itself.

A proof of concept is available in the Akamai Security Research repository. A proof of concept is a small demonstration program that shows the flaw is real.

Summary

When new features are added, it is important to be mindful of the potential consequences, not only in the feature's own functionality but also in the way it is made accessible to users. Here, SMB over QUIC was added to Windows and introduced new functions to the Server service. The vulnerability lay not in the implementation of SMB over QUIC, but rather in the way an older function restricted access to the RPC interface.

The Akamai Security Research team has conducted several pieces of research on MS-RPC, starting with an analysis of an RPC runtime vulnerability in April's Patch Tuesday, as well as an outline of another CVE found in May. Ben Barnea and Ophir Harpaz presented the Server service vulnerability research at DEF CON 30 in Las Vegas.

Learn more


  • CyberSecurity
  • Information Security
  • Research
  • Security Research

Glossary

  • AD CS (Active Directory Certificate Services): Microsoft's system for issuing and managing certificates inside a Windows network.
  • Authentication: The process of proving who you are to a computer or service.
  • Certificate: A digital identity document, issued by a trusted party, that a machine or person presents to prove its identity.
  • Certificate mapping: A link between a server's QUIC certificate and a certificate held in the Windows certificate store.
  • Certificate store: Windows' organised collection of certificates.
  • Cluster account: A special account used by Windows clustering; the callback treats it differently from ordinary remote clients.
  • Common Internet File System (CIFS) server: A server that makes files, printers and directories available over the network using the SMB family of protocols.
  • CVE: A public identifier for a known security vulnerability, here CVE-2022-30216.
  • Domain: A group of computers and accounts managed together under a central authority in a Windows network.
  • Domain controller: The central server in a Windows domain that holds account and authentication information.
  • Event ID 4768: The Windows event log entry recorded when a ticket-granting ticket is requested.
  • Interface (RPC): The list of functions an RPC server offers to clients.
  • LanmanServer: Another name for the Windows Server service.
  • MS-RPC (Microsoft remote procedure calls): Microsoft's implementation of RPC, a way for one program to ask another, possibly on a different computer, to run a function.
  • Named pipe: A channel Windows uses to pass messages between programs; srvsvc listens on \\pipe\srvsvc.
  • NTLM: A Windows authentication scheme based on a challenge and a response derived from the account's credentials.
  • NTLM relay attack: An attack that captures a victim's authentication exchange and passes it to another service instead of cracking the password.
  • Off-by-one error: A mistake in which a boundary, such as the end of a range, is set one step too low or too high, so one item falls outside the intended check.
  • Opnum (operation number): The number that identifies a function on an RPC interface.
  • Patch Tuesday: Microsoft's monthly release day for security updates.
  • PetitPotam: A known attack technique that abuses Windows services to coerce authentication and relay it to AD CS.
  • Proof of concept: A small demonstration that shows a vulnerability is real and can be tested.
  • QUIC: A modern transport protocol designed to be reliable and secure over the internet.
  • RPC (remote procedure call): A way for one program to ask another program, possibly on a different machine, to run a function.
  • Security callback: A checkpoint in an RPC server that decides whether a request is allowed, based on the caller and the function requested.
  • Server service (srvsvc): The Windows service that manages SMB shares and runs by default on every Windows machine.
  • Share: A resource such as files, printers or directory trees made available over the network.
  • SMB (Server Message Block): The protocol Windows uses to share files and printers over a network.
  • SMB over QUIC: A Windows feature that lets clients reach SMB shares over the QUIC protocol, with the server proving its identity using a certificate.
  • Spoofing: Pretending to be something or someone you are not.
  • Struct: A bundle of related pieces of data passed together to a function.
  • TGT (ticket-granting ticket): The pass a Windows account obtains at login and uses to request access to individual services.
  • Transport protocol: The rules two computers follow to send data to each other.
  • UNC path: A Windows network address that starts with two backslashes and a computer or share name.
  • Vulnerability: A weakness in software that an attacker can use to do something the software's author did not intend.

More by Ben Barnea

View all

6 more disclosed reports, best first.

More from Microsoft

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.