WriteCertificateTemplates
WriteCertificateTemplates
Summary
FSProtect ACL Alias
WriteCertificateTemplates
AD Alias
Write
Affected Object Types
Certification Authorities
Exploitation Certainty
Certain
AD Right
WriteProperty
AD Permission Guid
2a39c5b1-8960-11d1-aebc-0000f80367c1
Description
The WriteCertificateTemplates permission in Active Directory grants a user or group the ability to modify the certificateTemplates attribute on a Certification Authority (CA) object. This permission effectively allows the holder to add, remove, or alter references to certificate templates associated with the CA. By doing so, the user can publish new or previously unpublished certificate templates, potentially enabling the issuance of certificates based on templates that were not intended for deployment — which may lead to privilege escalation or unauthorized certificate enrollment if abused.
However, if misconfigured, the WriteCertificateTemplates permission can pose security risks. An attacker with this right can publish previously unpublished or unauthorized certificate templates, allowing the CA to issue certificates that enable privilege escalation or unauthorized access within the environment.
Identification
PowerShell
Active Directory Module
Using the ActiveDirectory PowerShell module, you can enumerate WriteCertificateTemplates entries.
1. Find-WriteCertificateTemplates function
2. Scan all templates
.NET Directory Services
By leveraging PowerShell’s built-in .NET DirectoryServices namespace, you can enumerate WriteCertificateTemplates entries without relying on any external modules or dependencies.
1. Find-WriteCertificateTemplatesSimple function
2. Scan all templates
Active Directory Service Interfaces
1. Open Active Directory Service Interfaces (adsi) on your Windows server.
2. Connect to the configuration
3. Select Services then Public Key Services then Enrollment Servcies then the desired CA
4. In the Properties window, navigate to the Security tab.
5. In the Security Settings window, locate and select the relevant Access Control Entry (ACE) for the user or group you wish to configure.
6. In the permissions list, locate and check the option Write certificateTemplates.
7. 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
Publishing by default unpulished template SubCA
Example:

Linux
Get writeCertifiactes value
Example:
Publishing by default unpulished template SubCA
Example:

Mitigation
1. Open Active Directory Service Interfaces (adsi) on your Windows server.
2. Connect to the configuration
3. Select Services then Public Key Services then Enrollment Servcies then the desired CA
4. In the Properties window, navigate to the Security tab.
5. In the Security Settings window, locate and select the relevant Access Control Entry (ACE) for the user or group you wish to configure.
6. In the permissions list, locate and remove the Write certificateTemplates permission from unauthorized users.
7. Click OK to save your changes and close the dialogs.
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.
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
Last updated
Was this helpful?