WriteOverCertificateTemplate

Summary

FSProtect ACL Alias

WriteOverCertificateTemplate

AD Alias

Write

Affected Object Types

Certificate Templates

Exploitation Certainty

Certain

AD Right

WriteProperty

AD Permission Guid

00000000-0000-0000-0000-000000000000

Description

The WriteOverCertificateTemplate permission in Active Directory grants a user or group write permission over certificate templates. This permission allows the holder to modify and manage all writable aspects of certificate templates. Administrators can configure key aspects such as validity periods, encryption algorithms, enrollment options, auto-renewal settings, and which Certificate Authorities can issue certificates based on these templates.

However, if misconfigured, the WriteOverCertificateTemplate permission can pose significant security risks. An attacker who gains WriteOverCertificateTemplate right on a certificate template could modify its settings to issue fraudulent certificates, bypass security checks, or weaken cryptographic controls. This exploitation could lead to unauthorized access, compromise of secure communications, and widespread disruption of the Public Key Infrastructure (PKI).

Identification

PowerShell

Active Directory Module

Using the ActiveDirectory PowerShell module, you can enumerate WriteOverCertificateTemplate entries.

1. Find-WriteOverCertificateTemplate function

2. Scan all templates

3. Scan a specific template

4. Exclude default admins for clear visibility

.NET Directory Services

By leveraging PowerShell’s built-in .NET DirectoryServices namespace, you can enumerate WriteOverCertificateTemplate entries without relying on any external modules or dependencies.

1. Find-WriteOverCertificateTemplateSimple function

2. Scan all templates

3. Scan a specific template

4. Exclude default admins for clear visibility

Certification Authority

1. Open Certification Authority (certsrv) on your Windows server.

2. Expand CA name and right click the Certificate Templates

3. Select Manage from the context menu.

4. In the Certificate Templates Console window, double-click the Certificate Template.

5. In the Properties window, navigate to the Security tab.

6. In the Security Settings window, locate and select the relevant Access Control Entry (ACE) for the user or group you wish to configure.

7. In the permissions list, locate and check the option Write.

8. Click OK to save your changes and close the dialogs.

Exploitation

This permission can be exploitable on Windows systems with certify and rubeus, while on Linux systems, tools such as certipy can be effectively used for exploitation.Certify, Rubeus, Certipy

The following examples demonstrate exploitation on Windows and Linux environments.

Windows

Using powerview to edit the template to be vulnerable to ESC01

Request a certificate for administrator

Example:

After running this, certify will give a certificate to you. You should create a pem file and write came file. Then convert pem file to pxf format with openssl, it will give you a pfx-formatted certificate. (You don't have to set password)

Example:

Then you can obtain a TGT using the formatted certificate with Rubeus and retrieve the NTLM hash.

Example:

Linux

Using Certipy-AD to list vulnerable templates

Example:

Edit the Template to Be Vulnerable to ESC01 Using Certipy-AD

Example:

Request a certificate for administrator

Example:

Retrieve the NTLM hash of administrator

Example:

Mitigation

1. Open Certification Authority (certsrv) on your Windows server.

2. Expand CA name and right click the Certificate Templates

3. Select Manage from the context menu.

4. In the Certificate Templates Console window, double-click the Certificate Template.

5. In the Properties window, navigate to the Security tab.

6. In the Security Settings window, locate and select the relevant Access Control Entry (ACE) for the user or group you wish to configure.

7. In the permissions list, locate and remove the Write permission from unauthorized users.

8. Click OK to save your changes and close the dialogs.

Detection

Adding new Access Control Entries on the Active Directory objects changes the ntSecurityDescriptor attribute of the objects themselves. These changes can be detected with the 5136 and 4662 Event IDs to identify unauthorized modifications.

Event ID
Description
Fields/Attributes
References

5136

A directory service object was modified.

ntSecurityDescriptor

https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-5136

4662

An operation was performed on an object.

AccessList, AccessMask

https://learn.microsoft.com/en-us/windows/security/threat-protection/auditing/event-4662

4886

Certificate Services received a certificate request.

CertificateTemplate, Requester

https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn319076(v=ws.11)

4887

Certificate Services approved a certificate request and issued a certificate.

CertificateTemplate, Requester

https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn319076(v=ws.11)

References

Manage AD certificates in devices | CyberArk Docs

Configure Certificate Auto-Enrollment for Network Policy Server | Microsoft Learn

Access controls | The Hacker Recipes

Last updated

Was this helpful?