Certificate Template Allows Privilege Escalation (AD CS ESC1)

Illustrative example. ACME Financial is an invented company and every detail below is made up. The layout is the one our reports use.

Finding 4.1
Certificate Template Allows Privilege Escalation (AD CS ESC1)
C1
Severity
Critical
CVSS 3.1 score
8.8High
Risk rating
Likelihood:  High
Impact:  Critical
CVSS vector
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H
Classification
MITRE ATT&CK T1649 - Steal or Forge Authentication Certificates
CWE-269
Description
Active Directory Certificate Services (AD CS) issues certificates that users and computers use to sign in. A certificate template is vulnerable to ESC1 when low-privileged users can enroll in it, choose whose name goes on the certificate, and use the certificate to sign in. Any such user can then obtain a certificate in an administrator's name and sign in as that administrator.
Affected assets
ca01.corp.acme-financial.example (certificate authority), template ACME-RemoteAccess
The CVSS score rates the technical characteristics of the flaw. The severity rating also accounts for likelihood and business impact: the template is available to every domain user, and exploitation results in control of the domain.

Impact

Using this flaw, Strafe escalated from a standard domain user account to domain administrator in ACME Financial’s internal domain. Domain administrator access provides control of every domain-joined server and workstation, every employee account, and the systems that store customer and payment data. A certificate issued in this way remains valid until it expires or is revoked; resetting the affected administrator’s password does not invalidate it.

The template is available to all domain users, so the compromise of any employee account or workstation is sufficient to exploit it. Within an attack chain, this finding provides privilege escalation immediately after initial access and would precede data theft or the deployment of ransomware. Strafe assesses the likelihood as high and the impact as critical.

Technical details

Testing began from a standard domain account provided for the assessment, CORP\t.user, which held no administrative rights. A review of the certificate templates published in Active Directory identified one template that met all three conditions:

Template:            ACME-RemoteAccess
Enrollment rights:   CORP\Domain Users
Extended key usage:  Client Authentication
Subject name:        Supplied in the request
Manager approval:    Not required
Certificate template enumeration showing ACME-RemoteAccess allows client authentication, lets the enrollee supply the subject, and grants enrollment to Domain Users
Figure 1 - The misconfigured certificate template Open full size

Authenticated as CORP\t.user, Strafe requested a certificate from this template and specified a domain administrator account as the subject:

Requested by:              CORP\t.user
Template:                  ACME-RemoteAccess
Subject alternative name:  da-svc@corp.acme-financial.example
Result:                    Issued
Certipy requesting a certificate from the ACME-RemoteAccess template with a domain administrator as the subject, which is issued
Figure 2 - A certificate issued in an administrator's name Open full size

Strafe used the issued certificate to authenticate to a domain controller as da-svc and listed the members of the Domain Admins group to confirm the level of access. No changes were made to the environment. The finding was reported to ACME Financial’s point of contact on the day it was identified.

Certipy authenticating as da-svc with the issued certificate and listing the members of Domain Admins
Figure 3 - Domain administrator access Open full size

Remediation

  1. Configure the ACME-RemoteAccess template to build the subject name from Active Directory rather than accepting it from the request. If requester-supplied names are a business requirement, require certificate manager approval and restrict enrollment to the group that needs the template.
  2. Review all published templates for the same combination of settings: a requester-supplied subject, an authentication usage, and enrollment rights granted to a broad group.
  3. Review the certificate authority’s issuance records for this template, and revoke any certificate whose subject differs from the account that requested it.
  4. Enable auditing on the certificate authority (events 4886 and 4887), and alert when the requested subject differs from the requester.

Resetting the affected administrator’s password is not sufficient remediation, because the issued certificate remains valid.

Certipy requesting the same certificate after the fix, now issued in the requester's own name
Figure 4 - The subject forced to the requester after the fix Open full size

References

  • MITRE ATT&CK, T1649: Steal or Forge Authentication Certificates
  • SpecterOps, "Certified Pre-Owned: Abusing Active Directory Certificate Services"
  • Microsoft, securing Active Directory Certificate Services templates