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_SUBJECT in mspki-certificate-name-flag.

  • Set the mspki-certificate-application-policy to be used for authentication, such as Any Purpose or Client 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

Then use the generated pfx (cert.pfx) to grab the NTLM hash for the account.

Windows

Note to self, it should be in theory possible to create a backup JSON or XML file of a certificate templates configuration and restore with ADSI. Should look into completing this and adding these notes to this section.

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:

ESC1

Mitigations

  • Set appropriate access controls on the template object. Remove overly permissive permissions from unexpected or low level users and groups.

Last updated