Active Directory Certificate Services (ADCS) is one of the most common ways a low-privilege user becomes Domain Admin on internal tests. The classic case is ESC1: a certificate template that lets the requester choose whose name goes on the certificate. Ask for a certificate "as the administrator", authenticate with it, done. This post explains the misconfiguration, walks through it with Certipy in a lab, and covers detection and the fix.
Lab work only. Test ADCS only where you have written permission.
Why certificates can log you in
Kerberos supports certificate-based logon through PKINIT. If a certificate is trusted by the domain, has an EKU that allows client authentication, and maps to a user, the DC will issue that user a TGT. The mapping comes from the certificate's Subject Alternative Name (SAN), usually a UPN like administrator@corp.local.
So the question becomes: who gets to decide what's in the SAN?
What makes a template ESC1
A template is vulnerable to ESC1 when all of these are true:
-
Enrollee supplies subject (
CT_FLAG_ENROLLEE_SUPPLIES_SUBJECTinmsPKI-Certificate-Name-Flag). The requester can put any name in the SAN. - An EKU that allows authentication: Client Authentication, PKINIT Client Authentication, Smart Card Logon, Any Purpose, or no EKU at all.
- Low-privileged users (like Domain Users or Authenticated Users) have enrollment rights.
- Manager approval is not required and no authorized signatures are needed.
These templates usually exist because someone copied the "Web Server" template, needed client auth for an app, and ticked "Supply in the request" so the app could set its own name.
Finding ESC1 with Certipy
certipy find -u lowpriv@corp.local -p 'Password1' -dc-ip 10.10.10.10 -vulnerable -stdout
Certipy lists the CAs and templates and flags the ones it considers vulnerable, with the ESC number and the reason. Note the CA name and the template name. BloodHound CE also shows ADCS paths if you collect them.
Requesting a certificate as someone else
certipy req -u lowpriv@corp.local -p 'Password1' -dc-ip 10.10.10.10 \
-ca CORP-CA -template VulnTemplate -upn administrator@corp.local
On domain controllers with strong certificate mapping in full enforcement (the KB5014754 changes), the certificate also needs the target's SID. Recent Certipy versions take it with -sid:
certipy req ... -upn administrator@corp.local -sid S-1-5-21-...-500
You get administrator.pfx.
Authenticating with the certificate
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.10
Certipy performs PKINIT, saves a TGT to a ccache file, and uses the UnPAC-the-hash technique to recover the account's NT hash. From there you can use the ticket or pass the hash. The same PKINIT and UnPAC-the-hash flow powers Shadow Credentials.
The certificate stays valid until it expires, often a year, even if the administrator changes their password. That's why ADCS findings matter for persistence, and why the report should list every certificate you issued so the client can revoke them.
Detection
- On the CA, enable auditing of certificate services. Event 4886 (request received) and 4887 (certificate issued) show the requester and the attributes.
- Alert when the requester and the SAN in the issued certificate don't match, especially for privileged accounts.
- On DCs, event 4768 includes certificate information when a TGT is requested with PKINIT. A privileged account suddenly logging on with a certificate is worth a look.
Mitigation
- Remove "Supply in the request" from templates that allow authentication, or remove the authentication EKUs if they aren't needed.
- Restrict enrollment rights to the specific groups that need the template.
- Require CA manager approval for sensitive templates.
- Run
certipy find -vulnerableor a tool like Locksmith regularly. ADCS misconfigurations come back when someone duplicates a template. - Keep strong certificate mapping in full enforcement mode on DCs.
FAQ
What is ADCS ESC1?
A certificate template misconfiguration where low-privileged users can enroll, the template allows client authentication, and the requester can supply the subject. It lets a user request a certificate for any account, including domain admins.
Which tool finds vulnerable certificate templates?
Certipy (certipy find -vulnerable) from Linux, or Certify from Windows. Defenders can use Locksmith or PSPKIAudit.
Does resetting the password fix an ESC1 compromise?
No. A certificate issued for the account keeps working until it expires or is revoked. Revoke the issued certificates and fix the template.