{"id":15940,"date":"2021-06-14T10:20:24","date_gmt":"2021-06-14T09:20:24","guid":{"rendered":"https:\/\/www.riskinsight-wavestone.com\/?p=15940"},"modified":"2021-09-14T11:51:05","modified_gmt":"2021-09-14T10:51:05","slug":"microsoft-adcs-abusing-pki-in-active-directory-environment","status":"publish","type":"post","link":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/","title":{"rendered":"Microsoft ADCS \u2013 Abusing PKI in Active Directory Environment"},"content":{"rendered":"<p>Due to the ever-growing use of certificates in modern applications, a large number of Active Directory infrastructures make use of Public Key Infrastructures (PKI) features. These features are provided by Certification Authorities (CA) which are either external to Active Directory or deeply coupled with it.<\/p>\n<p>Similar intricate systems, such as Microsoft Exchange, have highlighted <a href=\"https:\/\/github.com\/gdedrouas\/Exchange-AD-Privesc\">a significant number of ways<\/a> that someone with a user account on Active Directory and malicious intent can benefit from to take over Active Directory.<\/p>\n<p>Active Directory Certificate Services (ADCS) have never really been under security scrutiny until a few years ago (by <a href=\"https:\/\/cyberstoph.org\/posts\/2019\/12\/an-introduction-to-golden-certificates\/\">C. Falta<\/a> and later <a href=\"https:\/\/blog.qdsecurity.se\/2020\/09\/04\/supply-in-the-request-shenanigans\/\">Q&amp;D Security<\/a>). We will therefore focus today on how similar techniques can be used to gain Domain Admins privileges.<\/p>\n<p><strong>Note: <\/strong>this article assumes that the reader has a correct understanding of <a href=\"https:\/\/en.wikipedia.org\/wiki\/Active_Directory\">Active Directory<\/a> and\/or <a href=\"https:\/\/en.wikipedia.org\/wiki\/Public_key_infrastructure\">PKI<\/a> operation; some sections may be skipped depending on the reader experience and level of expertise.<\/p>\n<h2>Table of contents<\/h2>\n<ol class=\"ol-toc\">\n<li><a href=\"#section-1\">Active Directory pentest: mission briefing<\/a>\n<ol class=\"ol-toc\">\n<li><a href=\"#section-1-1\">Context and objectives<\/a><\/li>\n<li><a href=\"#section-1-2\">Elevating privileges in an AD environment<\/a>\n<ol class=\"ol-toc\">\n<li><a href=\"#section-1-2-1\">From lateral movement&#8230;<\/a><\/li>\n<li><a href=\"#section-1-2-2\">&#8230; to compromise graphs<\/a><\/li>\n<li><a href=\"#section-1-2-3\">Drafting the domain compromise graph<\/a><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<li><a href=\"#section-2\">Deep dive into Microsoft ADCS<\/a>\n<ol class=\"ol-toc\">\n<li><a href=\"#section-2-1\">What is ADCS?<\/a><\/li>\n<li><a href=\"#section-2-2\">How does ADCS operate?<\/a>\n<ol class=\"ol-toc\">\n<li><a href=\"#section-2-2-1\">Active Directory: Public Key Services<\/a><\/li>\n<li><a href=\"#section-2-2-2\">ADCS server: local configuration<\/a><\/li>\n<li><a href=\"#section-2-2-3\">Mixing it all together!<\/a><\/li>\n<\/ol>\n<\/li>\n<li><a href=\"#section-2-3\">Kerberos, smartcard logon and certificate authentication<\/a>\n<ol class=\"ol-toc\">\n<li><a href=\"#section-2-3-1\">Kerberos 101<\/a><\/li>\n<li><a href=\"#section-2-3-2\">Introducing PKINIT<\/a><\/li>\n<li><a href=\"#section-2-3-3\">Using PKINIT in real life<\/a><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<\/li>\n<li><a href=\"#section-3\">Elevating privileges with ADCS<\/a>\n<ol class=\"ol-toc\">\n<li><a href=\"#section-3-1\">Exploiting an existing ADCS misconfiguration<\/a><\/li>\n<li><a href=\"#section-3-2\">The insidious case of EDITF_ATTRIBUTESUBJECTALTNAME2<\/a><\/li>\n<li><a href=\"#section-3-3\">Local administrator rights on ADCS server<\/a><\/li>\n<li><a href=\"#section-3-4\">ACL exploit on user objects (1)<\/a><\/li>\n<li><a href=\"#section-3-5\">ACL exploit on user objects (2)<\/a><\/li>\n<li><a href=\"#section-3-6\">ACL exploit on certificate templates<\/a><\/li>\n<li><a href=\"#section-3-7\">ACL exploit on enrollment services<\/a><\/li>\n<\/ol>\n<\/li>\n<li><a href=\"#section-4\">Current mitigations<\/a>\n<ol class=\"ol-toc\">\n<li><a href=\"#section-4-1\">Integration within the Active Directory tiering model<\/a>\n<ol class=\"ol-toc\">\n<li><a href=\"#section-4-1-1\">ESAE: Enhanced Security admin Environment<\/a><\/li>\n<li><a href=\"#section-4-1-2\">Moving ADCS objects up one tier!<\/a><\/li>\n<\/ol>\n<\/li>\n<li><a href=\"#section-4-2\">Proper handling of corner cases<\/a>\n<ol class=\"ol-toc\">\n<li><a href=\"#section-4-2-1\">Context example<\/a><\/li>\n<li><a href=\"#section-4-2-2\">Setting the manager approval<\/a><\/li>\n<li><a href=\"#section-4-2-3\">Choosing your CA managers<\/a><\/li>\n<\/ol>\n<\/li>\n<li><a href=\"#section-4-3\">Adding the detection layer<\/a><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<h2><\/h2>\n<p>&nbsp;<\/p>\n<h1><a name=\"section-1\"><\/a>Active Directory pentest: mission briefing<\/h1>\n<p>This article will tackle Microsoft ADCS and its potential issues under the specific prism of an Active Directory pentest, but the conclusions will be applicable on a broader scope: red team assignments, ADCS hardening, etc.<\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-1-1\"><\/a>Context and objectives<\/h2>\n<p>An Active Directory pentest is a type of assignment where the sponsor of the audit is asking the pentester to interact with the audit target\u2019s infrastructure to find ways of gaining control of Active Directory. The auditor usually performs this task under the two following approaches:<\/p>\n<ul>\n<li>The <span style=\"color: #005572;\"><strong>black box approach<\/strong><\/span>: it simulates an attacker who a<span style=\"color: #000000;\">lready has <strong>physical access<\/strong> to the target\u2019s premises (and consequently to network plugs and physical devices); the goal is often to <strong>progress<\/strong> <strong>towards the grey box approach<\/strong>, leveraging unencrypted hard drives, credential sniffing, guest access and misconfigured applications on vulnerable assets;<\/span><\/li>\n<li>The <span style=\"color: #005572;\"><strong>grey box approach<\/strong><\/span>: the pentester acts as a malicious or compromised user, within the context of its domain session, i.e. being able to execute arbitrary code as this user.<\/li>\n<\/ul>\n<p>In our case, we will focus on the grey box approach, therefore consid<span style=\"color: #000000;\">ering a <strong>malicious party<\/strong> who already has the <strong>ability of interacting with the domain<\/strong> as a standard user with no specific rights. The goal of the pentester would be to find a way to leverage the current rights of the user on the domain to <strong>compromise high-privileged principals<\/strong>, frequently the members of the <strong>Domain Admins<\/strong> group.<\/span><\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-1-2\"><\/a>Elevating privileges in an AD environment<\/h2>\n<h3><a name=\"section-1-2-1\"><\/a>From lateral movement &#8230;<\/h3>\n<p>Historically, Windows has been built as a <strong>user-friendly operating system<\/strong>, which means that it will do its best to <strong>minimize the number of situations where a user must type its password<\/strong>. In terms of user experience, most users will only type their password to unlock their workstation. System administrators may have to type it another time when using the Remote Desktop Protocol (RDP), but they don\u2019t expect it to type it again when connected to the remote server and\/or interacting with domain resources.<\/p>\n<p>Under the hood, it means that Windows offers <strong>Single-Sign-On<\/strong> (SSO) features, which allow the system to authenticate as the user to other systems or applications. This sleight of hand is performed by the lsass.exe process, which caches usable credentials for the user in memory. There are two types of credentials that can be cached:<\/p>\n<ul>\n<li>Authenticators <strong>derived <\/strong>from credentials, e.g. the password itself, or its NT hash<\/li>\n<li>Authenticators <strong>retrieved <\/strong>thanks to other means, e.g. Kerberos tickets<\/li>\n<\/ul>\n<p>The credentials are cached into the memory of the <code>lsass.exe<\/code> process running with the <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/win32\/secauthz\/mandatory-integrity-control\">System integrity level<\/a>. Either processes running as <code>SYSTEM<\/code>, or processes with <code>SeDebugPrivilege<\/code> enabled (which by default can only be enabled by local administrators) would be able to peek into <code>lsass.exe<\/code> memory.<\/p>\n<p>Various tools, such as <a href=\"https:\/\/github.com\/gentilkiwi\/mimikatz\">Mimikatz<\/a> and <a href=\"https:\/\/www.passcape.com\/windows_password_recovery\">Windows Password Recovery<\/a>, allow users with local administration rights to extract the aforementioned authenticators from the memory:<\/p>\n<figure id=\"post-15992 media-15992\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-15992 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/01.png\" alt=\"\" width=\"449\" height=\"365\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/01.png 688w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/01-235x191.png 235w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/01-48x39.png 48w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/01-155x125.png 155w\" sizes=\"auto, (max-width: 449px) 100vw, 449px\" \/><\/figure>\n<p class=\"TitreFigure2\" style=\"text-align: center;\"><em><span lang=\"EN-US\">Mimikatz extracting authenticators from lsass.exe process memory<\/span><\/em><\/p>\n<p>These authenticators in turn can be used to log in onto other workstations and servers, using techniques such as <a href=\"https:\/\/en.hackndo.com\/pass-the-hash\/\">Pass-the-Hash<\/a> or <a href=\"https:\/\/attack.mitre.org\/techniques\/T1550\/003\/\">Pass-the-Ticket<\/a>. The use of these techniques is included in what is called <span style=\"color: #005572;\"><strong>Lateral Movement<\/strong><\/span> and allows progressing from low-privileged assets to high-privileged ones.<\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"section-1-2-2\"><\/a>&#8230; to compromise graphs<\/h3>\n<p>In a grey box approach, a pentester would usually be provided with a standard network access, a domain-joined workstation and a basic user account. Assuming local administration rights are somehow obtained, the pentester would then gather:<\/p>\n<ul>\n<li>The <span style=\"color: #005572;\"><strong>local accounts\u2019 credentials<\/strong><\/span> in the SAM database (NT hashes)<\/li>\n<li>The <span style=\"color: #005572;\"><strong>local and domain accounts\u2019 authenticators<\/strong><\/span> which recently logged in (NT hashes and Kerberos tickets, even cleartext passwords under some conditions)<\/li>\n<\/ul>\n<p>Using this newly found credential, the next objective is to try using them on the other assets in the domain. If this works, <strong>the operation can be repeated<\/strong>, each time gaining <strong>more and more foothold on the domain<\/strong>.<\/p>\n<p>This progression is quite easily performed by hand in a lab domain a limited number of workstations and servers but cannot be humanly feasible in a real-life domain with hundreds of servers and thousands of users and workstations (without mentioning domain trusts, etc.). This is where graph theory comes into play, with the following equivalents:<\/p>\n<ul>\n<li><span style=\"color: #005572;\"><strong>Vertices<\/strong> <\/span>(nodes) represent domain assets: user objects, computer objects and group objects<\/li>\n<li><span style=\"color: #005572;\"><strong>Oriented edges<\/strong><\/span> connect two vertices when one has the ability to compromise the other (also called <span style=\"color: #005572;\"><strong>control path<\/strong><\/span>)<\/li>\n<\/ul>\n<p>With such a graph, one would quite easily <strong>find<\/strong> (if it exists),<strong> the shortest path from a basic user account to a high-privileged principal<\/strong> on the domain. The only remaining task would be to exploit it. A path from one principal to another is called a compromise path, and the set of compromise paths between two principals represent all the means at one\u2019s disposal to compromise the latter starting from the former:<\/p>\n<figure id=\"post-16065 media-16065\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-16065 size-medium\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-13_28_44-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-437x131.png\" alt=\"\" width=\"437\" height=\"131\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-13_28_44-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-437x131.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-13_28_44-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-71x21.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-13_28_44-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-768x230.png 768w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-13_28_44-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility.png 860w\" sizes=\"auto, (max-width: 437px) 100vw, 437px\" \/><\/figure>\n<p class=\"TitreFigure2\" style=\"text-align: center;\"><em><span lang=\"EN-US\">Compromise paths between a user and a member of the Domain Admins group<\/span><\/em><\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"section-1-2-2\"><\/a>Drafting the domain compromise graph<\/h3>\n<p>In order to build the domain compromise graph, a list of possible edge types has to be defined. Lateral movement using credential dumping is often central, but it is not the only way of compromising principals. The current list includes (but is not limited to):<\/p>\n<ul>\n<li>Domain <strong>group membership<\/strong><\/li>\n<li>Being<strong> local administrator<\/strong> of a target<\/li>\n<li>Having an <strong>open session<\/strong> on a target<\/li>\n<li>Ability to <strong>connect <\/strong>to a target <strong>using RDP<\/strong> (generally implicitly combined with the ease of privilege escalation)<\/li>\n<li>Domain <strong>principal ownership<\/strong><\/li>\n<li><strong>Permissive Access Control Entries<\/strong> (ACEs) over domain objects: GenericAll, GenericWrite, WriteProperty, etc.<\/li>\n<li>\u201c<strong>By design<\/strong>\u201d compromise paths from built-in groups: Server Operators, Backup Operators, DNS Admins, etc.<\/li>\n<\/ul>\n<p>Building domain compromise graphs is particularly difficult to perform by hand, especially on large domains. There exist tools that help building these graphs and adding edges to find compromise paths.<\/p>\n<p>Although many tools exist (Tenable.ad, AD-Control-Paths, PingCastle), the most famous one is BloodHound, and it leverages most of known techniques used to compromise accounts:<\/p>\n<figure id=\"post-15996 media-15996\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-15996 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/03.png\" alt=\"\" width=\"834\" height=\"385\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/03.png 834w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/03-414x191.png 414w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/03-71x33.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/03-768x355.png 768w\" sizes=\"auto, (max-width: 834px) 100vw, 834px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Example graph generated by BloodHound<\/em><\/p>\n<p>&nbsp;<\/p>\n<h1><a name=\"section-2\"><\/a>Deep dive into Microsoft ADCS<\/h1>\n<h2><a name=\"section-2-1\"><\/a>What is ADCS?<\/h2>\n<p><span style=\"color: #005572;\"><strong>Microsoft Active Directory Certificate Services<\/strong><\/span> (ADCS) is a role that can be given to servers who will act as <span style=\"color: #005572;\"><strong>Certification Authorities<\/strong><\/span> (CA) in the forest. It integrates naturally within the forest, which means that there are domain objects that represents the different actors involved in a PKI lifecycle, and Access Control Lists regulating the interactions between these actors:<\/p>\n<ul>\n<li>Certificate template management<\/li>\n<li>Certificate enrolment<\/li>\n<li>Certificate revocation<\/li>\n<li>CRL publication<\/li>\n<li>etc.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-2-2\"><\/a>How does ADCS operate?<\/h2>\n<p>The ADCS server role is installed on every server that is to act as a CA. When installing the ADCS role, the administrator is presented with twochoices: first, either install a<strong> Standalone<\/strong> or an <strong>Enterprise <\/strong><em>CA<\/em>:<\/p>\n<figure id=\"post-15998 media-15998\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-15998 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/04.png\" alt=\"\" width=\"500\" height=\"160\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/04.png 945w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/04-437x140.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/04-71x23.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/04-768x245.png 768w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>CA setup type choice<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Then, in the case of an enterprise CA, it can be positioned as a <strong>Root CA <\/strong>or <strong>Subordinate CA<\/strong>:<\/p>\n<figure id=\"post-16000 media-16000\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16000 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/05.png\" alt=\"\" width=\"494\" height=\"163\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/05.png 945w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/05-437x144.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/05-71x23.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/05-768x254.png 768w\" sizes=\"auto, (max-width: 494px) 100vw, 494px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>CA type choice<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>This article will focus on the Enterprise Root CA, for which the configuration is split between two places:<\/p>\n<ul>\n<li><span style=\"color: #005572;\"><strong>Active Directory<\/strong><\/span>, in which information global to the PKI infrastructure is stored: names and location of CA servers, global rights, etc.<\/li>\n<li>The <span style=\"color: #005572;\"><strong>Windows servers on which the ADCS role is installed<\/strong><\/span>, on which the day-to-day configuration parameters specific to this Certification Authority are stored: CA administration rights, certificate emission parameters, etc.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h3><a name=\"section-2-2-1\"><\/a>Active Directory: Public Key Services<\/h3>\n<p>In Active Directory, the configuration is stored under the following location (Configuration partition, thus defined at forest-level):<\/p>\n<pre class=\"w-code\">CN=Public Key Services,CN=Services,CN=Configuration,DC=lab,DC=local<\/pre>\n<p>The configuration can be viewed using the <code>adsiedit.msc<\/code> component in the MMC:<\/p>\n<figure id=\"post-16002 media-16002\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16002 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/06.png\" alt=\"\" width=\"543\" height=\"184\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/06.png 658w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/06-437x148.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/06-71x24.png 71w\" sizes=\"auto, (max-width: 543px) 100vw, 543px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Global PKI configuration in Active Directory<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>Certificate templates<\/h4>\n<p>The <span style=\"color: #005572;\"><strong>CertificateTemplate<\/strong><\/span> container has one domain object of type <code>pKICertificateTemplate<\/code> for every template to be shared amongst the enterprise Certification Authorities. These templates define, through <strong>attributes <\/strong>configured on their domain object, a <strong>set of policies<\/strong> that mostly describe and constrain:<\/p>\n<ul>\n<li><strong>General settings:<\/strong> the validity period of the delivered certificates<\/li>\n<li><strong>Request handling:<\/strong> the purpose of the certificate and the ability to export the private key (although this can be bypassed if the private key is generated prior to the certificate request, for example with the <code>certreq<\/code> binary)<\/li>\n<li><strong>Cryptography:<\/strong> the Cryptographic Services Provider (CSP) to be used and the minimum key size<\/li>\n<li><strong>Extensions:<\/strong> the list of X509v3 extensions to be included in the certificate, and their criticality (including the <code>KeyUsage<\/code> and <code>ExtendedKeyUsages<\/code>)<\/li>\n<li><strong>Subject name<\/strong>, which dictates how the Distinguished Name of the certificate is built: either from a user-supplied value in the request, or from the identity of the domain principal requesting the certificate<\/li>\n<li><strong>Issuance requirements<\/strong><em>:<\/em> the need for a \u201cCA certificate manager\u201d approval in order to deliver the certificate<\/li>\n<li><strong>Security descriptor<\/strong><em>:<\/em> the ACL of the certificate template, including the identity of the principals who have the extended right needed to enroll to the template<\/li>\n<\/ul>\n<figure id=\"post-16008 media-16008\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16008 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/09.png\" alt=\"\" width=\"321\" height=\"280\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/09.png 400w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/09-219x191.png 219w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/09-45x39.png 45w\" sizes=\"auto, (max-width: 321px) 100vw, 321px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Access Control List of a pKICertificateTemplate object<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>Enrollment services<\/h4>\n<p>The <span style=\"color: #005572;\"><strong>Enrollment Services<\/strong><\/span> provides domain principals with the list of enterprise ADCS servers with the domain, under the following naming convention:<\/p>\n<pre class=\"w-code\">CN=&lt;CA name&gt;,CN=Enrollment Services,CN=Public Key Services,...<\/pre>\n<p>The attributes of these objects describe these Certification Authorities, how the principals can reach them, and what they are authorized to do:<\/p>\n<ul>\n<li>The <code>dNSHostName<\/code> attribute corresponds to the FQDN (or alias) of the ADCS server<\/li>\n<li>The <code>certificateTemplates<\/code> attribute lists a <strong>subset of the Certificate Templates<\/strong> that the principals are allowed to request certificates for from this Certification Authority<\/li>\n<li>The <strong>Security Descriptor<\/strong> (available through the \u201cSecurity\u201d tab) lists the actions that principals are allowed to do on the Certification Authority or the current domain object: enroll, modify the list of certificate templates, etc.<\/li>\n<\/ul>\n<figure id=\"post-16010 media-16010\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16010 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/10.png\" alt=\"\" width=\"447\" height=\"253\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/10.png 634w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/10-337x191.png 337w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/10-69x39.png 69w\" sizes=\"auto, (max-width: 447px) 100vw, 447px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>pKIEnrollmentService object<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>NtAuth enterprise store<\/h4>\n<p>The <span style=\"color: #005572;\"><strong>NtAuthCertificates <\/strong><\/span>is a domain object which contains a<strong> list of CA certificates<\/strong> (in the <code>cACertificate<\/code> attribute). This list dictates <strong>which certificates will be valid for authentication purposes<\/strong> across the domain, as authentication services will look for the <strong>direct issuer CA<\/strong> within this enterprise store:<\/p>\n<figure id=\"post-16012 media-16012\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16012 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/11.png\" alt=\"\" width=\"394\" height=\"224\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/11.png 500w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/11-336x191.png 336w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/11-69x39.png 69w\" sizes=\"auto, (max-width: 394px) 100vw, 394px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>NtAuth store contents<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>It is important to note that workstations and servers (including Domain Controllers) keep a<strong> local cached<\/strong> version of this store in the Windows Registry, at the following location:<\/p>\n<pre class=\"w-code\">HKLM\\SOFTWARE\\Microsoft\\EnterpriseCertificates\\NTAuth\\Certificates<\/pre>\n<p>Any update will not be replicated unless the following command is issued locally (or after a while when the machine GPO is refreshed):<\/p>\n<pre class=\"w-code\">gpupdate \/force<\/pre>\n<h4><\/h4>\n<h4>Other enterprise certificate stores<\/h4>\n<p>The <strong>Certification Authorities<\/strong> and <strong>AIA <\/strong>(Authority Information Access) containers correspond respectively to the <strong>Root Certification Authorities<\/strong> and <strong>Intermediate Certification Authorities<\/strong> certificate stores for the domain. Every object present in these stores has its <code>cACertificate<\/code> attribute set to the certificate of said authority. This enterprise store is automatically replicated within the local stores of domain workstations and servers. Additional parameters, such as <code>crossCertificatePair<\/code>, can be also set in some cases.<\/p>\n<figure id=\"post-16004 media-16004\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16004 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/07.png\" alt=\"\" width=\"526\" height=\"265\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/07.png 722w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/07-379x191.png 379w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/07-71x36.png 71w\" sizes=\"auto, (max-width: 526px) 100vw, 526px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>certificationAuthority object<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>Certificate revocation list<\/h4>\n<p>The <span style=\"color: #005572;\"><strong>CDP<\/strong> <\/span>(CRL Distribution Point) container aims at providing the domain with <strong>Certificate Revocation Lists<\/strong> for each enterprise ADCS server installed. Therefore, each sub-container has an object, which contains the CRL (optionally delta CRL) in the <code>certificateRevocationList<\/code> (optionally <code>deltaRevocationList<\/code>), named as follows:<\/p>\n<pre class=\"w-code\">CN=&lt;CA name&gt;,CN=&lt;ADCS server&gt;,CN=CDP,CN=Public Key Services,...<\/pre>\n<figure id=\"post-16006 media-16006\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16006 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/08.png\" alt=\"\" width=\"462\" height=\"237\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/08.png 723w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/08-372x191.png 372w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/08-71x36.png 71w\" sizes=\"auto, (max-width: 462px) 100vw, 462px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>cRLDistributionPoint object<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>Miscellaneous objects<\/h4>\n<p>The <strong>KRA <\/strong>(Key Recovery Agent) and <strong>OID <\/strong>containers describe objects and parameters vital to the ADCS servers, but on which <strong>focus is not mandatory in this context<\/strong>.<\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"section-2-2-2\"><\/a>ADCS server: local configuration<\/h3>\n<p>In addition to the global configuration stored in Active Directory, each ADCS server can be <strong>locally configured<\/strong> to tune its behavior regarding day-to-day operations. These rights allow users and groups to perform various actions linked to the Certification Authority, such as:<\/p>\n<ul>\n<li>Certificate request validation<\/li>\n<li>Certificate revocation<\/li>\n<li>Certificate Revocation List (CRL) publication<\/li>\n<li>Certification Authority renewal<\/li>\n<li>etc.<\/li>\n<\/ul>\n<p>This extensive set of rights is organized under roles, which limits the fine tuning of access rules but provides a <strong>Role Based Access Control<\/strong> (RBAC) mechanism. The following matrix summarizes the 4 roles and the main actions associated with them:<\/p>\n<figure id=\"post-16014 media-16014\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-16014 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/12.png\" alt=\"\" width=\"1040\" height=\"297\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/12.png 1040w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/12-437x125.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/12-71x20.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/12-768x219.png 768w\" sizes=\"auto, (max-width: 1040px) 100vw, 1040px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Local rights matrix for ADCS servers<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>The attribution of roles to users and groups can be configured from the \u201cproperties\u201d contextual menu of the Certification Authority instance (using the <code>certsrv.msc<\/code> MMC component):<\/p>\n<figure id=\"post-16016 media-16016\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16016 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/13.png\" alt=\"\" width=\"480\" height=\"320\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/13.png 595w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/13-286x191.png 286w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/13-58x39.png 58w\" sizes=\"auto, (max-width: 480px) 100vw, 480px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Local attribution of roles on the CA server<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Access to these configuration parameters and global PKI operation can be mostly performed remotely using Remote Procedure Call (RPC), via the Microsoft Management Console (MMC).<\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"section-2-2-3\"><\/a>Mixing it all together!<\/h3>\n<p>The heart of the day-to-day interactions with ADCS and CA servers resides in the <strong>certificate templates<\/strong> and <strong>enrollment services<\/strong>:<\/p>\n<ul>\n<li>Each <strong>enrollment service<\/strong> links to a <strong>CA server<\/strong> with the ADCS role \u2013 <strong>additional settings<\/strong> can be configured <strong>locally<\/strong> on a per-server basis, mainly stored in the registry<\/li>\n<li>The <strong>enrollment service<\/strong> lists a <strong>subset of the certificate templates<\/strong> published:<\/li>\n<\/ul>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16081 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_24_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility.png\" alt=\"\" width=\"874\" height=\"228\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_24_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility.png 1078w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_24_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-437x114.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_24_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-71x19.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_24_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-768x200.png 768w\" sizes=\"auto, (max-width: 874px) 100vw, 874px\" \/><\/p>\n<p style=\"text-align: center;\"><em>ADCS operation overview<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Finally, in order to request a certificate, the user \/ computer must: \u200b<\/p>\n<ul>\n<li>Have the <strong>enrollment rights <\/strong>on the <strong><strong>Enrollmen<\/strong><\/strong><strong>t Service<\/strong><\/li>\n<li><em>And<\/em> have the <strong>enrollment rights<\/strong> on the <strong>target Certificate Template<\/strong>\u200b<\/li>\n<li>Be able to reach the CA server on <strong>port 135<\/strong> (RPC) and <strong>high dynamic ports<\/strong> (usually start at 49152)<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-2-3\"><\/a>Kerberos, smartcard logon and certificate authentication<\/h2>\n<h3><a name=\"section-2-3-1\"><\/a>Kerberos 101<\/h3>\n<p>Authentication in Active Directory is mostly performed using one two authentication protocols:<\/p>\n<ul>\n<li>The NTLM challenge-response, solely based on the NT hash of the principal<\/li>\n<li>Kerberos \u2013 a protocol originally designed by the MIT \u2013 which uses tickets and secrets keys<\/li>\n<\/ul>\n<p>In its most simple form, Kerberos operates as follows:<\/p>\n<ol>\n<li>An <strong>Active Directory principal<\/strong> (user, computer) emits an <span style=\"color: #005572;\"><strong>AS-REQ<\/strong><\/span> request to the <strong>Authentication Service (AS)<\/strong>; this request contains a pre-authentication message that validates the principal\u2019s identity<\/li>\n<li>If the authentication succeeds, the <strong>AS<\/strong> replies with an <span style=\"color: #005572;\"><strong>AS-REP<\/strong><\/span> which includes a <strong>Ticket-Granting-Ticket (TGT)<\/strong> delivered by the <strong>Key Distribution Center (KDC)<\/strong><\/li>\n<li>The principal then sends <span style=\"color: #005572;\"><strong>TGS-REQ<\/strong><\/span> requests to the <strong>Ticket-Granting-Service (TGS)<\/strong>, including the <strong>TGT<\/strong>, to ask for an ticket built for an <strong>Active Directory service<\/strong> \u2013 an AD principal whose <code>servicePrincipalName<\/code> attribute is not empty<\/li>\n<li>The <strong>KDC <\/strong>replies with an <span style=\"color: #005572;\"><strong>TGS-REP<\/strong><\/span> which includes a <strong>Service Ticket (ST)<\/strong> encrypted with the service\u2019s secret key (RC4 key (NT Hash), AES-256 key, etc.)<\/li>\n<li>The principal can authenticate to said service with an <span style=\"color: #005572;\"><strong>AP-REQ<\/strong><\/span> request by sending the <span style=\"color: #000000;\"><strong>ST<\/strong><\/span>, which will be decrypted by the service to identify the client principal<\/li>\n<li>If everything is in order, the service replies with an <span style=\"color: #005572;\"><strong>AP-REP<\/strong><\/span> message:<\/li>\n<\/ol>\n<figure id=\"post-16084 media-16084\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16084 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility.png\" alt=\"\" width=\"471\" height=\"470\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility.png 563w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-191x191.png 191w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-39x39.png 39w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-32x32.png 32w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-64x64.png 64w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-96x96.png 96w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-128x128.png 128w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-70x70.png 70w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-175x175.png 175w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-130x130.png 130w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-115x115.png 115w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_29_55-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-30x30.png 30w\" sizes=\"auto, (max-width: 471px) 100vw, 471px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Kerberos authentication graphical representation<\/em><\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"section-2-3-2\"><\/a>Introducing PKINIT<\/h3>\n<p>The type of pre-authentication to be used is described in the <code>padata-type<\/code> field of the <code>AS-REQ<\/code> request. The most common value is <code>PA-ENC-TIMESTAMP<\/code>, which works by <span style=\"color: #005572;\"><strong>encrypting a timestamp token with one of the user\u2019s secrets<\/strong><\/span> (NT hash, AES key, etc.). The complete list of values that can be used within a Microsoft environment is detailed in <a href=\"https:\/\/docs.microsoft.com\/en-us\/openspecs\/windows_protocols\/ms-kile\/ae60c948-fda8-45c2-b1d1-a71b484dd1f7\">[MS-KILE]<\/a>.<\/p>\n<p>Kerberos authentication using smartcards relies on the <code>PA-PK-AS-REQ<\/code> value and uses the <span style=\"color: #005572;\"><strong>PKINIT <\/strong><\/span><a href=\"https:\/\/tools.ietf.org\/html\/rfc4556\">[RFC4556]<\/a> protocol. This protocol defines how public key cryptography can be used as a pre-authentication mechanism in Kerberos, whereas usually it uses symmetric cryptographic protocols (using shared secrets derived from the password).<\/p>\n<p><span style=\"color: #005572;\"><strong>PKINIT <\/strong><\/span>needs to identify the authenticating Active Directory object based on sent elements, as described below:<\/p>\n<figure id=\"post-16087 media-16087\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16087 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_33_03-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility.png\" alt=\"\" width=\"374\" height=\"166\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_33_03-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility.png 672w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_33_03-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-431x191.png 431w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/2021-06-09-15_33_03-Microsoft-ADCS-Abusing-PKI-to-get-the-keys-to-the-realm.docx-Compatibility-71x31.png 71w\" sizes=\"auto, (max-width: 374px) 100vw, 374px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Global overview of PKINIT operating<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Like in the standard mode, a<strong> timestamp token is generated <\/strong>that will later ensure the freshness of the authentication. <strong>This token is signed<\/strong> with the user\u2019s private key,<strong> the corresponding certificate is sent in the AS-REQ packet<\/strong> and, depending on the type of mapping intended (explicit or implicit), either a principal name or hints that can be used to locate the principal. The detailed operating of the implicit and explicit mappings is described below:<\/p>\n<figure id=\"post-16089 media-16089\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-16089 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/50.png\" alt=\"\" width=\"538\" height=\"709\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/50.png 538w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/50-145x191.png 145w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/50-30x39.png 30w\" sizes=\"auto, (max-width: 538px) 100vw, 538px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Details of PKINIT operating (<a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/security\/identity-protection\/smart-cards\/smart-card-certificate-requirements-and-enumeration\">source<\/a>)<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Once the Active Directory object is located, depending on the path taken, the certificate will have to meet the NT_AUTH policy, i.e. having its <strong>direct issuer\u2019s certificate included in the NtAuth enterprise store<\/strong>.<\/p>\n<p>Then, the authentication server will verify that the certificate \u00ab&nbsp;Enhanced Key Usage&nbsp;\u00bb extension contains either \u201c<span style=\"color: #005572;\"><strong>Client Authentication<\/strong><\/span>\u201d (<code>1.3.6.1.5.5.7.3.2<\/code>), \u201c<span style=\"color: #005572;\"><strong>Microsoft Smartcard Logon<\/strong><\/span>\u201d (<code>1.3.6.1.4.1.311.20.2.2<\/code>), \u201c<span style=\"color: #005572;\"><strong>Key Purpose Client Auth<\/strong><\/span>\u201d (<code>1.3.6.1.5.2.3.4<\/code>) or \u201c<span style=\"color: #005572;\"><strong>Any purpose<\/strong><\/span>\u201d (<code>2.5.29.37.0<\/code>).<\/p>\n<p>Finally, the KDC will verify that the certificate provided <strong>links to a trusted root Certification Authority<\/strong>, is <strong>valid <\/strong>(dates and revocation) and that the <strong>signature of the timestamp token is cryptographically correct<\/strong>. If all checks pass, the user is provided with a TGT for the located AD object.<\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"section-2-3-3\"><\/a>Using PKINIT in real life<\/h3>\n<p>The <span style=\"color: #005572;\"><strong>PKINIT <\/strong><\/span>protocol is automatically used when smartcard logon is performed. The authentication GUI detects that a smartcard can be used, and, if the user provides the correct PIN, <strong>uses the embedded private key to sign the pre-authentication data<\/strong>.<\/p>\n<p>By default, only the associated certificate is sent but administrators can enable the use of \u201cname hints\u201d through local policies (<em>Computer Configuration &gt; Administrative templates &gt; Windows components &gt; Smartcard &gt; Allow username hints<\/em>):<\/p>\n<figure id=\"post-16026 media-16026\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16026 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/18.jpg\" alt=\"\" width=\"421\" height=\"249\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/18.jpg 768w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/18-323x191.jpg 323w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/18-66x39.jpg 66w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/18-120x70.jpg 120w\" sizes=\"auto, (max-width: 421px) 100vw, 421px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Providing name hints alongside the certificate<\/em><\/p>\n<p><em>&nbsp;<\/em><\/p>\n<p>It is also possible to use third-party tools to request a TGT using PKINIT and load it alongside legitimate tickets in the user\u2019s session. In the examples below, the current user has two certificates in its store:<\/p>\n<ul>\n<li>A certificate named \u201c<span style=\"color: #005572;\"><strong>Explicit<\/strong><\/span>\u201d with thumbprint <code>9c7bd7...1ce0b<\/code> and mapped to the <code>APERTURE\\GlADOS<\/code> domain user via its <code>altSecurityIdentities<\/code> attribute<\/li>\n<li>A certificate named \u201c<span style=\"color: #005572;\"><strong>Implicit<\/strong><\/span>\u201d with thumbprint <code>f414...000c8<\/code> and including the <code>userPrincipalName<\/code> set as <code>cave@aperture.science<\/code><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4>With Kekeo<\/h4>\n<p><a href=\"https:\/\/github.com\/gentilkiwi\/kekeo\">Kekeo<\/a> is a piece of software developed by <strong>Gentilkiwi<\/strong>, the author of the well-known tool <strong>Mimikatz<\/strong>. It aims at providing its users with utilities to easily manipulate Windows API related to Kerberos and other protocols. However, if detected, it is hard to compile anew to evade detection due to the use of the commercial ASN.1\/C library.<\/p>\n<p>The screenshots below detail how <span style=\"color: #005572;\"><strong>Kekeo <\/strong><\/span>provides support for <strong>PKINIT<\/strong>:<\/p>\n<figure id=\"post-16028 media-16028\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-16028 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/19.png\" alt=\"\" width=\"771\" height=\"174\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/19.png 771w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/19-437x99.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/19-71x16.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/19-768x173.png 768w\" sizes=\"auto, (max-width: 771px) 100vw, 771px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Using PKINIT with explicit mapping<\/em><\/p>\n<p>&nbsp;<\/p>\n<figure id=\"post-16030 media-16030\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-16030 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/20.png\" alt=\"\" width=\"887\" height=\"173\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/20.png 887w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/20-437x85.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/20-71x14.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/20-768x150.png 768w\" sizes=\"auto, (max-width: 887px) 100vw, 887px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Using PKINIT with implicit mapping in kekeo<\/em><\/p>\n<p>&nbsp;<\/p>\n<h4>With Rubeus<\/h4>\n<p>As described on the tool\u2019s GitHub repository, <a href=\"https:\/\/github.com\/GhostPack\/Rubeus\">Rubeus<\/a> is a C# toolset for raw Kerberos interaction and abuses. Its advantage comes from the fact that it can be easily recompiled to evade detection from security tools.<\/p>\n<p>The screenshots below detail how <span style=\"color: #005572;\"><strong>Rubeus <\/strong><\/span>provides support for <strong>PKINIT<\/strong>, although username hints are mandatory since the \/user switch must be provided:<\/p>\n<figure id=\"post-16032 media-16032\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-16032 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/21.png\" alt=\"\" width=\"710\" height=\"329\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/21.png 710w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/21-412x191.png 412w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/21-71x33.png 71w\" sizes=\"auto, (max-width: 710px) 100vw, 710px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Using PKINIT with explicit mapping in Rubeus<\/em><\/p>\n<figure id=\"post-16034 media-16034\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-16034 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/22.png\" alt=\"\" width=\"696\" height=\"345\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/22.png 696w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/22-385x191.png 385w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/22-71x35.png 71w\" sizes=\"auto, (max-width: 696px) 100vw, 696px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Using PKINIT with implicit mapping in Rubeus<\/em><\/p>\n<p>&nbsp;<\/p>\n<h1><a name=\"section-3\"><\/a>Elevating privileges with ADCS<\/h1>\n<p>The idea behind exploiting ADCS-related control paths is mostly to fraudulently obtain a certificate to authenticate as a privileged principal using PKINIT. Based on the PKINIT decision graph, there are two ways that certificates that can be used to achieve this purpose:<\/p>\n<ul>\n<li>For <span style=\"color: #005572;\"><strong>explicit mappings<\/strong><\/span>, it needs to be configured on the target object as an alternative security identity<\/li>\n<li>For <span style=\"color: #005572;\"><strong>implicit mappings<\/strong><\/span>, it needs to includes the UserPrincipalName (UPN) of the target principal in the Subject Alternative Name extension<\/li>\n<\/ul>\n<p>The sections below aim at detailing the prerequisites needed to conduct the attack, and how it can be performed.<\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-3-1\"><\/a>Exploiting an existing ADCS misconfiguration<\/h2>\n<p>In some cases, no additional ACL exploit is needed because there are existing certificate templates that already validate the prerequisites needed to request an authentication certificate for any other principal:<\/p>\n<ul>\n<li>The <strong>template is listed<\/strong> in at least one of the enrollment services, and both grant the enroll rights to one of the assets (user, computer) already compromised<\/li>\n<li>The <strong>server<\/strong> associated to the enrollment service <strong>is reachable<\/strong> on port 135 and high ports<\/li>\n<li>The template lists at least one of the following <strong>extended key usages<\/strong>: <span style=\"color: #005572;\">Client Authentication<\/span>, <span style=\"color: #005572;\">Microsoft Smartcard Logon<\/span>, <span style=\"color: #005572;\">Key Purpose Client Auth<\/span> or <span style=\"color: #005572;\">Any Purpose<\/span><\/li>\n<li>The template allows <strong>supplying the subject name in the request<\/strong><\/li>\n<li><strong>No additional approval<\/strong> is required for the certificate issuance; such parameter can be configured at the template level \u2013 the list of validators is configured at the server-level and can only be determined by users with at least \u201cRead\u201d privileges on the CA<\/li>\n<\/ul>\n<p>If all conditions are met, there are multiple options to request the certificate (<code>certreq<\/code> executable or the <code>X509Enrollment<\/code> COM object in PowerShell), but the fastest is to use the <code>certmgr.msc<\/code> MMC component:<\/p>\n<figure id=\"post-16036 media-16036\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\" wp-image-16036 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/23.png\" alt=\"\" width=\"582\" height=\"224\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/23.png 789w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/23-437x168.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/23-71x27.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/23-768x296.png 768w\" sizes=\"auto, (max-width: 582px) 100vw, 582px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Requesting a new certificate with the MMC<\/em><\/p>\n<p><em>&nbsp;<\/em><\/p>\n<p>At the template selection menu, interesting templates will appear with a yellow warning sign, since they need the requester to supply the name of the subject:<\/p>\n<figure id=\"post-16038 media-16038\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16038 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/24.png\" alt=\"\" width=\"500\" height=\"106\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/24.png 727w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/24-437x93.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/24-71x15.png 71w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Exploitable certificate template<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Then, enter a friendly name in the common name of the certificate (since kekeo needs it to select the certificate), and the UPN of the target user in the alternative name section:<\/p>\n<figure id=\"post-16040 media-16040\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16040 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/25.png\" alt=\"\" width=\"374\" height=\"305\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/25.png 614w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/25-234x191.png 234w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/25-48x39.png 48w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/25-155x125.png 155w\" sizes=\"auto, (max-width: 374px) 100vw, 374px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Filling the subject name<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>After enrollment, the certificate will be present in the Personal store and available to Kekeo and Rubeus to perform PKINIT with the identity of the target user (here <code>administrator@lab.local<\/code>):<\/p>\n<pre class=\"w-code\">Kekeo # tgt::ask \/subject:ItDoesNotMatter<\/pre>\n<figure id=\"post-16042 media-16042\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16042 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/26.png\" alt=\"\" width=\"361\" height=\"221\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/26.png 467w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/26-312x191.png 312w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/26-64x39.png 64w\" sizes=\"auto, (max-width: 361px) 100vw, 361px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Authentication certificate retrieved<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Subsequent sections present cases in which it is possible to exploit <strong>additional misconfigurations<\/strong> in Active Directory or on the ADCS servers to <strong>fall back to the situation and the exploit described above<\/strong>.<\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-3-2\"><\/a>The insidious case of EDITF_ATTRIBUTESUBJECTALTNAME2<\/h2>\n<p>One of the most dangerous and misunderstood of the CA servers\u2019 local settings is <code>EDITF_ATTRIBUTESUBJECTALTNAME2<\/code>. It was initially proposed as a way to allow for Subject Alternative Name (SAN) selection when using the <code>certreq<\/code> binary on command-line, and can locally be checked with:<\/p>\n<pre class=\"w-code\">C:\\Users\\Administrator&gt;certutil -getreg policy\\editflags\n\nHKEY_LOCAL_MACHINE\\SYSTEM\\CurrentControlSet\\Services\\CertSvc\\Configuration\\LAB ROOT CA\\PolicyModules\\CertificateAuthority_MicrosoftDefault.Policy\\EditFlags:\n\n  EditFlags REG_DWORD = 15014e (1376590)\n    EDITF_REQUESTEXTENSIONLIST -- 2\n    EDITF_DISABLEEXTENSIONLIST -- 4\n    EDITF_ADDOLDKEYUSAGE -- 8\n    EDITF_BASICCONSTRAINTSCRITICAL -- 40 (64)\n    EDITF_ENABLEAKIKEYID -- 100 (256)\n    EDITF_ENABLEDEFAULTSMIME -- 10000 (65536)\n<span class=\"w-grepped\">    EDITF_ATTRIBUTESUBJECTALTNAME2<\/span> -- 40000 (262144)\n    EDITF_ENABLECHASECLIENTDC -- 100000 (1048576)\nCertUtil: -getreg command completed successfully.<\/pre>\n<p>This setting <strong>forces the CA to accept a user-selected SAN <\/strong>for every certificate template listed by this enrollment service. This means that even if the \u201cBuild for this Active Directory information\u201d option is selected in the template options, the final SAN to be included in the certificate will be at the hand of the requester. <strong>This setting is fortunately disabled by default<\/strong>.<\/p>\n<p>In this case, every authentication certificate template will be vulnerable to the previous exploit. In order to exploit it, create the following policy.inf file:<\/p>\n<pre class=\"w-code\">[Version]\nSignature=\"$Windows NT$\"\n \n[NewRequest]\nSubject = \"CN=TEST\"  ; will not be taken into account\nExportable = FALSE\nKeyLength = 2048\nKeySpec = 1\nKeyUsage = 0xA0\nMachineKeySet = FALSE ; TRUE if you want it in the machine store\nProviderName = \"Microsoft RSA SChannel Cryptographic Provider\"\nRequestType = PKCS10\n \n[Extensions]\n2.5.29.17 = \"{text}\"\n_continue_ = \"upn=<span class=\"w-user\">username@domain.tld<\/span>\"\n \n \n[RequestAttributes]\n; If your client operating system is Windows Server 2003, Windows Server 2003 R2, or Windows XP\n; and you are using a standalone CA, SANs can be included in the RequestAttributes\n; section by using the following text format.\n \nSAN=\"upn=<span class=\"w-user\">username@domain.tld<\/span>\"\nCertificateTemplate = <span class=\"w-user\">YourTemplateName<\/span><\/pre>\n<p>Then, the certreq binary is again used to build the request and submit it to the CA server, and finally to add the certificate to the store:<\/p>\n<pre class=\"w-code\">C:\\&gt; certreq -new policy.inf request.pem\nC:\\&gt; certreq -submit request.pem cert.pem\nC:\\&gt; certreq -accept cert.pem<\/pre>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-3-3\"><\/a>Local administrator rights on ADCS server<\/h2>\n<p>There are multiple ways that domain and local users that are in the local Administrators group of CA servers can compromise the domain.<\/p>\n<p>First, local administrators have <strong>full access to the registry<\/strong>, and therefore they can <strong>modify the CA policy<\/strong> <strong>settings<\/strong> to include the <code>EDITF_ATTRIBUTESUBJECTALTNAME2<\/code> attribute mentioned in the previous section. It will allow the exploitation of any authentication certificate template that is listed by the server, which usually is enough to craft a certificate viable for a PKINIT on a privileged user.<\/p>\n<p>Secondly, local administrators are granted access to the machine certificate store, in which the CA private key is located. From there, there are multiple options to issue an authentication certificate, including:<\/p>\n<ul>\n<li>Use the <code>certutil -sign<\/code> command to <strong>re-sign an authentication certificate<\/strong> issued by the same CA, and modify on-the-fly its subject alternative name list<\/li>\n<li><strong>Export the certificate and its private key<\/strong>, if exportable or by patching the private key file \u201cexportability blob\u201d<\/li>\n<li>Use Mimikatz to patch the CryptoAPI \/ CNG and <strong>export the certificate along with its private key<\/strong><\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-3-4\"><\/a>ACL exploit on user objects (1)<\/h2>\n<p>If one has some control on a domain user object, there are several ways that this object may be compromised. For example, <strong>its password can be changed<\/strong> (requires <code>AllExtendedRights<\/code> or <code>ForceChangePassword<\/code>), granting access to the account (watch out for side effects!).<\/p>\n<p>A more silent way would be to <strong>modify the logon script<\/strong> by setting the <code>Scriptpath<\/code> attribute which only requires <code>GenericWrite<\/code> or specific <code>Write<\/code> to the attribute. It will execute any executable or script withing the context of the target\u2019s session when it performs a logon.<\/p>\n<p>There is another way of taking control over a user account (which is also fairly silent) by messing with the <code>altSecurityIdentities<\/code> attribute. As detailed in the PKINIT diagram, <strong>an explicit mapping can be created between a user object and a certificate<\/strong>, which then can be used to authenticate as the user.<\/p>\n<p>Using the Microsoft Management Console (MMC), it can be performed through the \u201cActive Directory Users &amp; Computers\u201d component:<\/p>\n<figure id=\"post-16044 media-16044\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16044 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/27.png\" alt=\"\" width=\"250\" height=\"59\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/27.png 402w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/27-71x17.png 71w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Adding the MMC component<\/em><\/p>\n<p><em>&nbsp;<\/em><\/p>\n<p>After enabling the \u201cAdvanced Features\u201d in the \u201cView\u201d menu, it is possible to configure mappings through the \u201cName Mappings\u201d option:<\/p>\n<figure id=\"post-16046 media-16046\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16046 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/28.png\" alt=\"\" width=\"500\" height=\"93\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/28.png 715w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/28-437x81.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/28-71x13.png 71w\" sizes=\"auto, (max-width: 500px) 100vw, 500px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Select the name mappings<\/em><\/p>\n<p><em>&nbsp;<\/em><\/p>\n<p>Then, just select the certificate that will be used to create the explicit mapping. Note that <strong>implicit mappings take precedence over explicit ones<\/strong>, so the certificate <strong>must not include an UPN<\/strong>, but it still needs to <strong>feature the correct Extended Key Usage<\/strong>:<\/p>\n<figure id=\"post-16048 media-16048\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16048 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/29.png\" alt=\"\" width=\"364\" height=\"241\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/29.png 528w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/29-288x191.png 288w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/29-59x39.png 59w\" sizes=\"auto, (max-width: 364px) 100vw, 364px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Creating the explicit mapping<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Under the hood, the GUI modifies the <code>altSecurityIdentities<\/code> attribute of the user in the following way:<\/p>\n<figure id=\"post-16050 media-16050\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16050 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/30.png\" alt=\"\" width=\"709\" height=\"155\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/30.png 1302w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/30-437x96.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/30-71x16.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/30-768x168.png 768w\" sizes=\"auto, (max-width: 709px) 100vw, 709px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Modification of the altSecurityIdentities attribute<\/em><\/p>\n<p><em>&nbsp;<\/em><\/p>\n<p>The new value of the attribute is a <strong>collection of strings<\/strong>, so it may be modified rather easily with the <code>Set-AdUser<\/code> cmdlet or another AD editing tool such as <code>adsiedit.msc<\/code> or AD Explorer.<\/p>\n<p>Finally, the authentication can take place, using your favorite tool (Kekeo, Rubeus, etc.):<\/p>\n<figure id=\"post-16052 media-16052\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16052 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/31.png\" alt=\"\" width=\"647\" height=\"151\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/31.png 922w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/31-437x102.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/31-71x17.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/31-768x179.png 768w\" sizes=\"auto, (max-width: 647px) 100vw, 647px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Authenticating as Admin1 with explicit mapping from Administrator\u2019s certificate<\/em><\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-3-5\"><\/a>ACL exploit on user objects (2)<\/h2>\n<p>There exists another way of leveraging write access to user objects on the domain, however being <strong>much noisier<\/strong> and with a <strong>higher risk of breaking things<\/strong>.<\/p>\n<p>If one already has an authentication certificate which includes the UPN of a low-privileged user, it will basically consist in modifying the <code>userPrincipalName<\/code> attribute of the target account to the value of that UPN. Such situations may arise when access to the enterprise Wi-Fi network is configured to be performed with a certificate, and with \u201cuser authentication\u201d rather than \u201ccomputer authentication\u201d. In our case, we have a certificate with a UPN for <code>User1<\/code>:<\/p>\n<figure id=\"post-16054 media-16054\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16054 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/32.png\" alt=\"\" width=\"334\" height=\"274\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/32.png 506w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/32-233x191.png 233w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/32-48x39.png 48w\" sizes=\"auto, (max-width: 334px) 100vw, 334px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>User1 authentication certificate<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>Using the write access on the <code>Admin1<\/code> user account, we modify its UPN to the one of <code>User1<\/code>:<\/p>\n<figure id=\"post-16056 media-16056\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16056 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/33.png\" alt=\"\" width=\"558\" height=\"152\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/33.png 994w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/33-437x119.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/33-71x19.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/33-768x209.png 768w\" sizes=\"auto, (max-width: 558px) 100vw, 558px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Modification of Admin1 UPN<\/em><\/p>\n<p><em>&nbsp;<\/em><\/p>\n<p>Finally, using our authentication certificate, it is now possible to perform a PKINIT pre-authentication for both user accounts, using either implicit or explicit mappings:<\/p>\n<figure id=\"post-16058 media-16058\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16058 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/34.png\" alt=\"\" width=\"595\" height=\"256\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/34.png 1000w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/34-437x188.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/34-71x31.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/34-768x331.png 768w\" sizes=\"auto, (max-width: 595px) 100vw, 595px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Authentication as both User1 and Admin1 with User1\u2019s certificate<\/em><\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-3-6\"><\/a>ACL exploit on certificate templates<\/h2>\n<p>If one of the already compromised assets in the domain has <strong>write access on a certificate template <\/strong>that is <strong>listed in one of the usable enrollment services, <\/strong>then the following modifications will allow the issuance of <strong>PKINIT-compliant authentication certificates<\/strong>:<\/p>\n<ul>\n<li>Set the <code>msPKI-Enrollment-Flag<\/code> attribute to <code>0<\/code>: it will remove the need for additional approval set by the flag <code>CT_FLAG_PEND_ALL_REQUESTS<\/code><\/li>\n<li>Set the <code>msPKI-Certificate-Name-Flag<\/code> attribute to <code>1<\/code>: it will build the subject name based on the information provided by the requester<\/li>\n<li>Add the one of the required OIDs (for example <code>3.6.1.5.5.7.3.2<\/code>) to the <code>msPKI-Certificate-Application-Policy<\/code> set to include the Client Authentication extended key usage<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>Such modifications can be performed through <code>adsiedit.msc<\/code> or via the <code>Set-ADObject<\/code> cmdlet from the ADDS Remote Server Administration Tools (RSAT) or with PowerView:<\/p>\n<pre class=\"w-code\">$newAttr = @{}\n$newAttr['msPKI-Enrollment-Flag'] = '0'\n$newAttr['msPKI-Certificate-Name-Flag'] = '1'\n$newAttr['msPKI-Certificate-Application-Policy'] = @('1.3.6.1.5.5.7.3.2')\n\n<span class=\"w-cli\"># Set new attributes<\/span>\nSet-AdObject \"CN=<span class=\"w-root\">TemplateName<\/span>,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,<span class=\"w-root\">DC=LAB,DC=LOCAL<\/span>\" -Replace $newParams<\/pre>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-3-7\"><\/a>ACL exploit on enrollment services<\/h2>\n<p>Similarly, write access on enrollment services objects can help the issuance of PKINIT-compliant authentication certificates. The attribute to be targeted is <code>certificateTemplates<\/code> since <strong>it allows the addition (or deletion) of listed certificate templates<\/strong>.<\/p>\n<p><strong>By default<\/strong>, there is <strong>only one certificate template with the correct PKINIT prerequisites<\/strong> in Active Directory, which is \u201cRouter (Offline request)\u201d, but only Domain Admins can enroll a certificate with it.<\/p>\n<p>However, the longer a PKI infrastructure lives, the higher the chance to find remnants of tests that will most likely be exploitable. As in the previous section, you can use <code>adsiedit.msc<\/code> or PowerShell to add a new template:<\/p>\n<pre class=\"w-code\">$object = \"CN=<span class=\"w-user\">LAB ROOT CA<\/span>,CN=Enrollment Services,CN=Public Key Services,CN=Services,CN=Configuration,<span class=\"w-user\">DC=LAB,DC=LOCAL<\/span>\"\n\n\n$templates = (Get-AdObject $object -Properties *).CertificateTemplates\n$templates.Add(\"<span class=\"w-user\">OfflineRouter<\/span>\")\n\nSet-AdObject $object -Replace @{'certificateTemplates'=[System.Array]$templates}\n<\/pre>\n<h1><\/h1>\n<h1><a name=\"section-4\"><\/a>Current mitigations<\/h1>\n<h2><a name=\"section-4-1\"><\/a>Integration within the Active Directory tiering model<\/h2>\n<h3><a name=\"section-4-1-1\"><\/a>ESAE: Enhanced Security admin Environment<\/h3>\n<p>In Active Directory, it is recommended to partition the administrator privileges according to the type of devices they need to interact with. The theory behind this partitioning of Active Directory is called the tiering model and is described by Microsoft in the <span style=\"color: #005572;\"><strong>Enhanced Security Admin Environment<\/strong><\/span> (ESAE). Though the ESAE model is now <a href=\"https:\/\/docs.microsoft.com\/en-us\/security\/compass\/esae-retirement\">retired<\/a> and replaced by the <a href=\"https:\/\/docs.microsoft.com\/en-us\/security\/compass\/security-rapid-modernization-plan\">Rapid Modernization Plan<\/a> (RaMP) to tackle the cloud aspects of hybrid information systems, most of its conclusions still apply regarding on-premise assets.<\/p>\n<p>&nbsp;<\/p>\n<h4>Tier-0<\/h4>\n<p>The idea behind the tiering model is built on isolation between assets in the information system. The most critical assets are in the Tier-0 and defined as:<\/p>\n<ul>\n<li>Any <strong>AD object<\/strong> that <strong>allows the compromise of the domain<\/strong>, therefore including the Domain\/Enterprise Admins and (Enterprise) Domain Controllers groups<\/li>\n<li>Any <strong>AD object<\/strong> that <strong>allows taking over another object in the Tier-0<\/strong>, including, but not limited to: the krbtgt user, the OUs in which Tier-0 objects reside, the GPOs that apply to them, etc.<\/li>\n<li>Any <strong>asset in the Information System<\/strong> that can be used to <strong>compromise the Tier-0 or its objects<\/strong>: antivirus and EDR console, standalone WSUS servers, backup infrastructure, etc.<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>The Tier-0 is consequently defined as the <span style=\"color: #005572;\"><strong>set of assets that have control paths over each other but no other control paths from anywhere else<\/strong><\/span>: it is a closed loop in the compromise graph, that also includes non-domain-joint assets.<\/p>\n<p>&nbsp;<\/p>\n<h4>Tier-1 and 2<\/h4>\n<p>All the assets that are not present in Tier-0 are distributed in <strong>two other tiers<\/strong>. These tiers are built according to the type of objects they contain:<\/p>\n<ul>\n<li><span style=\"color: #005572;\"><strong>Tier-2<\/strong><\/span> contains everything closely <strong>related to standard users<\/strong>: their accounts, their workstation, but also TSE servers, the administrative layer that controls these assets, etc.<\/li>\n<li><span style=\"color: #005572;\"><strong>Tier-1<\/strong><\/span> is dedicated to hosting assets <strong>in relation with the applications<\/strong>: servers that host them, service accounts, administrative workstations (excluding Tier-0)<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h4>Tier permeability<\/h4>\n<p><span style=\"color: #005572;\"><strong>The risk of intra-tier compromise is part of the tiering model\u2019s design<\/strong><\/span> (even if some Active Directory mechanisms \u2013 such as the Protected Users domain group or LAPS \u2013 will limit it). However, the tiering model aims at protecting the most critical assets by strictly defining <span style=\"color: #005572;\"><strong>which inter-tier connection are allowed<\/strong><\/span>. The set of connections and their status is roughly detailed below:<\/p>\n<figure id=\"post-16124 media-16124\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16124 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/60.png\" alt=\"\" width=\"494\" height=\"426\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/60.png 1005w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/60-221x191.png 221w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/60-45x39.png 45w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/60-768x663.png 768w\" sizes=\"auto, (max-width: 494px) 100vw, 494px\" \/><\/figure>\n<p>In the previous diagram, the red arrows represent the <strong>impossibility for an administrator of a higher level of administration to open a session to a resource of a lower level<\/strong>. In addition, the yellow arrows indicate the need to limit inter-tier connection to user connections only (e.g. a domain user querying the LDAP service on a DC from his workstation).<\/p>\n<p>The <strong>dedicated administrative accounts<\/strong> are to be created <strong>in each tier<\/strong>, and their <strong>session opening must be restricted to that tier <\/strong>to prevent escalation between tiers. Since the source device of a network connection is also susceptible to credential theft (keylogging, malware spying on memory, etc.), it is preferable that the administrative accounts in each tier are used from an administrative workstation only. This behavior <strong>needs to be enforced in the Tier-0<\/strong>, with the use of<span style=\"color: #005572;\"><strong> Privileged Access Workstations<\/strong><\/span> (PAW).<\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"section-4-1-2\"><\/a>Moving ADCS objects up one tier!<\/h3>\n<p>All the examples of privilege escalation provided in the \u201cElevating privileges with ADCS\u201d section consequently point towards the fact that <span style=\"color: #005572;\"><strong>the<\/strong> <strong>following AD objects need to be included in the Tier-0<\/strong><\/span>:<\/p>\n<ul>\n<li>The servers on which the ADCS role is installed<\/li>\n<li>The certificate templates that are published to a public accessible enrollment service<\/li>\n<li>The enrollment services if there are already certificate templates susceptible to exploitation<\/li>\n<\/ul>\n<p>To facilitate the handling of these objects over time, it is recommended to<span style=\"color: #005572;\"><strong> include every certificate template and every enrollment service in the Tier-0<\/strong><\/span>. This means that there must be no control path over the three object types listed above from somewhere outside of the Tier-0:<\/p>\n<ul>\n<li>The owner and control ACL over the objects must be positioned on Tier-0 principals only<\/li>\n<li>The local administrator group of the ADCS servers must be restricted to Tier-0 principals only<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-4-2\"><\/a>Proper handling of corner cases<\/h2>\n<h3><a name=\"section-4-2-1\"><\/a>Context example<\/h3>\n<p>Even after the application of all of the recommendations listed above (when possible), there are still legitimate use cases of authentication certificates that needs to be issued to a third party. For example, when one wants to deploy Network Access Control (<strong>802.1x<\/strong>) with certificate-based authentication, there are four types of devices to consider:<\/p>\n<ol>\n<li>The domain-joint devices, which will be able to use the enroll \/ auto-enroll features<\/li>\n<li>The devices supporting the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Simple_Certificate_Enrollment_Protocol\">Simple Certification Enrollment Protocol<\/a> (SCEP), which will be able to replicate the enroll \/ auto-enroll features<\/li>\n<li>The devices supporting certificates with no support for any enroll \/ auto-enroll feature whatsoever (e.g. printers)<\/li>\n<li>The devices that don\u2019t support certificates<\/li>\n<\/ol>\n<p>&nbsp;<\/p>\n<p>In the third case, network administrators would need to issue authentication certificates compliant with the <code>NT_AUTH<\/code> policy and including the Fully Qualified Domain Name (FQDN) of the device in the Subject Alternative Names (SAN) section. Since these devices are not domain principals and cannot enroll certificates with the ADCS server, the administrators are required to request certificates on behalf of the devices and to specify the name of the subject in the request.<\/p>\n<p>This situation is <strong>the exact context in which the administrators would also be able to issue an authentication certificate<\/strong> including the UPN of a domain administrator in the SAN section, therefore being able to perform PKINIT and authenticate as the domain administrator.<\/p>\n<p>&nbsp;<\/p>\n<h3><a name=\"section-4-2-2\"><\/a>Setting the manager approval<\/h3>\n<p>To protect against the malicious use, the certificate templates objects include an option to require the approval of a CA certificate manager:<\/p>\n<figure id=\"post-16116 media-16116\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16116 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/51.png\" alt=\"\" width=\"332\" height=\"122\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/51.png 400w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/51-71x26.png 71w\" sizes=\"auto, (max-width: 332px) 100vw, 332px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>CA certificate manager approval<\/em><\/p>\n<p>&nbsp;<\/p>\n<p>When the request for a new certificate is issued, it will appear in the \u201cPending Requests\u201d section of the ADCS instance, using the <code>certsrv.msc<\/code> MMC component:<\/p>\n<figure id=\"post-16118 media-16118\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16118 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/52.png\" alt=\"\" width=\"598\" height=\"216\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/52.png 797w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/52-437x158.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/52-71x26.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/52-768x278.png 768w\" sizes=\"auto, (max-width: 598px) 100vw, 598px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Pending certificate request<\/em><\/p>\n<p><em>&nbsp;<\/em><\/p>\n<p>The certificate can later be retrieved by the requester with the following commands:<\/p>\n<pre class=\"w-code\">C:\\&gt; certreq -retrieve &lt;ID_REQUEST&gt; file.cer\nC:\\&gt; certreq -accept file.cer<\/pre>\n<p>&nbsp;<\/p>\n<h3><a name=\"section-4-2-3\"><\/a>Choosing your CA managers<\/h3>\n<p>There are multiple strategies to select who should be able to validate the pending requests, at the ADCS server level:<\/p>\n<ul>\n<li>Since the issuance of a malicious certificate allows the compromise of a Tier 0 principal, the ideal solution would be to <span style=\"color: #005572;\"><strong>only allow Tier 0 principals on this role<\/strong><\/span>; however, this may complexify the issuance process at a large scale<\/li>\n<li>The alternative is to <span style=\"color: #005572;\"><strong>enable Tier 1 administrators to perform this action<\/strong><\/span>: in this case, the groups allowed to request the certificate need to be <strong>completely disjoint<\/strong> from the groups allowed to approve the requests. Note that even in this situation, control over accounts from both groups is sufficient to take over Tier 0 principals<\/li>\n<\/ul>\n<figure id=\"post-16134 media-16134\" class=\"align-none\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-16134 aligncenter\" src=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/61.png\" alt=\"\" width=\"665\" height=\"153\" srcset=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/61.png 1322w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/61-437x101.png 437w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/61-71x16.png 71w, https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/06\/61-768x177.png 768w\" sizes=\"auto, (max-width: 665px) 100vw, 665px\" \/><\/figure>\n<p style=\"text-align: center;\"><em>Alternative to Tier-0 validators only<\/em><\/p>\n<p>&nbsp;<\/p>\n<h2><a name=\"section-4-3\"><\/a>Adding the detection layer<\/h2>\n<p>The extensive guide about adding an ADCS logging facility would not fit in this article. However, there are some useful resources about how to enable logging and what to log:<\/p>\n<ul>\n<li><a href=\"https:\/\/cyberstoph.org\/posts\/2019\/12\/an-introduction-to-golden-certificates\/\">An introduction to Golden Certificates<\/a> (by C. Falta): the \u201cDefending against Golden Certificate\u201d gives very interesting insight on how to <span style=\"color: #005572;\"><strong>monitor the certificate template changes<\/strong><\/span>, which would certainly help in detecting some ACL exploits<\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/previous-versions\/windows\/it-pro\/windows-server-2012-r2-and-2012\/hh801901(v=ws.11)\">Securing PKI: Monitoring Public Key Infrastructure<\/a> (by Microsoft): this article is the <span style=\"color: #005572;\"><strong>reference regarding the configuration of ADCS logging <\/strong><\/span>and provides information on what event IDs are raised when specific events occur<\/li>\n<\/ul>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: right;\">Special thanks to <a href=\"https:\/\/twitter.com\/remiescourrou?lang=fr\">@R\u00e9miEscourrou<\/a>, <a href=\"https:\/\/twitter.com\/cnotin?lang=fr\">@Cl\u00e9mentNotin<\/a> and <a href=\"https:\/\/twitter.com\/hackanddo?lang=fr\">@Pixis<\/a> for their help on this subject,<br \/>\nand stay tuned for <a href=\"https:\/\/twitter.com\/harmj0y\">@harmj0y<\/a>&#8216;s <a href=\"https:\/\/www.blackhat.com\/us-21\/briefings\/schedule\/#certified-pre-owned-abusing-active-directory-certificate-services-23168\">presentation at Black Hat US<\/a> on this topic!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Due to the ever-growing use of certificates in modern applications, a large number of Active Directory infrastructures make use of Public Key Infrastructures (PKI) features. These features are provided by Certification Authorities (CA) which are either external to Active Directory&#8230;<\/p>\n","protected":false},"author":1421,"featured_media":15548,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"page-templates\/tmpl-one.php","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[3922,3273],"tags":[3918,3921,3920],"coauthors":[3475],"class_list":["post-15940","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-deep-dive-en","category-ethical-hacking-indicent-response-en","tag-activedirectory","tag-pentest-en","tag-pki-en"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Microsoft ADCS \u2013 Abusing PKI in Active Directory Environment - RiskInsight<\/title>\n<meta name=\"description\" content=\"Active Directory Certificate Services (ADCS) have never really been under security scrutiny until a few years ago (by C. Falta and later Q&amp;D Security). We will therefore focus today on how similar techniques can be used to gain Domain Admins privileges.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Microsoft ADCS \u2013 Abusing PKI in Active Directory Environment - RiskInsight\" \/>\n<meta property=\"og:description\" content=\"Active Directory Certificate Services (ADCS) have never really been under security scrutiny until a few years ago (by C. Falta and later Q&amp;D Security). We will therefore focus today on how similar techniques can be used to gain Domain Admins privileges.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/\" \/>\n<meta property=\"og:site_name\" content=\"RiskInsight\" \/>\n<meta property=\"article:published_time\" content=\"2021-06-14T09:20:24+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-14T10:51:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2020\/01\/Fotolia_78673393_Subscription_Monthly_M.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1378\" \/>\n\t<meta property=\"og:image:height\" content=\"1378\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Jean Marsault\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Jean Marsault\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"35 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/\"},\"author\":{\"name\":\"Jean Marsault\",\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/#\/schema\/person\/b91c655837841792e8ad612de7c9cced\"},\"headline\":\"Microsoft ADCS \u2013 Abusing PKI in Active Directory Environment\",\"datePublished\":\"2021-06-14T09:20:24+00:00\",\"dateModified\":\"2021-09-14T10:51:05+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/\"},\"wordCount\":5916,\"publisher\":{\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2020\/01\/Fotolia_78673393_Subscription_Monthly_M.jpg\",\"keywords\":[\"ActiveDirectory\",\"pentest\",\"PKI\"],\"articleSection\":[\"Deep-dive\",\"Ethical Hacking &amp; Incident Response\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/\",\"url\":\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/\",\"name\":\"Microsoft ADCS \u2013 Abusing PKI in Active Directory Environment - RiskInsight\",\"isPartOf\":{\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2020\/01\/Fotolia_78673393_Subscription_Monthly_M.jpg\",\"datePublished\":\"2021-06-14T09:20:24+00:00\",\"dateModified\":\"2021-09-14T10:51:05+00:00\",\"description\":\"Active Directory Certificate Services (ADCS) have never really been under security scrutiny until a few years ago (by C. Falta and later Q&D Security). We will therefore focus today on how similar techniques can be used to gain Domain Admins privileges.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#primaryimage\",\"url\":\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2020\/01\/Fotolia_78673393_Subscription_Monthly_M.jpg\",\"contentUrl\":\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2020\/01\/Fotolia_78673393_Subscription_Monthly_M.jpg\",\"width\":1378,\"height\":1378,\"caption\":\"computer infection design, vector illustration eps10 graphic\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.riskinsight-wavestone.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Microsoft ADCS \u2013 Abusing PKI in Active Directory Environment\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/#website\",\"url\":\"https:\/\/www.riskinsight-wavestone.com\/en\/\",\"name\":\"RiskInsight\",\"description\":\"The cybersecurity &amp; digital trust blog by Wavestone&#039;s consultants\",\"publisher\":{\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.riskinsight-wavestone.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/#organization\",\"name\":\"Wavestone\",\"url\":\"https:\/\/www.riskinsight-wavestone.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/08\/Monogramme\u2013W\u2013NEGA-RGB-50x50-1.png\",\"contentUrl\":\"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/08\/Monogramme\u2013W\u2013NEGA-RGB-50x50-1.png\",\"width\":50,\"height\":50,\"caption\":\"Wavestone\"},\"image\":{\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.riskinsight-wavestone.com\/en\/#\/schema\/person\/b91c655837841792e8ad612de7c9cced\",\"name\":\"Jean Marsault\",\"sameAs\":[\"https:\/\/x.com\/iansus\"],\"url\":\"https:\/\/www.riskinsight-wavestone.com\/en\/author\/jean-marsault\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Microsoft ADCS \u2013 Abusing PKI in Active Directory Environment - RiskInsight","description":"Active Directory Certificate Services (ADCS) have never really been under security scrutiny until a few years ago (by C. Falta and later Q&D Security). We will therefore focus today on how similar techniques can be used to gain Domain Admins privileges.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/","og_locale":"en_US","og_type":"article","og_title":"Microsoft ADCS \u2013 Abusing PKI in Active Directory Environment - RiskInsight","og_description":"Active Directory Certificate Services (ADCS) have never really been under security scrutiny until a few years ago (by C. Falta and later Q&D Security). We will therefore focus today on how similar techniques can be used to gain Domain Admins privileges.","og_url":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/","og_site_name":"RiskInsight","article_published_time":"2021-06-14T09:20:24+00:00","article_modified_time":"2021-09-14T10:51:05+00:00","og_image":[{"width":1378,"height":1378,"url":"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2020\/01\/Fotolia_78673393_Subscription_Monthly_M.jpg","type":"image\/jpeg"}],"author":"Jean Marsault","twitter_misc":{"Written by":"Jean Marsault","Est. reading time":"35 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#article","isPartOf":{"@id":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/"},"author":{"name":"Jean Marsault","@id":"https:\/\/www.riskinsight-wavestone.com\/en\/#\/schema\/person\/b91c655837841792e8ad612de7c9cced"},"headline":"Microsoft ADCS \u2013 Abusing PKI in Active Directory Environment","datePublished":"2021-06-14T09:20:24+00:00","dateModified":"2021-09-14T10:51:05+00:00","mainEntityOfPage":{"@id":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/"},"wordCount":5916,"publisher":{"@id":"https:\/\/www.riskinsight-wavestone.com\/en\/#organization"},"image":{"@id":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#primaryimage"},"thumbnailUrl":"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2020\/01\/Fotolia_78673393_Subscription_Monthly_M.jpg","keywords":["ActiveDirectory","pentest","PKI"],"articleSection":["Deep-dive","Ethical Hacking &amp; Incident Response"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/","url":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/","name":"Microsoft ADCS \u2013 Abusing PKI in Active Directory Environment - RiskInsight","isPartOf":{"@id":"https:\/\/www.riskinsight-wavestone.com\/en\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#primaryimage"},"image":{"@id":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#primaryimage"},"thumbnailUrl":"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2020\/01\/Fotolia_78673393_Subscription_Monthly_M.jpg","datePublished":"2021-06-14T09:20:24+00:00","dateModified":"2021-09-14T10:51:05+00:00","description":"Active Directory Certificate Services (ADCS) have never really been under security scrutiny until a few years ago (by C. Falta and later Q&D Security). We will therefore focus today on how similar techniques can be used to gain Domain Admins privileges.","breadcrumb":{"@id":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#primaryimage","url":"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2020\/01\/Fotolia_78673393_Subscription_Monthly_M.jpg","contentUrl":"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2020\/01\/Fotolia_78673393_Subscription_Monthly_M.jpg","width":1378,"height":1378,"caption":"computer infection design, vector illustration eps10 graphic"},{"@type":"BreadcrumbList","@id":"https:\/\/www.riskinsight-wavestone.com\/en\/2021\/06\/microsoft-adcs-abusing-pki-in-active-directory-environment\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.riskinsight-wavestone.com\/en\/"},{"@type":"ListItem","position":2,"name":"Microsoft ADCS \u2013 Abusing PKI in Active Directory Environment"}]},{"@type":"WebSite","@id":"https:\/\/www.riskinsight-wavestone.com\/en\/#website","url":"https:\/\/www.riskinsight-wavestone.com\/en\/","name":"RiskInsight","description":"The cybersecurity &amp; digital trust blog by Wavestone&#039;s consultants","publisher":{"@id":"https:\/\/www.riskinsight-wavestone.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.riskinsight-wavestone.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.riskinsight-wavestone.com\/en\/#organization","name":"Wavestone","url":"https:\/\/www.riskinsight-wavestone.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.riskinsight-wavestone.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/08\/Monogramme\u2013W\u2013NEGA-RGB-50x50-1.png","contentUrl":"https:\/\/www.riskinsight-wavestone.com\/wp-content\/uploads\/2021\/08\/Monogramme\u2013W\u2013NEGA-RGB-50x50-1.png","width":50,"height":50,"caption":"Wavestone"},"image":{"@id":"https:\/\/www.riskinsight-wavestone.com\/en\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.riskinsight-wavestone.com\/en\/#\/schema\/person\/b91c655837841792e8ad612de7c9cced","name":"Jean Marsault","sameAs":["https:\/\/x.com\/iansus"],"url":"https:\/\/www.riskinsight-wavestone.com\/en\/author\/jean-marsault\/"}]}},"_links":{"self":[{"href":"https:\/\/www.riskinsight-wavestone.com\/en\/wp-json\/wp\/v2\/posts\/15940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.riskinsight-wavestone.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.riskinsight-wavestone.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.riskinsight-wavestone.com\/en\/wp-json\/wp\/v2\/users\/1421"}],"replies":[{"embeddable":true,"href":"https:\/\/www.riskinsight-wavestone.com\/en\/wp-json\/wp\/v2\/comments?post=15940"}],"version-history":[{"count":99,"href":"https:\/\/www.riskinsight-wavestone.com\/en\/wp-json\/wp\/v2\/posts\/15940\/revisions"}],"predecessor-version":[{"id":16787,"href":"https:\/\/www.riskinsight-wavestone.com\/en\/wp-json\/wp\/v2\/posts\/15940\/revisions\/16787"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.riskinsight-wavestone.com\/en\/wp-json\/wp\/v2\/media\/15548"}],"wp:attachment":[{"href":"https:\/\/www.riskinsight-wavestone.com\/en\/wp-json\/wp\/v2\/media?parent=15940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.riskinsight-wavestone.com\/en\/wp-json\/wp\/v2\/categories?post=15940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.riskinsight-wavestone.com\/en\/wp-json\/wp\/v2\/tags?post=15940"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.riskinsight-wavestone.com\/en\/wp-json\/wp\/v2\/coauthors?post=15940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}