ESC4
Description
ESC4 abuse is where a low privilege user possess permissions over a certificate template which could be used to make it vulnerable to other attacks such as ESC1 or ESC2. In theory, the templates could be modified to support any misconfiguration based attack but, the simplest would be to make it vulnerable to ESC1 and ESC2.
Requirements for attack path
Access to an account that has at least ONE of the following permissions over a template:
Owner
Write Owner Principals
Write Property Principals
Write DACL Principals
Changes required to a template to make it vulnerable to ESC1 attacks.
Disable manage approval
disable authorized signatures
enable the flag
ENROLLEE_SUPPLIES_SUBJECTinmspki-certificate-name-flag.Set the
mspki-certificate-application-policyto be used for authentication, such asAny PurposeorClient Authentication.
Linux
Enumeration
Performing the attack
Before making any changes, certipy can be used to save the current configuration of a template, so it can be restored to its original form later.
This command will make the selected template vulnerable to ESC1 attacks. Below, shows the ESC4 vulnerable template after modification. We can see how now any authenticated user on the domain could abuse this for escalation.

We can then perform the ESC1 attack against the template and grab
For accuracy and to avoid certificate mismatch issues we should always aim to provide the -sid parameter which should be the value of the UPN we are targeting (administrator@security.local in the example below).
Then use the generated pfx (cert.pfx) to grab the NTLM hash for the account.
Ensure to restore the original template configuration once this attack has been achieved.
Windows
These notes for Windows do not discuss restoring the altered configuration. Whilst the practice below is valid for CTF and lab envrionments, do not perform the actions below on a real engagement without first checking with the client that they have backed up the template to be modified. It is preffered to use Certipy if on an engagement in order to restore the old configuration.
Enumeration
Certify is not able to discern vulnerable certificate templates via its 'find /vulnerable' module for ESC4 and requires manual identification.

Performing the attackE
The following modifications require to be complete. The example below uses PowerView.
Or using the following native ADSI commands
After making the changes above and enumerating the certificate configuration again, we should see the template is now vulnerabl to ESC1.

From here we can follow the attack methodology for ESC1 as described here:
ESC1Mitigations
Set appropriate access controls on the template object. Remove overly permissive permissions from unexpected or low level users and groups.
Last updated