1. Resources
  2. Identity Threats
  3. Active Directory

AD CS ESC12: CA Key on YubiHSM with Stored Auth Key

Also known as: ESC12, YubiHSM2 CA key abuse, AuthKeysetPassword, Shell access to AD CS CA with YubiHSM

A user with an unprivileged shell on a CA server whose key sits in a YubiHSM2 binds the CA certificate to the HSM key in their own store and signs certificates the CA never records.

Platform
Active Directory
Impact
Critical
Last updated
Attack difficulty
High
Detection difficulty
High
Privileges required: Specific rights or roles
An interactive or remote shell on the CA server as any user, including a non-administrator. The CA must keep its key in a YubiHSM2 through the YubiHSM Key Storage Provider.
What the attacker gains
Use of the CA's signing key from an ordinary user session: forged certificates for any account that the CA database, its events and its revocation list know nothing about.
Threat groups
APT29NIMBUS MANTICOREAPT32RedCurlVOID MANTICOREGroups that MITRE ATT&CK records using T1649, T1552.002.

How it works

A hardware security module keeps the CA's private key off the server's disk. The Yubico YubiHSM2 is a small USB device used for this with Active Directory Certificate Services; it is plugged into the CA server, or attached through a USB device server when the CA is a virtual machine. Windows reaches it through the YubiHSM Key Storage Provider.

Hans-Joachim Knobloch, who named ESC12 in 2023, described two properties of that provider that together undo much of the protection:

  • To generate and use keys, the provider needs an authentication key for the HSM. It is stored in the registry under HKEY_LOCAL_MACHINE\SOFTWARE\Yubico\YubiHSM\AuthKeysetPassword, in clear text.
  • The provider does not check which user account the calling process runs as.

So on the CA server, any process can ask the provider to use the keys in the HSM, and the provider authenticates to the device on its behalf. A user who can run commands on the CA server, even without administrative rights, can therefore use the CA's signing key. They do not need the CA service, and the CA service does not see what they sign.

The research gives two routes:

  1. Sign on the CA server. The attacker imports the public CA certificate into their own user certificate store, links it to the private key in the HSM, and then signs certificates with it using built-in tools.
  2. Move the HSM. If the YubiHSM2 is attached through a USB device server that the attacker can administer, they connect the device to a machine of their own and configure the AuthKeysetPassword value there, which they read from the CA server's registry locally or remotely. This usually disconnects the HSM from the CA, which stops issuing certificates and CRLs.

A certificate signed this way is a forged certificate in the sense of a Golden Certificate: it chains to a CA that domain controllers trust for logon, and it never passed through the CA's policy module, database or audit log.

Prerequisites

  • An enterprise CA whose key is held in a YubiHSM2 and used through the YubiHSM Key Storage Provider.
  • The ability to run commands on the CA server as any user: an interactive logon, a remote shell, or code execution in a service running there. For the second route, administrative access to the USB device server and read access to the registry value.
  • The CA certificate as a file. It is public and can be read from the directory or from any domain member.
  • For use as a logon credential: the CA's certificate in the NTAuth store, which is the case for an enterprise CA.

Attack steps

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

1. Confirm how the CA stores its key

On the CA server, the provider name of the CA's key shows in the CA configuration, and the stored authentication key can be read unless access to the value was restricted:

certutil -getreg CA\CSP\Provider
reg query HKLM\SOFTWARE\Yubico\YubiHSM /v AuthKeysetPassword

2. Obtain the CA certificate

Any domain member can export the CA certificate from the directory. On the CA server it is also in the machine's certificate stores:

certutil -config "SRV01.corp.example.com\CORP-CA" -ca.cert corp-ca.cer

3. Bind the certificate to the HSM key in the user store

As the unprivileged user on the CA server, import the certificate into the user's personal store and let certutil associate it with the private key held by the provider:

certutil -addstore -user my corp-ca.cer
certutil -csp "YubiHSM Key Storage Provider" -repairstore -user my "CORP-CA"

After the second command, the user's own certificate store holds the CA certificate with a usable private key reference. Windows now treats the user as the owner of a CA signing certificate.

4. Sign a certificate

The research uses certutil -sign, which re-signs a certificate or CRL with a signing certificate chosen from the store. The attacker takes an existing certificate as a base, changes the fields that matter (subject, subject alternative name, serial number, validity, extensions) and signs the result with the bound CA certificate. For a logon certificate under strong certificate mapping the forged certificate needs the target's SID in the security extension, or a strong explicit mapping on the target account.

5. Authenticate with the forged certificate

Once the forged certificate and its key are in a PFX file, it is used like any other logon certificate, from any host:

certipy auth -pfx 'administrator_forged.pfx' -dc-ip 192.0.2.10
Rubeus.exe asktgt /user:Administrator /certificate:administrator_forged.pfx /ptt

Impact

Whoever can sign with an enterprise CA's key can produce a logon certificate for any user or computer in the forest that trusts the CA, which makes this a privilege escalation from a shell on one server to control of the domain. The HSM was bought to prevent exactly this, and the organization usually believes the key is safe.

The forged certificates are harder to deal with than issued ones. The CA has no row for them, wrote no event, and sent no notification. If the forger gives the certificate a new serial number, the CA cannot revoke it until someone finds the certificate and imports it into the CA database. Ending the exposure means rotating the HSM authentication key and, if misuse cannot be ruled out, replacing the CA key and certificate.

OPSEC and artifacts

  • No CA events. An operator on this path never talks to the CA service. There is no event 4887, no database row, no entry from an exit module. The absence is the main property of the attack and the reason its detection difficulty is high.
  • A logon to the CA server. The operator needs a session on the server. A logon by an account that is not a PKI administrator, recorded as event 4624, is often the only reliable early signal.
  • certutil with unusual arguments. With command line auditing, event 4688 shows certutil run by a normal user with -repairstore -user and the provider name, and later with -sign. Renaming the binary does not remove the arguments.
  • A CA certificate in a user store. The binding leaves the CA certificate, with a private key reference to the YubiHSM provider, in the personal store of a user profile on the CA server. It stays there until removed.
  • Moving the HSM is loud. On the second route the CA loses its key and fails to issue certificates and CRLs, which service monitoring notices.
  • Use of the forged certificate. Event 4768 on the domain controller records the certificate sign-in with the CA as issuer and a serial number that the CA database does not contain.

Detection

  • Who logs on to the CA. Alert on any interactive, remote interactive or network logon to a CA server by an account outside the PKI administration group, and on new services, scheduled tasks or remote shells there.
  • Command lines on the CA. certutil with -repairstore, -csp or -sign, and registry reads of the Yubico key by processes other than the CA service.
  • Certificate sign-ins with no issuance record. Join 4768 events that carry a certificate serial number against the serial numbers in the CA database or in 4887 events. A certificate that names your CA as issuer and that the CA never issued is forged. Check log retention and every CA with that issuer name before concluding.
  • Key export attempts. The CA private key export rules cover backup and export of CA keys held in software. They stay useful on an HSM-backed CA as a sign of someone probing the key, but the ESC12 path itself does not trigger them.
// certutil used to bind or sign with a store certificate on CA servers
SecurityEvent
| where EventID == 4688
| where Computer has_any ("SRV01")   // CA servers
| where Process =~ "certutil.exe"
| where CommandLine has_any ("-repairstore", "-sign", "YubiHSM")
| project TimeGenerated, Computer, Account, CommandLine, ParentProcessName

The query needs process creation auditing with command line capture on the CA servers.

Mitigation

  • Limit access to the CA server. Only PKI administrators should be able to log on, locally or over the network. This is the control the original research puts first, and it applies to every CA regardless of where its key is. The Active Directory hardening guide treats the CA as a Tier 0 system next to the domain controllers.
  • Restrict the registry value. Remove read access for ordinary users from HKLM\SOFTWARE\Yubico\YubiHSM\AuthKeysetPassword. The research notes this as a way to stop the value being copied to another machine. Treat the value as a Tier 0 secret and keep it out of backups, images and documentation.
  • Protect the USB device server. Its administration interface decides which machine the HSM is attached to. Give it the same protection as the CA.
  • Keep nothing else on the CA server. No web applications, agents with remote command features, or shared service accounts whose compromise would give a shell there.
  • Monitor for the absence of records. Reconcile certificate sign-ins against the CA database on a schedule, because the CA's own audit trail cannot show this attack.
  • Ask the HSM vendor how the provider authorizes callers, and prefer a configuration in which the calling account matters.
  • After suspected misuse, rotate the HSM authentication key. If signing by an unauthorized user cannot be excluded, plan the replacement of the CA key and certificate and the removal of the old certificate from the NTAuth store.

Detection rules for this attack

Log events to collect

FAQ

Does ESC12 mean the CA key can be extracted from the HSM?

No. The key stays inside the YubiHSM2. What the attacker gains is the ability to ask the HSM to sign with it, from their own user session on the CA server. For forging certificates that is enough: a signature made by the real key is valid whether or not the key ever left the device.

Why can a non-administrator use the CA's key?

Two properties of the YubiHSM Key Storage Provider, as the original research describes them. The authentication key the provider uses to talk to the HSM is stored in clear text in the registry value HKLM\SOFTWARE\Yubico\YubiHSM\AuthKeysetPassword, and the provider does not check which user account is calling it.

Do other HSMs have the same problem?

The research covers the YubiHSM2 only. Its author notes that some other HSMs use a key storage provider that is aware of the calling account and are not open to this, and that he could not test every brand. Any HSM whose unlock secret sits on the CA server's disk deserves the same review.

Can tools such as Certipy find ESC12?

No. The condition is a registry value and a provider on the CA server, not a directory setting, so remote enumeration does not see it. Certipy's documentation states that it neither detects nor exploits ESC12. It is found by checking how the CA stores its key and who can log on to the server.

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.