Saltar al contenido principal

AD CS: catálogo ESC1-ESC16

En junio de 2021, Will Schroeder (@harmj0y) y Lee Chagolla-Christensen publicaron desde SpecterOps el paper “Certified Pre-Owned”, catalogando las primeras 8 escaladas (ESC1-ESC8) en una infraestructura PKI que Microsoft había documentado pobremente desde 2008. El catálogo creció a ESC16 entre 2022 y 2025.
Por qué sigue crítico en 2026: AD CS está habilitado por defecto en muchos entornos empresariales, sus templates traen flags peligrosos (CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT) sin warning visual en la consola GUI, y Mandiant en su M-Trends 2025 documentó múltiples brechas donde UNC2165 (RansomHub) abusaron AD CS para crear cuentas admin exentas de MFA.

Detección global (siempre primero)

Ese único comando enumera CAs, templates, y marca cuáles son vulnerables a cada ESC. Es el nmap -sV del AD CS.

ESC1 — Enrollee Supplies Subject

Condición: Template con CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT + EKU Client Authentication + Enroll para usuarios bajos. El solicitante decide el Subject Alternative Name (UPN/DNS). Exploit:
Impacto: Domain Admin directo. Detección: Event ID 4886/4887 con SAN distinto al requester. Remediación: quitar bit msPKI-Certificate-Name-Flag, exigir manager approval.

ESC2 — Any Purpose EKU

Condición: Template con EKU Any Purpose (OID 2.5.29.37.0) o sin EKU. Vale para todo, incluida autenticación. Exploit: mismo flujo que ESC1 + opcionalmente -on-behalf-of. Remediación: eliminar 2.5.29.37.0 de pKIExtendedKeyUsage, fijar EKU específicas.

ESC3 — Enrollment Agent

Condición: Template con EKU Certificate Request Agent (OID 1.3.6.1.4.1.311.20.2.1). El portador puede pedir certs on-behalf-of otros usuarios. Exploit:
Remediación: restringir Enrollment Agent a Tier 0, exigir signed approval.

ESC4 — ACL débil sobre el template

Condición: WriteDACL/GenericAll/WriteOwner sobre el objeto template AD. Convertimos el template en ESC1 y volvemos. Exploit:
Detección: Event ID 4900 (template security updated).

ESC5 — ACL débil sobre otros objetos PKI

Condición: ACL débiles en NTAuthCertificates, Enrollment Services, computer object de la CA, contenedor CN=Public Key Services. Exploit (forge desde la CA private key):
Remediación: scan periódico con Locksmith 2.

ESC6 — EDITF_ATTRIBUTESUBJECTALTNAME2

Condición: la CA tiene este flag activado, lo que hace que cualquier template acepte SAN arbitrario en la CSR. Remediación:

ESC7 — ManageCA / ManageCertificates peligrosos

Condición: usuario bajo con ManageCA. Puede habilitar template SubCA, denegar requests propias y reaprobarlas. Exploit:
Detección: Event ID 4888 → 4887 patrón “deny then issue”.

ESC8 — NTLM Relay a Web Enrollment (HTTP)

Condición: endpoint http://CA/certsrv/ activo sin EPA/HTTPS. Combinable con coercion (PetitPotam, PrinterBug, DFSCoerce). Es la cadena clásica de un usuario raso a Domain Admin en 5 min.
Mitigación: KB5005413 — forzar EPA + HTTPS en IIS, deshabilitar HTTP en /certsrv/.

ESC9 — CT_FLAG_NO_SECURITY_EXTENSION

Condición: template marca el flag 0x80000 en msPKI-Enrollment-Flag. El cert no embebe SID extension (szOID_NTDS_CA_SECURITY_EXT), forzando mapeo débil por UPN. Exploit (chain con account abuse):
Remediación: limpiar flag 0x80000.

ESC10 — Weak Certificate Mapping (registry)

Condición: HKLM\System\CurrentControlSet\Services\Kdc\StrongCertificateBindingEnforcement = 0 o 1 (no Full Enforcement). Desde febrero 2025 Microsoft fuerza valor 2 por defecto, pero entornos legacy siguen vulnerables. Exploit idéntico a ESC9 apuntando a registry weakness en KDC.

ESC11 — NTLM Relay a endpoint RPC

Condición: IF_ENFORCEENCRYPTICERTREQUEST no seteado en CA\InterfaceFlags. ICertPassage (RPC) acepta NTLM sin encriptar. Exploit:

ESC12 — CA con HSM YubiHSM y shell access

Condición: la CA usa YubiHSM con credenciales en plain-text en registry. Acceso a shell del CA = robo de la PIN/auth-key del HSM. Remediación: HSM FIPS 140-3 Level 3 con creds en device memory.

ESC13 — Issuance Policy linkeada a grupo privilegiado

Condición: atributo msDS-OIDToGroupLink mapea un OID de issuance policy a un grupo AD privilegiado. Al obtener cert con esa policy, el TGT incluye membresía implícita del grupo. Exploit:

ESC14 — Weak Explicit Mapping (altSecurityIdentities)

Condición: atributo altSecurityIdentities del usuario/computer usa mappings débiles X509RFC822 o X509IssuerSubject (deprecated post KB5014754). Exploit:
Remediación: migrar a X509IssuerSerialNumber, X509SKI o X509SHA1PublicKey.

ESC15 — EKUwu / CVE-2024-49019

Condición: template schema V1 + flag de enrollee-supplies-subject. La CSR puede inyectar Application Policies (extensión privada Microsoft) que se imponen sobre la EKU del template. Descubierto por Justin Bollinger (TrustedSec), septiembre 2024 — patch noviembre 2024. Exploit:
CVSS 7.8. Remediación: parche nov-2024, migrar todos los V1 a V2/V3 schema, despublicar V1. Fuente: TrustedSec EKUwu, CVE-2024-49019.

ESC16 — SID extension globalmente deshabilitada

Condición: OID 1.3.6.1.4.1.311.25.2 listado en policy\DisableExtensionList de la CA. Ningún cert emitido incluye SID extension → ESC9 a nivel global. Exploit (chain shadow credentials + UPN swap):

Toolkit en 2026: cuándo usar cada herramienta

Regla 2026: siempre empezar con certipy-ad find, exploit con certipy-ad req, fallback a PassTheCert si PKINIT da KDC_ERR_CLIENT_NOT_TRUSTED.

Detección defensiva moderna (2025-2026)

Microsoft Defender for Identity lanzó en 2024 un sensor dedicado AD CS. Alertas activas en 2026:
  • Suspicious certificate request relayed from a Domain Controller (cubre ESC8/ESC11)
  • Suspicious deletion of certificate requests
  • Suspicious certificate usage over Kerberos (PKINIT)
  • Certificate Authority ACL modification with high-privilege addition (ESC4/ESC5/ESC7)
Event IDs Windows clave (auditar en CA + DCs): Auditoría defensiva mensual — ejecutar:
  • Locksmith 2 — scan automatizado de templates y configuración CA.
  • PSPKIAuditInvoke-PKIAudit y Get-CertRequest para hunt retroactivo en la base de datos de la CA.

Casos reales

  • CVE-2022-26923 “Certifried” (mayo 2022, Oliver Lyak): cualquier usuario podía spoofear dNSHostName de un DC y obtener cert de máquina del DC. CVSS 8.8, en CISA KEV. Microsoft añadió la SID extension szOID_NTDS_CA_SECURITY_EXT como respuesta — origen de ESC9/ESC16. (HackTheBox)
  • CVE-2024-49019 “EKUwu” (octubre 2024, TrustedSec): inyección de Application Policies sobre templates V1 default → escalada a DA. Patch noviembre 2024.
  • UNC2165 / RansomHub (Mandiant M-Trends 2025): explotaron AD CS para crear admins exentos de MFA antes de destruir backups y desplegar ransomware. (Mandiant)
  • Black Basta playbook (chats filtrados febrero 2025): AD CS aparece como vector estándar tras initial access SMB.

Hardening obligatorio

  1. Templates: deshabilitar CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT salvo workflow auditado; requerir Manager Approval; eliminar EKU Any Purpose; migrar todos los V1 a V2/V3 schema (mata ESC15).
  2. CA flags:
  3. Web enrollment: HTTPS-only + EPA + Kerberos auth; deshabilitar HTTP en /certsrv/ (KB5005413).
  4. ACL audit mensual: Invoke-PKIAudit y Locksmith2 -Mode 1; revocar Write*/GenericAll de Domain Users sobre cualquier objeto bajo CN=Public Key Services,CN=Services,CN=Configuration.
  5. Strong Mapping enforcement: StrongCertificateBindingEnforcement = 2 en todos los DCs.
  6. MDI sensor sobre la CA: instalar el AD CS sensor de Defender for Identity en cada CA enterprise.
  7. Despublicar templates obsoletos: certutil -setcatemplates -<TemplateName>. El template no usado es deuda de seguridad.

Recursos


Recursos relacionados