Detection rules › Kusto
Certified Pre-Owned - backup of CA private key - rule 1
This query identifies someone that performs a read operation of they CA key from the file.
MITRE ATT&CK coverage
| Tactic | Techniques |
|---|---|
| Stealth | T1036 Masquerading |
Event coverage
| Provider | Event | Title |
|---|---|---|
| Security-Auditing | Event ID 5058 | Key file operation. |
Rule body kusto
id: aa5eaac7-1264-4833-b620-8f062be75541
name: Certified Pre-Owned - backup of CA private key - rule 1
description: |
This query identifies someone that performs a read operation of they CA key from the file.
severity: Medium
status: Available
requiredDataConnectors:
- connectorId: SecurityEvents
dataTypes:
- SecurityEvent
- connectorId: WindowsSecurityEvents
dataTypes:
- SecurityEvent
queryFrequency: 1h
queryPeriod: 1h
triggerOperator: gt
triggerThreshold: 0
tactics:
- DefenseEvasion
relevantTechniques:
- T1036
query: |
SecurityEvent
// Fill in the machine name of your CA.
| where EventID == 5058 and Computer contains "<YOUR CA MACHINE NAME>"
| where EventData contains "%%2499" // Machine key.
| extend EventData=parse_xml(EventData)
| mv-apply d=EventData.EventData.Data on
(
where d["@Name"]=="KeyName"
| project KeyName=tostring(d["#text"])
)
| mv-apply d=EventData.EventData.Data on
(
where d["@Name"]=="SubjectUserName"
| project SubjectUserName=tostring(d["#text"])
)
| mv-apply d=EventData.EventData.Data on
(
where d["@Name"]=="Operation"
| project Operation=tostring(d["#text"])
)
| extend Operation=iff(Operation == "%%2458", "Read persisted key from file", Operation)
// This one is a guess and very poorly documented :(
| extend Operation=iff(Operation == "%%2459", "Write persisted key to file", Operation)
// Fill in the keyname of the CA key.
| where KeyName == "<INSERT ISSUING CA KEY HERE>" // Or any other key you want to monitor.
entityMappings:
- entityType: Host
fieldMappings:
- identifier: FullName
columnName: Computer
version: 1.0.1
kind: Scheduled
Stages and Predicates
Stage 1: source
SecurityEvent
Stage 2: where
| where EventID == 5058 and Computer contains "<YOUR CA MACHINE NAME>"
Stage 3: where
| where EventData contains "%%2499"
Stage 4: extend
| extend EventData=parse_xml(EventData)
Stage 5: kusto:mv-apply
| mv-apply d=EventData.EventData.Data on
(
where d["@Name"]=="KeyName"
| project KeyName=tostring(d["#text"])
)
Stage 6: kusto:mv-apply
| mv-apply d=EventData.EventData.Data on
(
where d["@Name"]=="SubjectUserName"
| project SubjectUserName=tostring(d["#text"])
)
Stage 7: kusto:mv-apply
| mv-apply d=EventData.EventData.Data on
(
where d["@Name"]=="Operation"
| project Operation=tostring(d["#text"])
)
Stage 8: extend
| extend Operation=iff(Operation == "%%2458", "Read persisted key from file", Operation)
Operation =Operation == "%%2458""Read persisted key from file"OperationStage 9: extend
| extend Operation=iff(Operation == "%%2459", "Write persisted key to file", Operation)
Operation =Operation == "%%2459""Write persisted key to file"OperationStage 10: where
| where KeyName == "<INSERT ISSUING CA KEY HERE>"
Indicators
Each row is a field, operator, and value that the rule matches. The corpus column counts how many other rules in the catalog look for the same combination: high numbers point to widely-used, community-vetted indicators. Blank or 1 shows that the indicator is specific to this rule.
Output fields
Fields the rule emits when it matches. Chronicle authors list these in the outcome block; they appear on the detection and $risk_score drives alerting. Sentinel / Defender XDR rules build them up through project / summarize / extend stages. Sentinel maps these into alert fields via entityMappings and customDetails; Defender XDR custom detections surface them as alert fields directly.
| Field | Source |
|---|---|
EventData | extend |
Operation | extend |