When it is written
Windows writes 5059 when a cryptographic key is exported or imported through a CNG key storage provider (KSP), if Audit Other System Events is on. Microsoft says it is written only for two providers: the Microsoft Software Key Storage Provider and the Microsoft Smart Card Key Storage Provider. A key held by any other provider writes no 5059.
A successful operation has Return Code 0x0; a failed one is an Audit Failure event with the error code. Microsoft notes that the export operation is written not only on a real export, such as exporting a certificate with its private key, but also when a key is simply read for use.
How to turn it on
Advanced audit policy subcategory Audit Other System Events, Success and Failure. Set it in a Group Policy object linked to the computers that write the event:
Computer Configuration > Policies > Windows Settings > Security Settings > Advanced Audit Policy Configuration > Audit Policies > System > Audit Other System Events| Computer | Audit | Note |
|---|---|---|
| Domain controllers | Success and Failure | Recommended in both baselines, for the start, stop and failure events of the Windows Firewall service and driver. |
| Member servers | Success and Failure | Recommended in both baselines, for the start, stop and failure events of the Windows Firewall service and driver. |
| Workstations | Success and Failure | Recommended in both baselines, for the start, stop and failure events of the Windows Firewall service and driver. |
auditpol /get /subcategory:"Other System Events"auditpol /set /subcategory:"Other System Events" /success:enable /failure:enableauditpol /get /subcategory:"{0CCE9214-69AE-11D9-BED3-505054503030}"Run the commands in an elevated prompt on a computer that writes the event. Subcategory settings take effect only when the security option Audit: Force audit policy subcategory settings (Windows Vista or later) to override audit policy category settings is enabled (the default), and a Group Policy object that sets advanced audit policy replaces local changes at its next refresh. Microsoft's advanced audit policy reference
The subcategory is not enough on its own. Microsoft documents 5059 only for keys held by the Microsoft Software Key Storage Provider or the Microsoft Smart Card Key Storage Provider. Check which provider holds the private key of each CA (it is chosen when the CA is set up): a key held by a hardware security module's own provider, or by an older CryptoAPI provider, writes no 5059, and the rule cannot see an export of it.
To find the key container of the CA certificate, look at the certificates in the computer's personal store: Microsoft's event page shows certutil -store output, where the Key Container line gives the name that appears in KeyName.
Fields
In Event Viewer order. The field names are those of the event XML, from the event template that ships with Windows.
| Field | What it holds | Since |
|---|---|---|
Security IDSubjectUserSidSubjectRead by 1 rule | SID of the account that asked for the operation. Event Viewer shows it resolved to an account name when it can. The rule leaves out S-1-5-18, S-1-5-19 and S-1-5-20. | v0 |
Account NameSubjectUserNameSubject | Name of that account. For Local System it is the computer account, a name that ends with $. | v0 |
Account DomainSubjectDomainNameSubject | Domain of the account, usually as a NetBIOS name, the computer name for a local account, or NT AUTHORITY for well-known principals. | v0 |
Logon IDSubjectLogonIdSubject | Hexadecimal ID of the account's logon session. It matches the Logon ID of the 4624 event on the same computer. | v0 |
Process IDClientProcessIdProcess Information | ID of the process behind the operation, in decimal (shown as Process ID). Not documented by Microsoft. Version 1. | v1 |
Process Creation TimeClientCreationTimeProcess Information | Start time of that process (shown as Process Creation Time). With the process ID it identifies one run of the process. Not documented by Microsoft. Version 1. | v1 |
Provider NameProviderNameCryptographic Parameters | Key storage provider that performed the operation. Microsoft lists Microsoft Software Key Storage Provider and Microsoft Smart Card Key Storage Provider. | v0 |
Algorithm NameAlgorithmNameCryptographic Parameters | Algorithm of the key, for example RSA, DSA, DH, or an ECDH or ECDSA curve such as ECDSA_P256, ECDSA_P384 or ECDSA_P521. | v0 |
Key NameKeyNameCryptographic Parameters | Name of the key container the operation used. Compare it with the key container of the CA certificate to know whether the CA key was involved. | v0 |
Key TypeKeyTypeCryptographic Parameters | Whether the key belongs to a user or to the computer, as a message code. %%2500 user key, %%2499 machine key. | v0 |
OperationAdditional InformationRead by 1 rule | Operation performed, as a message code. %%2464 export of a persistent key (also written for plain reads), %%2465 import of a persistent key. The rule matches %%2464 and its text. | v0 |
Return CodeReturnCodeAdditional Information | Result in hexadecimal. 0x0 on success, otherwise the error code of the failure. | v0 |
Event versions
The template has two versions. Version 0 is the one Microsoft's event page documents. Version 1 adds ClientProcessId and ClientCreationTime, the process behind the operation and its start time, shown in Event Viewer as Process ID and Process Creation Time. Microsoft does not document version 1.
- Version 0: 10 fields
- Version 1: 12 fields, adds
ClientProcessId,ClientCreationTime
Values to know
Operation
| Value | Meaning | Signal |
|---|---|---|
%%2464 | Export of persistent cryptographic keyWhat the rule matches, by code or by its text. On a CA server, by a named account and for the CA's key container, it is a backup or a copy of the CA private key. Also written when a key is only read. | Attack signal |
%%2465 | Import of persistent cryptographic keyA key was imported, for example a certificate with its private key. | Worth knowing |
Security ID SubjectUserSid
| Value | Meaning | Signal |
|---|---|---|
S-1-5-18, S-1-5-19 or S-1-5-20 | Local System, Local Service or Network ServiceServices reading their own keys. Left out by the rule. | Noise |
Any other SID | A named accountOn a CA server, compare KeyName with the CA's key container. A match is a high-severity finding unless a planned backup explains it. | Attack signal |
Key Type KeyType
| Value | Meaning | Signal |
|---|---|---|
%%2499 | Machine keyA key stored for the computer rather than for a user. | Worth knowing |
%%2500 | User keyA key stored in a user's profile. | Worth knowing |
Return Code ReturnCode
| Value | Meaning | Signal |
|---|---|---|
0x0 | Success | Expected |
Any other value | The operation failedWritten as an Audit Failure event with the error code. | Failure |
Volume and noise
Microsoft rates Audit Other System Events Low; most of the subcategory is the start and stop events of the Windows Firewall service and driver. The volume of 5059 depends on how often software uses keys held by the two providers: because a plain key read is logged as an export, services that use certificates with keys in the Microsoft Software Key Storage Provider can write it routinely, usually as Local System, Local Service or Network Service.
Keeping it manageable
- On certification authority servers keep every 5059: the rule reads
OperationandSubjectUserSid, andKeyNameis what tells the CA key from the others. - The rule leaves out Local System, Local Service and Network Service (
S-1-5-18,S-1-5-19,S-1-5-20), whose key reads are logged as exports. Dropping the same accounts at collection is safe for the rule. - Once you know the key containers of the other certificates on a CA server, you can exclude them by
KeyName; never exclude the container of the CA certificate itself. - The rule is meant for CA servers only. Elsewhere, collect 5059 for your own key monitoring if you need it.
Sample event
Version 1, with made-up values.
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Microsoft-Windows-Security-Auditing" Guid="{54849625-5478-4994-a5ba-3e3b0328c30d}" />
<EventID>5059</EventID>
<Version>1</Version>
<Level>0</Level>
<Task>12292</Task>
<Opcode>0</Opcode>
<Keywords>0x8020000000000000</Keywords>
<TimeCreated SystemTime="2026-11-18T09:30:12.4567890Z" />
<EventRecordID>1048576</EventRecordID>
<Correlation />
<Execution ProcessID="712" ThreadID="2408" />
<Channel>Security</Channel>
<Computer>CA01.corp.example.com</Computer>
<Security />
</System>
<EventData>
<Data Name="SubjectUserSid">S-1-5-21-1004336348-1177238915-682003330-1104</Data>
<Data Name="SubjectUserName">alice</Data>
<Data Name="SubjectDomainName">CORP</Data>
<Data Name="SubjectLogonId">0x5d3a41</Data>
<Data Name="ClientProcessId">6204</Data>
<Data Name="ClientCreationTime">2026-11-18T09:29:58.1234567Z</Data>
<Data Name="ProviderName">Microsoft Software Key Storage Provider</Data>
<Data Name="AlgorithmName">RSA</Data>
<Data Name="KeyName">CORP-ISSUING-CA</Data>
<Data Name="KeyType">%%2499</Data>
<Data Name="Operation">%%2464</Data>
<Data Name="ReturnCode">0x0</Data>
</EventData>
</Event>Attacks this event reveals
Detection rules that read this event:
Frequently asked questions
Why does event 5059 say Export when nobody exported a key?
Microsoft notes that the operation Export of persistent cryptographic key is typically written when a key is read for use, and also on real exports such as exporting a certificate with its private key. That is why the rule leaves out the built-in service accounts and asks you to compare KeyName with the CA's key container.
Why do I see no 5059 for my CA's private key?
Either Audit Other System Events is not on for the CA server, or the CA key is not held by the Microsoft Software or Smart Card Key Storage Provider. Microsoft documents the event for those two providers only, so a key in a hardware security module's provider or in an older CryptoAPI provider writes none.
How do I tell whether a 5059 event concerns the CA key?
Compare KeyName with the key container of the CA certificate, which certutil shows as Key Container for the certificates in the computer's personal store. An export of that container by a named account is a backup or a copy of the CA private key.
Is an export of the CA key always an attack?
No. A planned CA backup exports the key too. Check for a change record and for a Certificate Services backup event (4876) around the same time; an export with neither deserves an immediate look, since whoever holds the CA key can issue certificates the domain trusts.