How the attack works
A certification authority signs every certificate it issues with its private key. Active Directory accepts a certificate for logon when it was issued by a CA that is published in the NTAuth store of the forest, which every enterprise CA is by default. Whoever holds the private key of such a CA can therefore sign certificates for any account, including domain administrators and domain controllers, on a machine of their own. Those forged certificates never pass through the CA. They are not in its database and match none of its request events, and resetting the password of the account they name does not invalidate them.
Unless a hardware security module holds the key, it is stored on the CA computer, and an administrator of that computer can back it up. This is a supported operation. The backup function of the CA and the Backup-CARoleService cmdlet write the CA certificate and its private key to a PKCS #12 file, and an attacker with the same rights uses the same path or exports the key from the certificate store of the computer.
Two kinds of events on the CA server show it. With Audit Other System Events enabled, Windows logs 5059 (key migration operation) when a key is exported or imported through the Microsoft Software Key Storage Provider, with the account, the key name and the operation, and 5058 (key file operation) when the key file is read. With Audit Certification Services enabled and the category "Back up and restore the CA database" selected in the CA's audit filter, the CA logs 4876 when a backup starts. Both have limits. Microsoft notes that 5059 with an export operation is also written when a key is only read for use, the two key events exist only for keys held by the Microsoft software or smart card key storage providers, and a key that is taken without going through the provider leaves neither. A CA that archives keys also holds the private keys of its subscribers' certificates, protected for its key recovery agents. A further rule reads event 4883, which the CA writes when one of those archived keys is retrieved from its database.
What an attacker needs
- Administrative access to the CA server. Microsoft's backup procedures ask for local administrator credentials on the CA computer or for a CA administrator account.
- A CA whose private key is stored on the CA computer and not in a hardware security module.
Impact
The ability to forge certificates for any account in the forest without contacting the CA again, for as long as the CA certificate is trusted. Microsoft describes the result as forged authentication certificates, impersonation of privileged identities and persistent access. It survives password resets and the removal of every account the attacker used. Recovery means revoking and replacing the CA certificate and key, which also invalidates every certificate the CA has legitimately issued.
Detection rules
Archived Private Key Retrieved From the CA Database
Detects event 4883 (Certificate Services retrieved an archived key) on an AD CS certification authority. A CA that is configured for key archival keeps the private keys of the certificates it issued from archival templates in its database, protected for its key recovery agents. Retrieving one is the first step of a key recovery, and whoever also controls a key recovery agent certificate obtains the private key of another person's certificate. Microsoft rates the event as medium. Key recovery is a rare, ticketed operation in most organizations, so one event is worth matching to a request. The rule matches on the event ID alone, because Microsoft documents the content of the event (the Request ID of the certificate) as message text and not as a named field, so the level is one step lower. Logged in the Security log of the CA server. Requires Audit Certification Services and the "Store and retrieve archived keys" category in the CA's audit filter.
title: Archived Private Key Retrieved From the CA Database
id: 8f5ad926-eaf5-4c41-a8e3-ea7301b602ff
status: experimental
description: >-
Detects event 4883 (Certificate Services retrieved an archived key) on an AD
CS certification authority. A CA that is configured for key archival keeps
the private keys of the certificates it issued from archival templates in
its database, protected for its key recovery agents. Retrieving one is the
first step of a key recovery, and whoever also controls a key recovery agent
certificate obtains the private key of another person's certificate.
Microsoft rates the event as medium. Key recovery is a rare, ticketed
operation in most organizations, so one event is worth matching to a
request. The rule matches on the event ID alone, because Microsoft documents
the content of the event (the Request ID of the certificate) as message text
and not as a named field, so the level is one step lower. Logged in the
Security log of the CA server. Requires Audit Certification Services and the
"Store and retrieve archived keys" category in the CA's audit filter.
references:
- 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-18
tags:
- attack.credential-access
- attack.t1649
logsource:
product: windows
service: security
detection:
selection:
EventID: 4883
condition: selection
falsepositives:
- A planned key recovery for a user who lost a certificate, usually an encryption certificate. Match the event to the recovery request and to the certificate named by the request ID.
level: medium
False positives
- A planned key recovery for a user who lost a certificate, usually an encryption certificate. Match the event to the recovery request and to the certificate named by the request ID.
Certification Authority Backup Started
Detects event 4876 (Certificate Services backup started) on an AD CS certification authority. The backup function of a CA can include the CA certificate and its private key, and a copy of that key lets its holder forge certificates for any account. A backup is routine when it is planned, so the event is a low-level signal to compare with the backup schedule and with the account that was logged on to the CA server. Microsoft documents the event text with the backup type and no field names, so the rule matches on the event ID. Logged in the Security log of the CA server. Requires Audit Certification Services and the "Back up and restore the CA database" category in the CA's audit filter.
title: Certification Authority Backup Started
id: e2c29527-7221-4654-9ffa-40829caea077
status: experimental
description: >-
Detects event 4876 (Certificate Services backup started) on an AD CS
certification authority. The backup function of a CA can include the CA
certificate and its private key, and a copy of that key lets its holder
forge certificates for any account. A backup is routine when it is planned,
so the event is a low-level signal to compare with the backup schedule and
with the account that was logged on to the CA server. Microsoft documents
the event text with the backup type and no field names, so the rule matches
on the event ID. Logged in the Security log of the CA server. Requires Audit
Certification Services and the "Back up and restore the CA database"
category in the CA's audit filter.
references:
- https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/audit-certification-services
- 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/powershell/module/adcsadministration/backup-caroleservice
- 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: 4876
condition: selection
falsepositives:
- Scheduled and manual CA backups by PKI administrators and by backup software, and backups taken before a migration or a change to the CA. Baseline the schedule and the accounts, and review the backups that fall outside it.
level: low
False positives
- Scheduled and manual CA backups by PKI administrators and by backup software, and backups taken before a migration or a change to the CA. Baseline the schedule and the accounts, and review the backups that fall outside it.
Private Key Export Operation by a Named Account on a CA Server
Detects event 5059 (key migration operation) with the operation "Export of persistent cryptographic key" by an account other than the built-in service accounts. On a certification authority server this is what a backup or an export of the CA private key through the Microsoft Software Key Storage Provider leaves in the Security log. Microsoft documents that the export operation is also written when a key is only read for use, which is why Local System, Local Service and Network Service are left out, and that the event exists only for keys held by the Microsoft Software or Smart Card Key Storage Provider. The rule cannot know which key belongs to the CA. Apply it to the Security log of CA servers and compare KeyName with the key container of the CA certificate. A match on that key is a high-severity finding. Requires Audit Other System Events on the CA server.
title: Private Key Export Operation by a Named Account on a CA Server
id: 1573adfe-5ba1-4ad6-bbc7-d8a9485e2816
status: experimental
description: >-
Detects event 5059 (key migration operation) with the operation "Export of
persistent cryptographic key" by an account other than the built-in service
accounts. On a certification authority server this is what a backup or an
export of the CA private key through the Microsoft Software Key Storage
Provider leaves in the Security log. Microsoft documents that the export
operation is also written when a key is only read for use, which is why
Local System, Local Service and Network Service are left out, and that the
event exists only for keys held by the Microsoft Software or Smart Card Key
Storage Provider. The rule cannot know which key belongs to the CA. Apply it
to the Security log of CA servers and compare KeyName with the key container
of the CA certificate. A match on that key is a high-severity finding.
Requires Audit Other System Events on the CA server.
references:
- https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/event-5059
- https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-10/security/threat-protection/auditing/audit-other-system-events
- 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/windows-server/identity/ad-ds/manage/understand-security-identifiers
- 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: 5059
Operation:
- '%%2464'
- 'Export of persistent cryptographic key.'
filter_service_accounts:
SubjectUserSid:
- 'S-1-5-18'
- 'S-1-5-19'
- 'S-1-5-20'
condition: selection and not filter_service_accounts
falsepositives:
- A planned CA backup or migration that includes the private key, and the renewal of the CA certificate. Match the event to the change record and to the person who was assigned the work.
- An administrator who exports another certificate with its private key on the same server, or software that reads a key under a named service account. Compare KeyName with the key container of the CA certificate and exclude the other keys by exact KeyName.
- The filter removes every operation by Local System, Local Service and Network Service, including one started by an attacker who runs a process as Local System. Once you know which keys the server reads in normal operation, replace the filter with exclusions by KeyName.
level: medium
False positives
- A planned CA backup or migration that includes the private key, and the renewal of the CA certificate. Match the event to the change record and to the person who was assigned the work.
- An administrator who exports another certificate with its private key on the same server, or software that reads a key under a named service account. Compare KeyName with the key container of the CA certificate and exclude the other keys by exact KeyName.
- The filter removes every operation by Local System, Local Service and Network Service, including one started by an attacker who runs a process as Local System. Once you know which keys the server reads in normal operation, replace the filter with exclusions by KeyName.
Detection logic
Patterns that need more than one event, a baseline or knowledge of your own environment. Each is a hypothesis to build and tune in your SIEM, not a ready rule.
Certificate sign-in with a serial number that the named CA never issued
A certificate signed with a stolen CA key never passes through the CA, so it is in no CA database and matches no issuance event. Domain controllers record the issuer and the serial number of every certificate used to obtain a ticket-granting ticket. A serial number of which the named CA has no record points to a certificate made outside the CA, whatever account it names.
- Export on a schedule the serial numbers of the certificates each enterprise CA has issued, from its database, with the CA name as it appears in the Issued by field of its certificates.
- Find event 4768 with result code 0x0 in which
CertIssuerNamenames one of those CAs andCertSerialNumberis filled in. - Look up
CertSerialNumberin the export of that CA. A serial number with no record is the finding. - Read
TargetUserName,TargetSidandIpAddress, and give the highest priority to privileged accounts and the accounts of domain controllers.
Events4768
LimitsCertificates issued after the last export have no record yet, so the export has to be recent. Rows deleted from the CA database (event 4896) leave the same gap and are a finding of their own. Normalise the serial numbers on both sides (spaces, letter case). A certificate used over Schannel leaves no event 4768.
Triage
- Read the account (SubjectUserName, SubjectLogonId), the key (KeyName, ProviderName, AlgorithmName) and the operation. Compare KeyName with the key container of the CA certificate. An export of another key on the server, such as a web server certificate, is a different matter.
- Find the logon session of that account on the CA server (event 4624 with the same logon ID) and where it came from. Was a backup or a migration planned for that time, and by this person?
- Look at the surrounding events, such as a key file read by the same account just before (5058), a CA backup start (4876), and new processes on the server (4688).
- Find out where the exported file went. Check the server for new PKCS
- Check whether the CA's audit filter or the audit policy of the server was changed before the event (4885, 4719).
Response
Once the attack is confirmed:
- Treat the CA key as compromised once an unplanned export is confirmed. Nothing done on the CA server afterwards takes a copied key back.
- Disable the account that made the export, end its sessions, and isolate the CA server and the host the session came from for investigation.
- Revoke the CA certificate at its parent CA and publish a new revocation list. Remove the certificate from the NTAuth store as well, so that it is no longer trusted for logon in the forest.
- Build a replacement CA with a new key, held in a hardware security module where possible, and reissue the certificates that users and services still need.
- Search domain controllers for certificate logons (event 4768 with the certificate issuer and serial number filled in) that name this CA with a serial number its database does not list, and investigate the accounts involved.
- Find out how the account obtained administrative access to the CA server and remove that path.
Mitigation
- Keep CA private keys in a hardware security module, so that the key is not stored on the CA computer and cannot be copied from it.
- Treat CA servers as Tier 0. Limit local administrators, CA administrators and backup operators on them to the PKI team, and administer them only from Tier 0 workstations.
- Keep the root CA offline, so that only the keys of issuing CAs are exposed on the network and a stolen one can be revoked by its parent.
- Store CA backups that contain the private key in an access-controlled location and deliver the password through a separate channel, as Microsoft advises, and delete working copies.
- Run CA backups only as a planned and recorded change, so that any other backup or key export stands out.
- Enable Audit Other System Events and Audit Certification Services on CA servers, select every category in the CA's audit filter, and forward the Security log to a system the CA administrators cannot change.
Frequently asked questions
Why is a stolen CA key worse than a stolen certificate?
A stolen certificate impersonates one account until it expires or is revoked. The private key of the CA signs new certificates, so its holder can create a valid certificate for any account at any time, on a machine of their own. The CA never sees those certificates. They are missing from its database and from its request events, so there is nothing to find and revoke one by one. The remedy is to revoke and replace the CA certificate and its key.
Does event 5059 always mean that the key left the server?
No. Microsoft documents that the export operation of event 5059 is typically written when a key is read for use, and also during a real export such as exporting a certificate with its private key. The rule therefore leaves out operations by the built-in service accounts and reports those of a named account. Read the key name and the account, and look for a backup file or a 4876 event at the same time before you decide.
Which ways of taking the key do these rules not see?
Events 5058 and 5059 are written only for keys held by the Microsoft Software Key Storage Provider or the Microsoft Smart Card Key Storage Provider. A CA key in a legacy cryptographic service provider or in a hardware security module produces neither, and neither does a key that is taken without going through the provider. An operation by a process that runs as Local System is left out by the filter of the rule. Event 4876 covers the backup function of the CA only.
Is a CA backup not a routine operation?
It is, which is why the backup rule has a low level. Microsoft's own procedures back up the CA database and the private key before a migration and before changes to the CA. What matters is whether this backup was planned, who started it and where the files went. A backup outside a change window, by an account that does not normally run it, or to an unusual location deserves the same attention as a key export.
References
- MITRE ATT&CK T1649: Steal or Forge Authentication Certificates
- Event 5059: Key migration operation
- Event 5058: Key file operation
- Audit Other System Events
- Audit Certification Services (events 4868 to 4898)
- Securing PKI: Appendix A: Events to Monitor (CA events and required audit filter)
- Securing PKI: Monitoring Public Key Infrastructure (use of the CA private key outside the CA service)
- What is the Certification Authority role service? (CA private keys and hardware security modules)
- Secure, delegate, and audit certification authority administration (CA backup)
- Backup-CARoleService
- How to import third-party CA certificates into the Enterprise NTAuth store
- Microsoft Defender for Identity alerts (suspicious CA certificate and private key theft)
- Event 4768: A Kerberos authentication ticket (TGT) was requested