1. Resources
  2. Detection rules
  3. Certificate Template Modification (ESC4)

Certificate Template Modification (ESC4) detection rules

An attacker with write access to an AD CS certificate template makes it exploitable, for example by letting enrollees supply the subject, then enrolls as a domain admin. Detected as 5136 writes on pKICertificateTemplate objects.

Platform
Active Directory
Severity
High
Log source
Windows Security event log
Last updated
Rule formats
Sigmaand queries for: SplunkMicrosoft SentinelIBM QRadar
What an attacker needs
Write access to a certificate template that an Enterprise CA publishes, and enrollment rights the attacker has or can grant.
Impact
A certificate that authenticates as any chosen user, including domain administrators and domain controllers, valid until it expires or is revoked and unaffected by password resets.
Response
Unpublish the template or restore its previous settings, disable the account that changed it, and revoke the certificates it issued that name an account other than the requester.
Mitigation
Restrict write, WriteDacl and WriteOwner on templates and on the Certificate Templates container to PKI administrators, and unpublish templates that are not in use.
Event IDs
489949005136

How the attack works

Certificate templates are pKICertificateTemplate objects in CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration. Their attributes decide who the certificate is issued for and what it can be used for: msPKI-Certificate-Name-Flag (whether the enrollee may supply the subject or SAN), msPKI-Enrollment-Flag (for example manager approval), msPKI-RA-Signature (required authorized signatures), and pKIExtendedKeyUsage / msPKI-Certificate-Application-Policy (client authentication and other purposes). The template's security descriptor decides who may enroll and who may edit it.

When a principal that should not manage PKI holds write rights on a template (the ESC4 misconfiguration), it can make the template exploitable: allow an enrollee-supplied subject, add a client authentication purpose, drop manager approval, then grant itself enrollment. It then requests a certificate naming a privileged user and authenticates with it through PKINIT or Schannel. The attacker often restores the original settings afterwards, so the template changes themselves are the durable evidence. With template auditing enabled on the CA, the CA server also logs 4899 (template updated) and 4900 (template security updated) when an enrollment is attempted for a loaded template that was changed. These events hold the old and the new template content and need no SACL in the directory, but they appear at the next enrollment attempt and not at the time of the change.

What an attacker needs

  • Write access to a certificate template (GenericAll, GenericWrite, WriteDacl, WriteOwner, ownership, or write on the template attributes).
  • An Enterprise CA that publishes the template, and enrollment rights the attacker has or can grant.

Impact

A certificate that authenticates as any chosen user, including domain administrators and domain controllers, valid until it expires or is revoked and unaffected by password resets. This is a direct path to domain compromise and persistent access.

Detection rules

Certification Authority Reported a Changed Certificate Template

Detects events 4899 (a Certificate Services template was updated) and 4900 (Certificate Services template security was updated) on an AD CS certification authority. Microsoft documents that the CA writes them when a template it has loaded was changed, in its attributes or in its security permissions, and an enrollment is then attempted for that template. The events hold the old and the new template content, and 4900 also the old and the new security descriptor. Compared with the 5136 rules of this attack they need no SACL on the Certificate Templates container, they are logged on the CA server, and they mark the moment a changed template is used for an enrollment and not the moment it was changed. The documented event text names no account that made the change, and a template that is changed back before anyone enrolls leaves no such event. The CA also logs 4898 when it loads a template, for every template at each start of the service, which is a baseline and not a change. Requires Audit Certification Services, the "Change CA security settings" category in the CA's audit filter and the policy module flag EDITF_AUDITCERTTEMPLATELOAD.

LevelMediumStatusExperimentalLog sourceWindows Security event log
title: Certification Authority Reported a Changed Certificate Template
id: 5c94d100-5b8d-4bc1-ae7e-a089d1476f01
status: experimental
description: >-
  Detects events 4899 (a Certificate Services template was updated) and 4900
  (Certificate Services template security was updated) on an AD CS
  certification authority. Microsoft documents that the CA writes them when a
  template it has loaded was changed, in its attributes or in its security
  permissions, and an enrollment is then attempted for that template. The
  events hold the old and the new template content, and 4900 also the old and
  the new security descriptor. Compared with the 5136 rules of this attack
  they need no SACL on the Certificate Templates container, they are logged
  on the CA server, and they mark the moment a changed template is used for an
  enrollment and not the moment it was changed. The documented event text
  names no account that made the change, and a template that is changed back
  before anyone enrolls leaves no such event. The CA also logs 4898 when it
  loads a template, for every template at each start of the service, which is
  a baseline and not a change. Requires Audit Certification Services, the
  "Change CA security settings" category in the CA's audit filter and the
  policy module flag EDITF_AUDITCERTTEMPLATELOAD.
references:
  - https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn786432(v=ws.11)
  - https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn786423(v=ws.11)
  - https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/audit-certification-services
  - https://attack.mitre.org/techniques/T1649/
author: Forestall
date: 2026-11-16
tags:
  - attack.credential-access
  - attack.t1649
logsource:
  product: windows
  service: security
detection:
  selection:
    EventID:
      - 4899
      - 4900
  condition: selection
falsepositives:
  - Template maintenance by PKI administrators, such as a new version of a template or a change of its enrollment permissions. The event appears at the first enrollment after the change, which can be days later. Compare the old and the new content in the event with the change record.
level: medium

False positives

  • Template maintenance by PKI administrators, such as a new version of a template or a change of its enrollment permissions. The event appears at the first enrollment after the change, which can be days later. Compare the old and the new content in the event with the change record.

Certificate Template Issuance Settings Modified

Detects a change to the attributes of an AD CS certificate template that control subject naming, approval, required signatures and key usage (msPKI-Certificate-Name-Flag, msPKI-Enrollment-Flag, msPKI-RA-Signature, pKIExtendedKeyUsage, msPKI-Certificate-Application-Policy). Editing these is how an ESC4 write right is turned into an exploitable template. Requires Audit Directory Service Changes and a SACL on the Certificate Templates container.

LevelHighStatusExperimentalLog sourceWindows Security event log
title: Certificate Template Issuance Settings Modified
id: 2b980987-d25e-4a42-ad64-b71c9216d6a5
status: experimental
description: >-
  Detects a change to the attributes of an AD CS certificate template that
  control subject naming, approval, required signatures and key usage
  (msPKI-Certificate-Name-Flag, msPKI-Enrollment-Flag, msPKI-RA-Signature,
  pKIExtendedKeyUsage, msPKI-Certificate-Application-Policy). Editing these is
  how an ESC4 write right is turned into an exploitable template. Requires Audit
  Directory Service Changes and a SACL on the Certificate Templates container.
references:
  - https://attack.mitre.org/techniques/T1649/
  - https://learn.microsoft.com/en-us/windows/win32/adschema/c-pkicertificatetemplate
  - https://learn.microsoft.com/en-us/windows/win32/adschema/a-mspki-certificate-name-flag
  - https://learn.microsoft.com/en-us/windows/win32/adschema/a-mspki-enrollment-flag
  - https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-5136
author: Forestall
date: 2026-11-10
tags:
  - attack.credential-access
  - attack.t1649
logsource:
  product: windows
  service: security
detection:
  selection:
    EventID: 5136
    ObjectClass: pKICertificateTemplate
    AttributeLDAPDisplayName:
      - msPKI-Certificate-Name-Flag
      - msPKI-Enrollment-Flag
      - msPKI-RA-Signature
      - pKIExtendedKeyUsage
      - msPKI-Certificate-Application-Policy
    OperationType:
      - '%%14674'
      - 'Value Added'
  condition: selection
falsepositives:
  - Template maintenance by PKI administrators (new versions of a template, changing approval requirements). Validate against change records; avoid excluding administrators wholesale, since their accounts are a common target.
level: high

False positives

  • Template maintenance by PKI administrators (new versions of a template, changing approval requirements). Validate against change records; avoid excluding administrators wholesale, since their accounts are a common target.

Certificate Template Permissions Modified

Detects a change to the nTSecurityDescriptor of an AD CS certificate template, that is a change of who may enroll in, edit or own the template. Attackers use it to grant themselves enrollment or edit rights before abusing the template. Requires Audit Directory Service Changes and a SACL on the Certificate Templates container.

LevelMediumStatusExperimentalLog sourceWindows Security event log
title: Certificate Template Permissions Modified
id: ca47f383-9205-4ede-8cb5-c12c4c566819
status: experimental
description: >-
  Detects a change to the nTSecurityDescriptor of an AD CS certificate template,
  that is a change of who may enroll in, edit or own the template. Attackers use
  it to grant themselves enrollment or edit rights before abusing the template.
  Requires Audit Directory Service Changes and a SACL on the Certificate
  Templates container.
references:
  - https://attack.mitre.org/techniques/T1649/
  - https://learn.microsoft.com/en-us/windows/win32/adschema/c-pkicertificatetemplate
  - https://learn.microsoft.com/en-us/windows/win32/adschema/a-ntsecuritydescriptor
  - https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-5136
author: Forestall
date: 2026-11-10
tags:
  - attack.credential-access
  - attack.t1649
logsource:
  product: windows
  service: security
detection:
  selection:
    EventID: 5136
    ObjectClass: pKICertificateTemplate
    AttributeLDAPDisplayName: nTSecurityDescriptor
    OperationType:
      - '%%14674'
      - 'Value Added'
  condition: selection
falsepositives:
  - PKI administrators granting enrollment to a new group or publishing a new template. Compare the added ACEs with the request; enrollment granted to broad groups (Domain Users, Authenticated Users) on a client authentication template needs follow-up.
level: medium

False positives

  • PKI administrators granting enrollment to a new group or publishing a new template. Compare the added ACEs with the request; enrollment granted to broad groups (Domain Users, Authenticated Users) on a client authentication template needs follow-up.

Triage

  • Identify the template (ObjectDN) and the changed attribute; compare the new value (OperationType "Value Added") with the old one (the "Value Deleted" event with the same OpCorrelationID).
  • Check whether the change enables enrollee-supplied subject names, adds a client authentication or Any Purpose usage, removes approval or signatures, or grants enrollment rights.
  • Confirm the writer (SubjectUserName) is a PKI administrator acting under a change record.
  • On the CA, review certificates issued from the template after the change (4886/4887) for subjects or SANs naming privileged accounts, and revoke any that were not expected.

Response

Once the attack is confirmed:

  1. Unpublish the template from every Enterprise CA, or restore its settings and permissions to the previous values from the "Value Deleted" events, so that nothing more can be enrolled with the changed settings.
  2. Disable the account that changed the template and remove its write access to the template and to the Certificate Templates container.
  3. Revoke the certificates issued from the template between the change and its reversal that name an account other than the requester. Password resets of the named accounts do not invalidate them.
  4. Review the sign-ins of the accounts named in those certificates since they were issued. A certificate for a domain administrator or a domain controller that was used means a domain compromise.
  5. Compare the other published templates with the approved configuration as well, in case the account had write access to more than one.

Mitigation

  • Restrict write, WriteDacl and WriteOwner on templates (and on the Certificate Templates container) to PKI administrators; remove such rights from broad groups.
  • Require manager approval or authorized signatures on templates that allow the enrollee to supply the subject, and avoid that flag on templates with client authentication.
  • Unpublish templates that are not in use from every Enterprise CA.
  • Configure a SACL on the Certificate Templates container that audits writes and permission changes, and enable "Audit Directory Service Changes" on domain controllers.

Frequently asked questions

The template looks correct again. Can the alert be closed?

No. Attackers often restore the original settings after they have enrolled, so the current state of the template proves nothing. The 5136 events are the durable evidence. Use them to find the time in which the template was changed, and review every certificate issued from it in that time.

Which template changes matter most?

Those that let the enrollee supply the subject or SAN, add a client authentication or Any Purpose usage, remove manager approval or required signatures, or grant enrollment or edit rights to a new principal. One of these on a template that already has the others makes it exploitable, so read the new value against the whole template and not alone.

Why do template changes produce no events in our environment?

Event 5136 is written only where a SACL asks for it. The Certificate Templates container in the Configuration partition needs a SACL that audits writes and permission changes, and domain controllers need the audit subcategory Audit Directory Service Changes. Without the SACL a template can be changed and restored without a trace in the Security log.

References

We respect your privacy

We use cookies to keep this site secure and working properly. With your permission, we also use optional cookies to understand usage and improve the experience. Cookie Policy

You can change your choice at any time.