← Back to the cybersecurity blog

How to audit AD CS: ESC templates, strong certificate mapping and detecting rogue issuance

By Thilina Manana · COO, Director Técnico de Seguridad hard2bit y socio fundador · Published: 24 November 2026 · Updated: 24 November 2026
How to audit AD CS AI-generated image

Microsoft's July 2026 security update fixed CVE-2026-54121, a flaw its discoverers named Certighost. According to Microsoft's analysis published on 31 July, a domain account with no administrative privileges could get an enterprise certification authority to issue certificates for domain computer accounts, domain controllers included. The vulnerable path requires a CA with the EDITF_ENABLECHASECLIENTDC flag set and a template that requires a DNS name. A public proof of concept appeared ten days later. Microsoft had not observed confirmed exploitation at the time and, as of 20 November 2026, the flaw was not in CISA's KEV catalogue.

Certighost is serious, but it is an outlier. In the Active Directory assessments we run, privilege escalation through Active Directory Certificate Services (AD CS) almost never needs a CVE. It comes from certificate templates set up years ago, whose options were carried from one server migration to the next without a second look. Offensive tooling already covers that ground: Certipy's documentation describes ESC1 through ESC17.

What follows is aimed at infrastructure teams and SOC analysts in mid-sized organisations running one or more Microsoft enterprise CAs joined to the domain. It walks through how AD CS turns a certificate into an identity, which settings open the most common ESC classes, which values to pin down and how to prove they are in place, and what telemetry is needed to catch anomalous issuance. Attribute names, event IDs and commands were checked against Microsoft documentation on 24 November 2026.

Why does an internal certification authority belong in Tier 0?

An enterprise CA published in Active Directory can issue certificates that domain controllers accept as proof of identity through PKINIT, the Kerberos extension for certificate logon. Anyone holding a valid certificate in a domain admin's name can obtain that admin's TGT without the password and without the second factor. A password reset does not touch it: the certificate works until it expires or is revoked.

So the CA, its templates and the accounts that manage them sit in Tier 0 of the administrative tiering model, next to the domain controllers. MITRE ATT&CK lists the technique as T1649, Steal or Forge Authentication Certificates. In practical terms it is a privilege escalation route that leaves little trace on the CA when it is not auditing. Our piece on detecting and containing hybrid Active Directory attacks covers the wider chain from Kerberoasting to Golden Ticket; this guide zooms in on the CA.

The guide requires the ActiveDirectory PowerShell module and a domain account for the read-only inventory queries, a local administrator account on each CA to read its configuration, and a SIEM ingesting the CAs' Security log plus the domain controllers' Security and System logs. The detection queries are written for Microsoft Sentinel; the logic can be adapted to other engines.

How AD CS turns a certificate into an identity

Three components are involved. The template, an AD object under the Certificate Templates container in the configuration partition, decides who may enrol, what the digital certificate may be used for (its EKUs) and where the subject name comes from. The CA checks each request against the template and signs. When the certificate is presented during PKINIT, the domain controller works out which account it belongs to.

Each component logs somewhere different. With auditing enabled, which takes two separate settings covered further down, the CA records events 4886 (request received) and 4887 (request approved and certificate issued) in its Security log. The domain controller records event 4768 with the certificate details of every TGT obtained through PKINIT, and writes Kdcsvc events to its System log when a certificate cannot be strongly mapped. Edits to a template object show up as event 5136, provided directory service change auditing and the SACL cover them.

Three settings that make a template dangerous

The first lets the requester supply the subject. The console calls it Supply in the request; on the object it is the CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT bit (0x00000001) of msPKI-Certificate-Name-Flag, as defined in the MS-CRTD specification. With that bit set, whoever asks for the certificate writes whatever subject alternative name (SAN) they like, including somebody else's UPN.

The second is a certificate that can authenticate: Client Authentication, Smart Card Logon, PKINIT Client Authentication, Any Purpose, or no EKU at all. The third is enrolment open to broad groups such as Domain Users or Authenticated Users, with neither manager approval (CT_FLAG_PEND_ALL_REQUESTS, 0x00000002 in msPKI-Enrollment-Flag) nor enrolment agent signatures (msPKI-RA-Signature).

When all three meet in a published template, any domain user with enrolment rights can request a certificate in an administrator's name. That combination is ESC1, and Microsoft Defender for Identity includes it, in preview, among its AD CS assessments.

What KB5014754 changed, and why ESC1 survived it

Since the May 2022 updates, the CA has stamped certificates with an extension holding the account's SID (szOID_NTDS_CA_SECURITY_EXT, OID 1.3.6.1.4.1.311.25.2), and the domain controller compares it with the account it maps the certificate to. KB5014754 gives the timeline: compatibility mode after May 2022, full enforcement by default from 11 February 2025, and the end of support for the StrongCertificateBindingEnforcement registry value with the 9 September 2025 update.

On a domain whose controllers are current, Kerberos refuses a certificate that has no SID extension and no explicit strong mapping in altSecurityIdentities, and logs Kdcsvc event 39. Microsoft counts X509IssuerSerialNumber (its recommendation), X509SKI and X509SHA1PublicKey as strong mappings, and X509IssuerSubject, X509SubjectOnly and X509RFC822 as weak. For Kerberos authentication, that leaves ESC9 and ESC16 with very little room.

Schannel, used by LDAPS among others, is governed separately by CertificateMappingMethods. Its current default (0x18) excludes UPN mapping; if someone has switched it back on, ESC9, ESC10 and ESC16 remain open through that route, so the value needs checking on its own.

ESC1 is largely unaffected. Under the MS-WCCE specification, when a template lets the requester supply the subject, the CA does not fill the SID extension from the directory; it takes it from the request. Microsoft also accepts a SID inside a SAN URI as a strong mapping. Either way, the requester controls the data. When a template lets the requester write the identity, the fix belongs in the template.

ESC classes: how to check them and how to close them

The ESC naming was published in 2021 with eight classes and now reaches seventeen, according to Certipy's documentation; Microsoft uses it in the Defender for Identity AD CS assessments. The table lists those we come across most often in our assessments, plus Certighost because it is recent, how to check each one without offensive tooling, and the control that shuts it.

Common ESC classes, how to check them and the main control
ClassWhat enables itHow to checkMain control
ESC1Template with requester-supplied subject, an authentication use and open enrolment without approvalThe inventory query in this guide and the Defender for Identity ESC1 assessmentTurn off requester-supplied subject or require manager approval; restrict enrolment
ESC2Template with the Any Purpose EKU or no EKU, open to enrolment by unprivileged usersEmpty pKIExtendedKeyUsage or 2.5.29.37.0; on v2 and later templates, also an empty msPKI-Certificate-Application-PolicySet explicit uses and limit who can enrol
ESC3Enrolment agent (Certificate Request Agent) template open to unprivileged usersTemplates with EKU 1.3.6.1.4.1.311.20.2.1 and their permissionsRestrict enrolment agents on the CA and on the template
ESC4Write permissions or ownership of a template held by broad groupsACL and owner of each template objectWrite access for PKI administrators only
ESC6EDITF_ATTRIBUTESUBJECTALTNAME2 flag set on the CAcertutil -getreg policy\EditFlagsRemove the flag and restart the service
ESC7ManageCA or ManageCertificates rights held by non-PKI accountsCA security in certsrv.mscCut back CA management rights
ESC8Web enrolment over HTTP, or NTLM without mandatory EPAIIS configuration of CertSrv and the CES web.configMandatory HTTPS and EPA set to Required (KB5005413)
ESC11RPC enrolment interface without enforced encryptioncertutil -getreg CA\InterfaceFlagsRe-enable IF_ENFORCEENCRYPTICERTREQUEST
ESC15Schema version 1 templates with requester-supplied subject that accepted arbitrary application policies (CVE-2024-49019)CA patch level and published v1 templatesNovember 2024 update; retire or duplicate unnecessary v1 templates
ESC16CA excluding the SID extension from every certificatecertutil -getreg policy\DisableExtensionListRemove 1.3.6.1.4.1.311.25.2 from the list
CertighostEnterprise CA without the July 2026 update (CVE-2026-54121)Patch level of each CAInstall the update on every enterprise CA

Sources: Microsoft Defender for Identity AD CS assessments, KB5005413, KB5014754, MS-WCCE, CVE-2024-49019, Microsoft's Certighost analysis and the Certipy documentation.

Which tool should run the inventory?

There are three sensible routes, none of them complete; the table shows what each one leaves out.

Options for auditing AD CS in a mid-sized organisation
OptionCostCoverageLimits
Defender for Identity security posture assessmentsIncluded in the MDI licenceESC1, ESC2, ESC3, ESC4, ESC6, ESC7, ESC8, ESC11 and ESC15ESC6, ESC7, ESC8, ESC11 and ESC15 need a sensor on the AD CS server; scores update every 24 hours
Locksmith (open source)Free, MIT licence with Commons ClauseESC1 to ESC9, ESC11, ESC13, ESC15 and ESC16, plus audit statusDoes not cover ESC10, ESC12 or ESC14. Modes 2 and 3 write CSV files; mode 4 offers to apply fixes and belongs in a maintenance window
In-house queries (LDAP and certutil)Team timeWhatever the team scripts; handy for keeping periodic evidenceDoes not replace reviewing template and CA ACLs, which is the most laborious part

MDI coverage per Microsoft Learn, checked on 24/11/2026; ESC1 and ESC6 in preview. Locksmith per its GitHub repository.

For a first pass we suggest running Locksmith in mode 0 (identify only) alongside the queries below, and keeping MDI for continuous monitoring if the licence is already there.

Implementation: which values to set and how to prove them

CA auditing

Without auditing, a CA issues certificates and its Security log records none of it. Appendix B of the Securing PKI guidance defines the CA audit filter as a seven-bit mask, and 127 switches every category on. The Audit Certification Services subcategory must also be enabled through Group Policy on servers holding the AD CS role; a local auditpol /set is overwritten whenever a GPO defines advanced audit policy.

# PowerShell on each enterprise CA, with a local administrator account.
certutil -setreg CA\AuditFilter 127
# The restart pauses issuance for a few seconds, so it belongs in a maintenance window.
Restart-Service certsvc
# Check: the filter should return 127 (0x7f).
certutil -getreg CA\AuditFilter
# The subcategory is queried by GUID, because its name is localised with the Windows language.
auditpol /get /subcategory:"{0CCE9221-69AE-11D9-BED3-505054503030}"
# On domain controllers: Kerberos Authentication Service (4768) and Directory Service Changes (5136).
auditpol /get /subcategory:"{0CCE9242-69AE-11D9-BED3-505054503030}"
auditpol /get /subcategory:"{0CCE923C-69AE-11D9-BED3-505054503030}"

Volume climbs with autoenrolment. A CA issuing certificates to every laptop and desktop in the business can produce thousands of 4886 and 4887 events a month, so retention should be sized before auditing is switched on.

Sentinel users have one more thing to check. According to the Microsoft Sentinel security events reference, the Minimal set contains none of the events in this guide, while the Common set includes 4768, 4886, 4887, 5136 and 5137 but not 4882, 4885, 4890, 4896, 4899 or 4900. The All set or a custom XPath collection rule is required. The trade-offs are the same ones we weigh in our guide to which logs to send to the SIEM.

Inventory of templates exposed to ESC1

The following query lists templates that accept a requester-supplied subject with no manager approval and no agent signatures. It is read-only. The output is then cross-checked against two more things: whether the template is published on a CA (certutil -CATemplates on each CA) and who holds enrolment rights.

# Read-only inventory using the ActiveDirectory module.
$cfg = (Get-ADRootDSE).configurationNamingContext
$base = "CN=Certificate Templates,CN=Public Key Services,CN=Services,$cfg"
$props = 'msPKI-Certificate-Name-Flag','msPKI-Enrollment-Flag','msPKI-RA-Signature','pKIExtendedKeyUsage','msPKI-Certificate-Application-Policy','msPKI-Template-Schema-Version'
$t = Get-ADObject -SearchBase $base -LDAPFilter '(objectClass=pKICertificateTemplate)' -Properties $props
# Filter: requester-supplied subject (bit 1), no approval (bit 2) and no agent signatures.
$r = $t | Where-Object { ($_.'msPKI-Certificate-Name-Flag' -band 1) -and -not ($_.'msPKI-Enrollment-Flag' -band 2) -and -not $_.'msPKI-RA-Signature' }
# Output with schema version, EKUs and application policies.
$r | Select-Object Name, 'msPKI-Template-Schema-Version', @{n='EKU';e={$_.pKIExtendedKeyUsage -join ', '}}, @{n='Policies';e={$_.'msPKI-Certificate-Application-Policy' -join ', '}}
# Each row is reviewed by hand before the template is touched.

Any template on that list that also carries EKU 1.3.6.1.5.5.7.3.2 (Client Authentication), 1.3.6.1.4.1.311.20.2.2 (Smart Card Logon), 1.3.6.1.5.2.3.4 (PKINIT), 2.5.29.37.0 (Any Purpose) or no EKU at all is an ESC1 candidate and goes to the top of the pile. On schema version 2 templates and above, application policies take precedence over EKUs, and having none counts the same as having no EKU; that is why the query returns both columns. Web server templates often appear because they need DNS names in the SAN; they seldom need client authentication.

CA flags and Schannel mapping

# Before any change, the output of each -getreg is saved for rollback.
# The -setreg lines run only if the preceding check shows the problem.
# ESC6: EDITF_ATTRIBUTESUBJECTALTNAME2 should not appear in the output.
certutil -getreg policy\EditFlags
certutil -setreg policy\EditFlags -EDITF_ATTRIBUTESUBJECTALTNAME2
# ESC16: the disabled extension list should not include 1.3.6.1.4.1.311.25.2.
certutil -getreg policy\DisableExtensionList
# The minus sign only removes strings from a REG_MULTI_SZ value; -getreg confirms the result.
certutil -setreg policy\DisableExtensionList -1.3.6.1.4.1.311.25.2
# ESC11: IF_ENFORCEENCRYPTICERTREQUEST should appear in the output.
certutil -getreg CA\InterfaceFlags
certutil -setreg CA\InterfaceFlags +IF_ENFORCEENCRYPTICERTREQUEST
# Changes made with -setreg take effect when the service restarts.
Restart-Service certsvc

On domain controllers, the Schannel value is read as follows; if it is absent, the 0x18 default applies, which leaves out UPN mapping (bit 0x4):

# Read-only, on each domain controller.
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\Schannel' -Name CertificateMappingMethods -ErrorAction SilentlyContinue

Microsoft advises finding out why EDITF_ATTRIBUTESUBJECTALTNAME2 was set before removing it. Typically a mobile device management (MDM) platform or a network appliance once needed arbitrary SANs, and if the flag is pulled without tracking that down, the first sign is likely to be failed renewals a few weeks later. IF_ENFORCEENCRYPTICERTREQUEST works the other way round: Microsoft's ESC11 assessment notes it is on by default, so if it is missing someone removed it, usually for older clients that will stop enrolling once it is restored.

Web enrolment without relayable NTLM (ESC8)

Web enrolment (CertSrv) and the CES service accept NTLM. An attacker who coerces a domain controller into authenticating to their machine can relay that to the portal and leave with a certificate for the controller. KB5005413 sets out the countermeasures. Extended Protection for Authentication goes to Required on both services, stored in IIS configuration as tokenChecking="Require". CES additionally needs <extendedProtectionPolicy policyEnforcement="Always" /> in its web.config. Require SSL is enabled so only HTTPS is accepted and, as further hardening, Windows authentication is limited to Negotiate:Kerberos or incoming NTLM is restricted on AD CS servers.

According to MSRC's December 2024 post, Windows Server 2025 enables EPA for AD CS by default, but in When Supported mode, which still accepts clients that send no channel binding. Closing ESC8 means raising it to Required there too. The change needs testing first: it breaks clients that enrol over HTTP and those behind TLS-terminating proxies.

# IIS administration module.
Import-Module WebAdministration
# Expected value on the CertSrv application: tokenChecking = Require.
Get-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' -Location 'Default Web Site/CertSrv' -Filter 'system.webServer/security/authentication/windowsAuthentication/extendedProtection' -Name tokenChecking
# Require SSL on the same application: sslFlags should include Ssl.
Get-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' -Location 'Default Web Site/CertSrv' -Filter 'system.webServer/security/access' -Name sslFlags
# CES is a separate IIS application: its web.config should contain policyEnforcement="Always".
Select-String -Path "$env:windir\systemdata\CES\*\web.config" -Pattern 'policyEnforcement'

If nobody uses web enrolment, removing the role is simpler than hardening it. Where a project is already under way to switch off NTLM without breaking the network, this step belongs in it.

Certighost: the patch and the interim workaround

The July 2026 update fixes the CA service, so it must go on every enterprise CA; patching only the domain controllers does not close Certighost. The researchers, who tested it only in a lab, describe a temporary workaround, certutil -setreg policy\EditFlags -EDITF_ENABLECHASECLIENTDC followed by a service restart, and warn that it can break legitimate enrolment; Microsoft states that the vulnerable path exists only on CAs with that flag set. One of the chain's prerequisites is the default ms-DS-MachineAccountQuota of 10 machines per user or, failing that, a machine account under the attacker's control.

Setting that quota to 0 narrows the exposure without removing the condition: according to Microsoft's analysis, the chain also works with a machine account the attacker already controls. With the quota at 0, users without delegated rights lose the ability to join computers to the domain. Before changing it, computer object creation is delegated on the relevant organisational unit to deployment accounts, which Microsoft places outside the quota, or computer accounts are pre-staged.

Detection and validation

The queries below map to the telemetry points described earlier: certificate use and mapping on the domain controller, issuance at the CA and changes to templates. None is sufficient alone; all of them should sit in the regular test cycle of a detection engineering programme.

Privileged accounts obtaining a TGT with a certificate

In ESC1 the impersonated SAN travels inside the signed request itself (the CSR), so the most dependable signal is on the domain controller and not on the CA. Event 4768 records the certificate issuer, serial number and thumbprint whenever the TGT came through PKINIT, and leaves those fields empty when no certificate was used. If a Tier 0 account that has never used a smart card suddenly obtains a TGT with a certificate, it warrants immediate investigation.

// TGTs obtained with a certificate (PKINIT) by Tier 0 accounts.
// The list is replaced with the SIEM watchlist of privileged accounts.
let Tier0 = dynamic(["administrator", "adm-infra"]);
SecurityEvent
| where EventID == 4768 and TargetUserName in~ (Tier0)
// Event fields.
| extend X = parse_xml(EventData)
| mv-apply D = X.EventData.Data on (summarize F = make_bag(bag_pack(tostring(D["@Name"]), tostring(D["#text"]))))
| extend Issuer = tostring(F.CertIssuerName), Serial = tostring(F.CertSerialNumber), PreAuth = tostring(F.PreAuthType)
// PKINIT: types 15, 16 and 17, or certificate data present.
| where isnotempty(Serial) or PreAuth in ("15", "16", "17")
| extend SourceIp = trim_start(@"::ffff:", IpAddress)
| project TimeGenerated, Computer, TargetUserName, Status, PreAuth, Issuer, Serial, SourceIp

The account filter runs before the XML is parsed because 4768 is one of the highest-volume events. False positives are likely from administrators who sign in with smart cards or Windows Hello for Business; a baseline of the accounts that routinely use certificates deals with them. For Certighost, the same query works with the controllers' machine accounts, with the trailing $, plus a filter that discards the controllers' IP addresses: a controller's TGT obtained through PKINIT from an address that belongs to no controller is a strong indicator of that chain.

Requests carrying the SAN as an attribute

In events 4886 and 4887 the Attributes field holds the request attributes, including the template (CertificateTemplate:) and, when the SAN is sent as an attribute, a SAN: entry with upn= or dns=. That is the route ESC6 opens. The field names match those used in the rules published in the Elastic and Splunk repositories. In Sentinel, the SecurityEvent table includes Requester and Attributes columns and also stores the full event as XML in EventData; the query uses the columns and falls back to the XML when they arrive empty.

Under full enforcement, a certificate obtained this way carries someone else's UPN alongside the requester's SID, and the domain controller normally refuses it with event 41, so this query is read together with the Kdcsvc one. ESC6 stays dangerous in three cases: combined with ESC16, with templates that omit the SID extension, and via Schannel.

// UPN SAN sent as an attribute that is not the requester's.
SecurityEvent
| where EventID == 4887 and EventData has "upn"
// Event fields.
| extend X = parse_xml(EventData)
| mv-apply D = X.EventData.Data on (summarize F = make_bag(bag_pack(tostring(D["@Name"]), tostring(D["#text"]))))
| extend Requester = coalesce(Requester, tostring(F.Requester)), Attributes = coalesce(Attributes, tostring(F.Attributes))
// Template and UPN, case-insensitive and tolerant of spaces.
| extend Template = extract(@"(?i)CertificateTemplate\s*:\s*([^\r\n]+)", 1, Attributes), Upn = extract(@"(?i)upn\s*=\s*([^&\r\n]+)", 1, Attributes)
| where isnotempty(Upn)
// Account without the domain or the trailing sign of machine accounts.
| extend Account = trim_end(@"\$", extract(@"([^\\]+)$", 1, Requester))
| where tolower(tostring(split(Upn, "@")[0])) != tolower(Account)
| project TimeGenerated, Computer, Requester, Template, Upn

Comparing the UPN's local part with the sAMAccountName breaks down wherever the two differ (john.smith against jsmith). There, the requester's UPN is resolved through the IdentityInfo table, which needs UEBA. False positives can come from MDM or smart card provisioning accounts and from legitimate enrolment agents; they are excluded by requester and template pair, never by requester alone. The query misses SANs that arrive as a CSR extension, and it misses Certighost, for which the Elastic rule compares the rmd attribute with the requesting account.

Kdcsvc certificate mapping events

// KDC warnings and errors: certificates without a strong mapping (39, 40, 41) or outside the NTAuth store (45, 21).
// Source depends on the agent: Kdcsvc or the provider name Kerberos-Key-Distribution-Center.
Event
| where EventLog == "System" and (Source =~ "Kdcsvc" or Source has "Kerberos-Key-Distribution-Center") and EventID in (21, 39, 40, 41, 45)
// Count per controller and event type.
| summarize Events = count(), First = min(TimeGenerated), Last = max(TimeGenerated) by Computer, EventID, EventLevelName
| order by Events desc

Event 39 is a warning in compatibility mode and an error under full enforcement; event 40 is only logged in compatibility mode, and event 41 is always an error. The collection rule needs errors from the System log and, on controllers without the September 2025 update, warnings as well. On an up-to-date domain, 39 means a valid certificate could not be strongly mapped and was refused, and 41 means the certificate's SID does not match the account. Since April 2025 the KDC also logs event 45, for a valid certificate that does not chain to the NTAuth store, and event 21, a generic AS-REQ failure.

A steady trickle usually comes from devices holding certificates from an external CA or issued through manual requests. A sudden spike from a user workstation warrants opening a case.

Changes to templates, their publication and CA security

Appendix A of Securing PKI rates events 4882 (CA permissions), 4885 (audit filter), 4890 (certificate manager settings) and 4896 (rows deleted from the database) as high criticality, all four on the CA. Events 4899 and 4900, rated medium in the same appendix, flag a template that was updated or had its security changed; the edit itself is monitored on the domain controller.

The edit itself lands on the domain controller as event 5136 against the template object. Publishing a template on a CA modifies the certificateTemplates attribute of the enrolment service object (pKIEnrollmentService), and creating a new template raises event 5137. The Sigma rule below covers all three; since SecurityEvent does not expose those fields as columns, a KQL equivalent accompanies it for Sentinel:

# Needs Directory Service Changes and an audit SACL on Certificate Templates and Enrollment Services.
title: AD CS certificate template change or publication
id: 91a0b3f1-6b2f-43cb-a86f-233f2dddc761
status: experimental
description: Detects changes to sensitive template attributes, new templates and template publication on a CA.
author: Hard2bit
date: 2026-11-24
tags: [attack.credential-access, attack.t1649]
logsource: {product: windows, service: security}
detection: {template: {EventID: 5136, OperationType: '%%14674', ObjectClass: pKICertificateTemplate, AttributeLDAPDisplayName: [msPKI-Certificate-Name-Flag, msPKI-Enrollment-Flag, msPKI-RA-Signature, pKIExtendedKeyUsage, msPKI-Certificate-Application-Policy, nTSecurityDescriptor]}, publication: {EventID: 5136, OperationType: '%%14674', ObjectClass: pKIEnrollmentService, AttributeLDAPDisplayName: certificateTemplates}, created: {EventID: 5137, ObjectClass: pKICertificateTemplate}, condition: template or publication or created}
falsepositives: [Changes approved by the PKI team]
level: high

// KQL equivalent of the Sigma rule: SecurityEvent does not expose ObjectClass or AttributeLDAPDisplayName as columns.
let Attrs = dynamic(["msPKI-Certificate-Name-Flag", "msPKI-Enrollment-Flag", "msPKI-RA-Signature", "pKIExtendedKeyUsage", "msPKI-Certificate-Application-Policy", "nTSecurityDescriptor", "certificateTemplates"]);
SecurityEvent
| where EventID in (5136, 5137) and EventData has_any ("pKICertificateTemplate", "pKIEnrollmentService")
// Event fields.
| extend X = parse_xml(EventData)
| mv-apply D = X.EventData.Data on (summarize F = make_bag(bag_pack(tostring(D["@Name"]), tostring(D["#text"]))))
| extend Class = tostring(F.ObjectClass), Attribute = tostring(F.AttributeLDAPDisplayName), Op = tostring(F.OperationType)
| where (EventID == 5137 and Class =~ "pKICertificateTemplate") or (EventID == 5136 and Op == "%%14674" and Attribute in~ (Attrs))
| project TimeGenerated, Computer, SubjectUserName, Class, Attribute, Object = tostring(F.ObjectDN)

Validating the detections without impersonating anyone

For the 4768 query, a smart card or Windows Hello for Business sign-in by a test account temporarily added to the list is enough. The 4887 query needs two separate checks. Ingestion is proved by requesting a legitimate certificate from an approved template and seeing event 4887 arrive with a complete Attributes field. The logic only fires on a SAN sent as an attribute, so it is tested against a synthetic event without touching the CA:

// Synthetic test of the logic: two made-up events; only the first carries someone else's UPN.
datatable(Requester:string, Attributes:string) [
"CONTOSO\\jsmith", "CertificateTemplate:User\nSAN:upn=someone.else@contoso.com",
"CONTOSO\\jsmith", "CertificateTemplate:User\nSAN:upn=jsmith@contoso.com"]
| extend Upn = extract(@"(?i)upn\s*=\s*([^&\r\n]+)", 1, Attributes), Account = trim_end(@"\$", extract(@"([^\\]+)$", 1, Requester))
// It should return a single row, the someone.else one.
| where isnotempty(Upn) and tolower(tostring(split(Upn, "@")[0])) != tolower(Account)

Live data also needs a check that Attributes arrives with line breaks between pairs; if the connector flattens it with spaces, the CertificateTemplate expression captures the rest of the string and needs adjusting. For the 5136 rule, a test template is duplicated without being published, its name flag changed and the template then deleted (deletion raises 5141, not 5136). For Kdcsvc, existing historical events are checked. Once a quarter, a threat hunting pass over the previous 90 days of issuance can catch some of what the rules miss.

Common mistakes and where these controls stop

Disabling a template does not invalidate the certificates it has already issued. If the review turns up an ESC1 template that has been published for years, what it issued is listed from the CA console, anything without a clear holder is revoked and a fresh CRL is published with certutil -crl. Until the CRL cached by each domain controller expires, a revoked certificate may still be accepted. Microsoft documents certutil -setreg chain\ChainCacheResyncFiletime @now for flushing that cache, but it affects every chain validation on the controller and should be tested first; in the meantime, event 4768 allows the certificate's use to be monitored.

Removing requester-supplied subject from a template that relies on it will break renewals. The usual answer is to split it: one template for web servers with DNS SANs and manager approval, another for client authentication with the subject built from Active Directory. Turning on manager approval for an autoenrolment template, by contrast, leaves enrolments and, unless specifically configured, renewals pending; it is no answer for high-volume machine or user templates.

Each query sees one slice. ESC3 and ESC4 leave their mark on the enrolment agent or the template change; ESC8 shows up in IIS and in the coerced controller's NTLM authentication; Certighost also needs a rule on the CA side, such as Elastic's, which compares the rmd attribute with the requesting account, or Defender for Identity's Potential Certighost (CVE-2026-54121) AD CS abuse alert.

MDI assessments and inventories are snapshots. Between two of them, someone with the right permissions can open a template, issue a certificate and close it again. Monitoring event 5136 as it happens covers that gap between inventories.

Finally, the CA is just another Windows server. An attacker with local administrator rights on it can use its signing material to mint certificates outside the normal flow, without a single 4887. An HSM prevents that material from being extracted, but not from being used from a compromised host. The main defence for that layer is Tier 0 isolation, together with LSASS credential protection.

Audit evidence: ISO 27001, NIS2 and Spain's ENS

The output of this review doubles as evidence. Under ISO/IEC 27001:2022 it supports Annex A controls 8.2 (privileged access rights), 8.5 (secure authentication), 8.15 (logging) and 8.24 (use of cryptography). NIS2 Article 21(2) covers policies and procedures on the use of cryptography in point (h) and access control policies in point (i). For organisations under Spain's ENS (Royal Decree 311/2022), it maps to op.acc.4 (access rights management process), op.acc.6 (authentication for the organisation's users), op.exp.8 (activity logging) and op.exp.10 (protection of cryptographic keys).

Useful evidence includes the dated template inventory, the certutil output from each CA, the CertSrv IIS configuration and the detection rules with their latest documented test. If the system is within ENS scope, that bundle is kept alongside the risk assessment; it is the same material our ENS compliance service starts from.

Where to start this week

The first step is the template inventory, crossed with what each CA publishes. Certighost has a patch, and strong mapping is already enforced for Kerberos on patched controllers. The rest depends on each organisation's configuration, and the most serious item is usually a published ESC1 template. It rests on a box ticked years ago and an enrolment permission that is too broad, and an attacker needs only one phished account with that permission to use it.

The second step is CA auditing. Without event 4887 in the SIEM there is no record of when a certificate was issued or to whom. If the team cannot spare the time to work through templates, ACLs and IIS, a systems hardening review or an internal penetration test focused on AD CS can cover it; with one or two CAs that is typically a few days' work, by our estimate, and the report also serves as audit evidence.

Sources and methodology: Microsoft documentation (KB5014754, KB5005413, the MS-CRTD and MS-WCCE specifications, the Securing PKI guidance, the Microsoft Sentinel security events reference and the Defender for Identity AD CS assessments) and Microsoft's Certighost analysis of 31 July 2026. The official CVE-2026-54121 record, CISA's KEV catalogue and MITRE ATT&CK technique T1649 were also checked. The remaining references are the official Certipy, Locksmith, Elastic and Splunk repositories, Royal Decree 311/2022 (BOE), Directive (EU) 2022/2555 (EUR-Lex) and ISO/IEC 27001:2022. The KQL queries and the Sigma rule are Hard2bit's own work. Information checked as of 24 November 2026.
Disclaimer: this content is for guidance only and does not replace an assessment of each environment. Microsoft products and the tools cited change with every update, so values, events and commands should be checked against current documentation. Any configuration change to a certification authority should be tested in pre-production first and applied in a maintenance window. Exploitation testing, including with the offensive tools mentioned, must only be carried out with prior written authorisation from the system owner.

Frequently asked questions

What does ESC1 mean in Active Directory Certificate Services? ▾

A published template that combines three settings: the requester supplies the certificate subject, the certificate can be used to authenticate, and enrolment is open to unprivileged users without manager approval. Any user with enrolment rights can then obtain a certificate bearing an administrator's UPN.

Is installing the Certighost patch enough? ▾

No. CVE-2026-54121 is a CA flaw that the July 2026 update fixes. ESC1 to ESC4 and ESC7 are configuration problems no patch fixes, and ESC8 only partly improves by default on Windows Server 2025. The template and permissions inventory is still required.

Does KB5014754 strong certificate mapping stop ESC1? ▾

No. For Kerberos on updated controllers it makes ESC9 and ESC16 very hard to exploit, because it refuses certificates without a SID extension or with weak mappings. In ESC1, though, the CA takes the SID from the request, which the requester controls. The template has to be corrected.

Which events should be collected to detect AD CS abuse? ▾

On each CA, Security events 4886 and 4887 for issuance and 4882, 4885, 4890, 4896, 4899 and 4900 for changes to permissions, auditing or templates and for deleted database rows. On domain controllers, event 4768 with certificate details, events 5136 and 5137 on templates and their publication, and KDC events 39, 40 and 41 in the System log.

Why are there no 4887 events even though the audit policy is enabled? ▾

Because two settings are needed: the Certification Services subcategory in advanced audit policy and the CA's own audit filter (certutil -setreg CA\AuditFilter 127 followed by a service restart). With only one, the CA does not record issuance. In Sentinel, the Minimal event set does not collect them either.

Is Locksmith safe to run in production? ▾

Its identification mode only reads configuration and is fit for production with suitable permissions. Mode 4 offers fixes that change templates and CA settings, so it should go through change management and be tested in pre-production first.

How should a vulnerable template that has been published for years be handled? ▾

The template should be unpublished or corrected, the certificates it issued reviewed, any without a clear holder revoked and a fresh CRL published. What it issued stays valid even once the template is disabled, and a revocation only takes effect on a domain controller when it refreshes its cached CRL.

Share this article

Cite this article

If you write about this topic, you can cite it like this:

Thilina Manana (24 November 2026). How to audit AD CS: ESC templates, strong certificate mapping and detecting rogue issuance. Hard2bit. https://hard2bit.com/en/blog/ad-cs-audit-certificate-templates-esc1-strong-mapping-detection/

<a href="https://hard2bit.com/en/blog/ad-cs-audit-certificate-templates-esc1-strong-mapping-detection/">How to audit AD CS: ESC templates, strong certificate mapping and detecting rogue issuance</a> (Hard2bit)

Want a straight answer on scope, priorities and price?

Most organizations reach us mid-question: something needs fixing, nobody has scoped it, and finance wants a number. Thirty minutes with a technical consultant — not a salesperson — gets you a defined scope, priorities ranked by risk and a price range. With what comes out of that call, we turn it into a fixed proposal. We work with organizations in Spain, across the EU and in LATAM.

If your situation is different, tell us anyway — we also take one-off questions on cybersecurity and regulatory compliance.

Based in Spain · Working across the EU and LATAM · ENS High · ISO 27001 · We usually reply in under 24 business hours