Overview
The vulnerability arises when a certificate template allows users to specify arbitrary Subject Alternative Names (SANs) during the enrollment process. If the template also permits client authentication (an Extended Key Usage that enables logon via certificates), a low-privileged user can request a certificate which can authenticate as another user via Kerberos PKINIT, allowing the attacker to compromise any other user in the environment.Vulnerability Criteria
The following criteria comprise an ESC1 vulnerability:Enterprise CA Enrollment Rights
Enterprise CA Enrollment Rights
The enterprise CA grants enrollment rights to the attacker-controlled user. Otherwise, the user would be unable to request any certificates from the CA.
Template Enrollment Rights
Template Enrollment Rights
The certificate template grants enrollment rights to the attacker-controlled user. Otherwise, the user would be unable to request certificates based on the specific template.
Manager Approval Disabled
Manager Approval Disabled
The “manager approval” feature is disabled for the certificate template. Otherwise, a “CA Manager” would have to manually review and approve the certificate request.
Authorized Signature Disabled
Authorized Signature Disabled
Client Authentication EKU
Client Authentication EKU
The certificate template defines an Extended Key Usage (EKU) that enables client authentication:
Client Authentication(1.3.6.1.5.5.7.3.2)PKINIT Client Authentication(1.3.6.1.5.2.3.4)Smart Card Logon(1.3.6.1.4.1.311.20.2.2)Any Purpose(2.5.29.37.0)Subordinate CA(No EKUs)
Arbitrary Subject Details
Arbitrary Subject Details
The certificate template allows the attacker-controlled user to specify arbitrary subject details. Otherwise, the user can only request certificates for itself, and cannot impersonate others.
Enumeration
We can search for certificate templates with these conditions using theenum-templates --filter-vulnerable command from Certify. For more information about the command and its parameters, please refer to the Command Overview page.
Sample Output
Exploitation
Once we have identified a vulnerable ESC1 certificate template that our attacker-controlled user has enrollment rights for, we can request a certificate based on the template, and include a Subject Alternative Name (SAN) for a target user that we want to impersonate (e.g.Administrator).
Certificate Request
This can be done using therequest command from Certify. The SAN can be in either of the formats UserPrincipalName (--upn) or DnsName (--dns). For environments where Strong Certificate Mapping is enabled, the security identifier (SID) of the target user must also be supplied with the --sid parameter.
Sample Output
Authentication
When the certificate has been issued, it is printed to the console in a base64-encoded format. The format is supported by Rubeus and can be used to authenticate as the target user with the [asktgt](/GhostPack/Rubeus-mdx/commands/ticket-requests/asktgt#authentication-methods) command by setting the /certificate: parameter to the output certificate.
Sample Output
Verification
Since the/ptt parameter was supplied to Rubeus when requesting the TGT, the ticket has been injected into the Kerberos ticket list, and we should be able to authenticate as the target user and access systems that the target user has access to.
Mitigation
Defense Recommendations
- Remove the
ENROLLEE_SUPPLIES_SUBJECTflag from certificate templates - Implement template access controls to limit enrollment rights
- Enable manager approval for sensitive certificate templates
- Consider implementing Strong Certificate Mapping
- Regular auditing of certificate template configurations