Security Roles
Either of the following security roles comprise an ESC7 vulnerability:CA Security Roles
CA Security Roles
- The
ManageCArole (also called theAdministratorrole)- Allows the principal to manage configurations and settings on the CA.
- The
ManageCertificatesrole (also called theOfficerrole)- Allows the principal to manage and issue certificates that are pending approval.
Detection
We can search for certificate authorities with excessive role delegations using theenum-cas --filter-vulnerable command from Certify. For more information about the command and its parameters, please refer to the Command Overview page.
As seen in the
CA Permissions section, arbitrary principals can have delegated security roles on certificate authorities. The abuse scenario for this vulnerability can vary depending on the delegated security role, but we have detailed some attack scenarios for each role in the following sections.ManageCA
The Certified Pre-Owned white-paper describes enabling ESC6 as one of the possibleManageCA attack vectors, but there are many other ways to abuse the security role.
ManageCA Attack Vectors
ManageCA Attack Vectors
- Enable ESC6 and perform the relevant attack.
- This can be toggled on/off with:
Certify.exe manage-ca --ca <ca> --esc6
- This can be toggled on/off with:
- Enable ESC11 and carry out the relevant attack.
- This can be toggled on/off with:
Certify.exe manage-ca --ca <ca> --esc11
- This can be toggled on/off with:
- Enable ESC16 and carry out the relevant attack.
- This can be toggled on/off with:
Certify.exe manage-ca --ca <ca> --esc16
- This can be toggled on/off with:
- Enable a disabled certificate template that is vulnerable to another escalation technique.
- These can be enabled/disabled with:
Certify.exe manage-ca --ca <ca> --template <template>
- These can be enabled/disabled with:
- Issue a certificate request that has failed due to access violation.
- These can be issued with:
Certify.exe manage-ca --ca <ca> --issue-id <request id> - This attack requires the
ManageCertificatessecurity role.
- These can be issued with:
- Coerce the CA server to authenticate over NTLM (and relay) via CRL Distribution Points (CDPs).
- For more information, please refer to this blogpost.
- Obtain RCE on the CA server by deploying a webshell via CRL Distribution Points (CDPs).
- For more information, please refer to this blogpost.
enum-templates --filter-client-auth --filter-supply-subject command from Certify.
If we can only identify certificate templates that are disabled (i.e. not published by any certificate authorities), we can simply enable them on an arbitrary certificate authority using the following command:
Certify.exe manage-ca --ca <ca> --template <template>
Administrator).
This can be done using the request command from Certify. The SAN can be in either of the formats UserPrincipalName (--upn), DnsName (--dns), or Rfc822Name (--email). For environments where Strong Certificate Mapping is enabled, the security identifier (SID) of the target user must also be supplied with the --sid parameter.
Once the certificate request has failed, the private key used for the certificate request is printed, and we must save this for later.
ManageCertificates role for the next step. If we do not have the role, we can grant it with the following command:
Certify.exe manage-ca --ca <ca> --officer <sid>
ManageCA and the ManageCertificates roles, we can force-issue the certificate request.
request-download command from Certify. We can include the private key from our certificate request to form a fully authenticatable PKCS12 (PFX) certificate.
asktgt command.
/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.
ManageCertificates
The Certified Pre-Owned white-paper describes approving pending certificates as a possibleManageCertificates attack vector, and as such require a certificate template with the following criteria:
ManageCertificates Template Requirements
ManageCertificates Template Requirements
- The enterprise CA grants enrollment rights to the attacker-controlled user.
- Otherwise, the user would be unable to request any certificates from the CA.
- 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.
- The “manager approval” feature is enabled for the certificate template.
- Otherwise, the
ManageCertificatesrole would not be able to manage and issue the certificate request.
- Otherwise, the
- The “authorized signature” feature is disabled for the certificate template.
- Otherwise, an enrollment agent would need to sign the certificate request on behalf of the requester.
- The certificate template defines a client authentication EKU and allows the requester to specify subject details (ESC1).
- The certificate template defines the
Any Purpose(2.5.29.37.0) EKU orSubordinate CA(No EKUs) (ESC2). - The certificate template defines the
Certificate Request Agent(1.3.6.1.4.1.311.20.2.1) EKU (ESC3).
enum-templates --filter-manager-approval command from Certify. For more information about the command and its parameters, please refer to the Command Overview page.
ENROLLEE_SUPPLIES_SUBJECT flag in the Certificate Name Flag attribute, it would be possible to perform an ESC1 attack, but with the slight variation of requiring manual manager approval using the ManageCertificates role. This would allow us to bypass the “manager approval has to be disabled” constraint for the ESC1 vulnerability.
However, since this is not the case, another solution must be found. Valdemar Carøe and Jonas Bülow Knudsen have recently discovered a new technique inspired by the ESC13 misconfiguration, which requires the existence of a group-linked enterprise OID (issuance policy). The issuance policy does not have to be applied to any certificate template, it just has to exist.
We can search for group-linked enterprise OIDs using the enum-pkiobjects --show-linked-oids command from Certify. For more information about the command and its parameters, please refer to the Command Overview page.
Since the
TemporaryAdmins group is a member of the Enterprise Admins group, we deem that it is worth compromising, so we request a certificate from the manager approval template using the request command from Certify.Once the certificate request has failed, the private key used for the certificate request is printed, and we must save this for later.
ManageCertificates role, we can now inject the group-linked issuance policy into the pending certificate request using the manage-ca --ca <ca> --issuance-policy <request id>:<policy oid> command from Certify.
request-download command from Certify. We can include the private key from our certificate request to form a fully authenticatable PKCS12 (PFX) certificate.
asktgt command using our low-privileged user.
/ptt parameter was supplied to Rubeus when requesting the TGT, we should now have a ticket in our Kerberos ticket list that contains Enterprise Admins membership. We can verify this by attempting to execute whoami /all on a domain controller.