Movin' On Up: An Analysis of The Privilege Escalation Vulnerability CVE-2022-26923
Tags: cve202226923, privilegeescalation, security, activedirectory
Published: 2022-10-23 23:25:31

 
This article provides analysis of [CVE-2022–26923](https://msrc.microsoft.com/update-guide/vulnerability/CVE-2022-26923), a vulnerability at the intersection of [Active Directory (AD)](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/get-started/virtual-dc/active-directory-domain-services-overview) and [Active Directory Certificate Services (AD CS)](https://www.securew2.com/blog/active-directory-certificate-services-ad-cs-explained) that was [discovered](https://research.ifcr.dk/certifried-active-directory-domain-privilege-escalation-cve-2022-26923-9e098fe298f4) and reported privately through [Zero Day Initiative](https://www.zerodayinitiative.com/) by [Oliver Lyak](https://medium.com/@oliverlyak) and patched on May 10, 2022, which allowed for a low-privileged attacker to escalate their privileges through impersonation of another computer account under the guise of a requested authentication certificate.
As the go-to directory service from Microsoft for Windows domain networks, Active Directory (AD), or more formally [Active Directory Domain Services (AD DS)](https://learn.microsoft.com/en-us/windows-server/identity/ad-ds/get-started/virtual-dc/active-directory-domain-services-overview), is a prime target for attackers who want to obtain access to resources on a network.

 
<img width="100%" style="width:100%" src="https://media.giphy.com/media/QFypAZbq5lz3i/giphy.gif" alt="merida from brave shooting a bow and arrow at a target">

In a nutshell, AD functions as both a distributed data store and an access control mechanism for organizations using it, including within its scope not just users and groups but other objects like servers, printers, and computers within the network - i.e., networked resources to which access needs to be controlled. Offering quite a simple hierarchical organization, AD makes it easy for domain administrators (often a centralized Identity and Access Management team within the organization) to control access to resources; it also enables authorized network users to navigate and query for information about other users and networked resources in their organization.

## The Challenge
Let's start with an assumption: you're a user on the network with normal, non-administrative permissions - or perhaps you're not, but you have obtained the identity of someone who is.

<img width="100%" style="width:100%" src="https://media.giphy.com/media/1ziDTlTl9z9iwVK5QA/giphy.gif" alt="Conan putting on a disguise">
 
How can you use Active Directory, as described above, to (perhaps _further_) escalate your privileges and obtain access to a resource on the network to which you currently do not have access?

First, privilege escalation would be a bit difficult without visibility of whose privilege level should be targeted. Of course, as mentioned previously, AD does offer the ability for an authorized domain user to simply query the data for information they're interested in like usernames, email addresses, group memberships, etc., which is one way that visibility could be obtained. However, we've seen that with a tool like [Bloodhound](https://bloodhound.readthedocs.io/en/latest/), that same domain user (or someone impersonating them on the network) could automatically obtain a graphical visualization (built with a fantastic graph data platform called [Neo4j](https://neo4j.com/)) not only depicting who the domain administrators are within AD, but also what the shortest path of privilege escalation is to each of those administrators - all essentially at the click of a button.
 
Basically, any domain user can obtain this information about their domain by logging into AD, running [SharpHound](https://bloodhound.readthedocs.io/en/latest/data-collection/sharphound.html) to collect the data from it in JSON format, and then piping that collected data right into the Neo4j-based Bloodhound visualizer. From that point, it's a matter of following the yellow brick road - that is, mapping a route to a target with desired privileges by following the graph edges that reveal useful vulnerabilities. Graph theory, permissions, memberships, oh my.

<img width="100%" style="width:100%" src="https://media.giphy.com/media/ycdNP5BQRz51S/giphy.gif" alt="Wizard of Oz; follow the yellow brick road">

As an example, you may want to access a domain admin's account, and you notice in the Bloodhound graph that a non-admin has permission within AD to [force change one or all of the domain admins' passwords](https://www.thehacker.recipes/ad/movement/dacl/forcechangepassword), so you identify that non-admin as the next target for impersonation.

Now, assume that you have identified a target for impersonation-based escalation of privileges. Assuming that target is a computer or server account (not a user account), CVE-2022–26923 was a vulnerability that offered a method of carrying out that impersonation.

## A Pause for Some Context
Introduced in Windows Server® 2008, [Active Directory Certificate Services (AD CS)](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/hh831740(v=ws.11)) is another [AD Server Role](https://redmondmag.com/articles/2015/12/10/server-roles-in-active-directory.aspx) leveraging [public key infrastructure (PKI)](https://en.wikipedia.org/wiki/Public_key_infrastructure) to provide domain users with the ability to create digital certificates. Such digital certificates could be used for general encryption to protect data confidentiality, for the generation of [digital signatures](https://www.cisa.gov/tips/st04-018#:~:text=Digital%20signatures%20create%20a%20virtual,part%20of%20the%20digital%20signature.) to protect message integrity during transmission, or even for authentication against AD, which is the focal use case for the purpose of this analysis since successful privilege escalation via impersonation is all about false positives when authenticating.
With public key infrastructure, on which AD CS is built, one of the overarching ideas is that with any public-private key pair, the private key is kept truly private by the owner and thus can be used to identify and authenticate that owner (which has additional [non-repudiation](https://csrc.nist.gov/glossary/term/non_repudiation) implications). If that owner signs (encrypts) something with their private key, the only way it can be decrypted is with the corresponding public key; more importantly, any message decrypted with a public key can only have come from the owner with the corresponding private key. This theory underlying PKI opens the door to [digital certificate-based authentication](https://docs.oracle.com/cd/E19575-01/820-2765/6nebir7eb/index.html).

By associating, or binding, the digital certificates with accounts on a network in AD (whether computer accounts, user accounts, or device accounts), AD CS allows for those accounts to authenticate against AD using their respective digital certificates. Certificate-based authentication is itself an interesting process relying on password entry in addition to digital signature verification, but this paper will avoid diving into that rabbit hole. Note that this process of binding a digital certificate to an identity for the purpose of it being used to authenticate them should be done in a way that other identities cannot forge that binding. This was the problem behind CVE-2022–26923 - AD CS allowed digital certs to be bound to identities via an attribute (dNSHostName) that could be reused arbitrarily for other identities.

## Using CVE-2022–26923 to Escalate Privileges
As documented by the [Semperis Research Team in August of 2022](https://www.semperis.com/blog/ad-vulnerability-cve-2022-26923/), there were ultimately two main steps that needed to be completed in order to exploit the CVE-2022–26923 privilege escalation vulnerability. First, the attacker needed to change the [dNSHostName](https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/5c578b15-d619-408d-ba17-380714b89fd1) of their own computer account to match the target computer or server account's dNSHostName value (e.g., that of a domain controller computer account). Then, the attacker needed to obtain a digital certificate bound to their own falsely identified computer account by requesting one with a template configured with the SubjectAltRequireDns flag. This flag essentially sets the Subject of the digital certificate to the dNSHostName value of the requesting computer account (without any sort of validation), where the Subject ultimately identifies the computer account bound to the public key. Note that for the first step, there was actually a prerequisite of the attacker creating their own computer account as a logged in user in AD (a feature _enabled by default_ in AD), since dNSHostName attributes can be modified only on computer accounts created by the editor.
The presence of this vulnerability meant that an attacker with access to AD could pick and choose from active AD computer accounts and use a default, built-in component of AD to arbitrarily impersonate any desired target via false digital certificate authentication.

## Mitigation
The easiest, most **sledgehammery** (looky there, I coined a term) fix for this problem would probably be to simply not run AD CS within a Windows domain network, as AD CS is the root of the CVE-2022–26923 rot. This would entirely prevent digital certificate-based authentication, but of course flipping such a broad switch has equivalently broad implications at the enterprise scale which may include, for example, service outages for services running on machines that use certificate-based authentication against AD for valid purposes.

<img width="100%" style="width:100%" src="https://media.giphy.com/media/QNFhSB9oz8BMr5QyzK/giphy.gif" alt="Guy flipping a breaker">
 
Luckily, Microsoft made an [announcement](https://support.microsoft.com/en-us/topic/kb5014754-certificate-based-authentication-changes-on-windows-domain-controllers-ad2c23b0-15d8-4340-a468-4d4f3b188f16) pretty quickly in response to the vulnerability disclosure about a new change to the way certificate-based authentication would be handled by Windows domain controllers. The announcement included explicit actions that needed to be taken to protect domain environments, namely the application of the May 10, 2022 update which placed AD devices into compatibility mode designed primarily to generate audits ahead of a recommended switch to full enforcement mode which, in short, would begin blocking certain authentication attempts not meeting updated digital certificate criteria.
Those criteria were centered on the idea of certificate mappings, or the bindings mentioned previously, where a mapping between a digital certificate and an account is considered weak, or insecure, if it relies on an identifier that can be reused by other accounts (i.e., the dNSHostName attribute). Certificates weakly mapped to identities would consequently generate audit events in compatibility mode for investigation and fixing, and would entirely fail to authenticate those identities upon the enabling of the update's full enforcement mode.

## Conclusion
In short, CVE-2022–26923 was a significant vulnerability within the Active Directory Certificate Services server role that allowed attackers to leverage weak bindings between identities and their digital certificates such that one could completely bypass the security of public-key infrastructure by simply requesting (and obtaining) a digital certificate identifying them in AD as their desired target. Upon its discovery and disclosure on May 10, 2022, it was quickly addressed by an update to the AD CS server role which requires **stronger, non-forgeable** bindings between digital certificates and AD identities.