Skip to main content

Enumeration

Start with Certipy’s vulnerable scan to quickly identify exploitable templates: it checks all known ESC conditions in one pass.

ESC1: Enrollee Supplies Subject

Conditions:
  • Low-priv user can enrol
  • No Manager Approval
  • No Authorised Signatures
  • Client Authentication EKU enabled
  • Template allows user to specify SAN (subjectAltName)
The SAN field isn’t validated, so you can request a cert claiming to be any domain user including Administrator.

ESC2: Any Purpose EKU

Conditions:
  • Low-priv user can enrol
  • No Manager Approval
  • No Authorised Signatures
  • Template has Any Purpose EKU or no EKU at all
With Any Purpose EKU the cert can be used for client auth, making it usable to request further certificates on behalf of other users.

ESC3: Enrolment Agent

Conditions:
  • Template has Certificate Request Agent EKU
  • Another template allows enrolment agent to enrol on behalf of others
Two-step: get an enrolment agent cert first, then use it to request a cert impersonating an admin on a second template.

ESC4: Writable Template

Conditions:
  • You have write rights on a certificate template: Owner, Write Owner, Write DACL, or Write Property
Overwrite the template’s attributes to introduce ESC1 conditions, exploit it, then restore the original config.

ESC5: Vulnerable PKI Object Access Control

Conditions:
  • Write permissions on PKI AD objects under CN=Public Key Services,CN=Services,CN=Configuration,...
  • Objects in scope: NTAuthCertificates, Enrollment Services objects, CA objects, certificate templates container, AIA/CDP containers
ESC5 is a catch-all for dangerous ACLs on PKI infrastructure rather than on individual templates. Exploitation depends on which object you have write on: write on the CA Enrollment Services object chains to ESC7 (grant yourself ManageCA/ManageCertificates), write on NTAuthCertificates lets you add a rogue CA cert and forge trusted certificates, write on the templates container lets you create new ESC1-vulnerable templates.

ESC6: EDITF_ATTRIBUTESUBJECTALTNAME2

Conditions:
  • CA has EDITF_ATTRIBUTESUBJECTALTNAME2 flag set
  • Any template with Client Authentication EKU is exploitable
This flag on the CA makes every Client Authentication template behave like ESC1: request any template with client auth EKU and supply an arbitrary SAN. On DCs with KB5014754 applied, the UPN in the SAN is ignored unless the certificate also lacks the SID security extension. On patched environments combine with ESC9 (template disables extension) or ESC16 (CA disables extension).

ESC7: Vulnerable CA ACL

Conditions:
  • You have ManageCA or ManageCertificates rights on the CA
With ManageCA you can enable the SubCA template and grant yourself the Certificate Officer role. Certificate Officer lets you issue any pending or failed request, including ones that require manager approval.

ESC8: Relay to AD CS HTTP

AD CS HTTP enrolment (/certsrv/certfnsh.asp) can be abused via both NTLM and Kerberos relay. The coercion and cert auth steps are the same for both; what differs is the relay tool and the prerequisite.

NTLM Relay

Conditions:
  • AD CS HTTP enrolment endpoint enabled
  • SMB signing disabled on the coerced host
Alternatively with ntlmrelayx.py:

Kerberos Relay (krbrelayx)

Conditions:
  • AD CS HTTP enrolment endpoint enabled
  • EPA (Extended Protection for Authentication) not enforced on certsrv (default on most installs)
  • SMB signing state does not matter
Kerberos relay works when SMB signing is enforced and NTLM relay is blocked. The trick is a crafted DNS hostname that embeds a minimal marshalled CREDENTIAL_TARGET_INFORMATION structure. When the DC tries to connect to that hostname, Windows internally calls CredMarshalTargetInfo which appends a Base64-encoded struct to the SPN, producing a hostname like DC-NETBIOS1UWhRCAA.... DNS resolves that to your listener, so the DC sends its AP-REQ to you instead.
1

Start krbrelayx

2

Add a malicious DNS record

The hostname is the DC’s NetBIOS name with the fixed marshalled CREDENTIAL_TARGET_INFO suffix appended. bloodyAD registers it in AD DNS pointing at your listener.
3

Coerce DC authentication

Trigger the DC to authenticate to the malicious hostname. Any coercion tool works. ERROR_BAD_NETPATH is the expected response and means the coercion fired successfully.
4

Authenticate with the obtained cert

krbrelayx catches the AP-REQ, relays it to certsrv, and writes the PFX to disk.
From Windows, KrbRelay handles coercion internally via DCOM — no separate DNS or coercion step needed:

ESC9: No Security Extension

Conditions:
  • Template has CT_FLAG_NO_SECURITY_EXTENSION flag
  • You have GenericWrite on an account
Without the security extension the cert isn’t bound to a specific account SID, so temporarily changing a victim’s UPN to match the admin gets you a valid admin cert.

ESC10: Weak Certificate Mappings

Conditions:
  • Registry key StrongCertificateBindingEnforcement = 0 or 1 (not 2)
  • OR CertificateMappingMethods has UPN bit set
Similar to ESC9: weak mapping means the DC resolves cert to account by UPN rather than by SID, so a UPN swap is all you need.

ESC11: IF_ENFORCEENCRYPTICERTREQUEST

Conditions:
  • CA has IF_ENFORCEENCRYPTICERTREQUEST not set
  • Allows NTLM relay over RPC (not just HTTP)
Like ESC8 but over the RPC interface instead of HTTP: useful when certsrv isn’t exposed.

ESC12: CA Key Compromise (Golden Certificate)

Conditions:
  • Admin or SYSTEM access on the CA server
With the CA private key you can forge valid certificates for any principal in the domain. Forged certs bypass template restrictions and enrolment logs entirely.
Conditions:
  • Principal has enrolment rights on the template
  • Template has an issuance policy in msPKI-Certificate-Policy
  • That issuance policy has msDS-OIDToGroupLink pointing to a privileged universal group
  • The linked group is empty and has universal scope
  • Template has a client authentication EKU
When the DC processes Kerberos authentication it sees the issuance policy OID in the cert and injects the linked group’s SID into the PAC. You gain effective group membership at authentication time without being listed as a member in AD.

ESC14: Explicit Certificate Mapping

Conditions (ESC14A):
  • Write access on a target account’s altSecurityIdentities attribute
altSecurityIdentities is the explicit certificate-to-account binding attribute. You map a certificate you control to a target account, then authenticate as that account using your cert. The serial number must be hex-reversed in the mapping format.

ESC15: Arbitrary Application Policy Injection

Conditions:
  • Template has schema version 1
  • Principal has enrolment rights
  • No manager approval required
(CVE-2024-49019) Version 1 templates do not validate the Application Policy extension in the CSR. Since Application Policy takes precedence over EKU when both are present, injecting the Certificate Request Agent OID (1.3.6.1.4.1.311.20.2.1) into any enrollable v1 template turns it into an enrolment agent cert, enabling the ESC3 step-2 chain.

ESC16: CA-Wide SID Extension Removal

Conditions:
  • CA has szOID_NTDS_CA_SECURITY_EXT (OID 1.3.6.1.4.1.311.25.2) in its DisableExtensionList
  • StrongCertificateBindingEnforcement is not 2 on DCs, or KB5014754 not applied
ESC16 is ESC9 at the CA level: every certificate issued by this CA lacks the SID security extension regardless of template configuration, making every enrollable template with client auth exploitable via UPN swap.

Post-Exploitation with Certificates

Once you have a PFX, use PKINIT to get the NT hash or a TGT: or fall back to Schannel LDAP shell if PKINIT is unavailable (e.g. no smart card logon EKU).