Detect Private Keys in CrowdStrike LogScale
Adversaries may search for private key and certificate files on compromised systems. Private keys (.key, .pem, .pfx, .p12, .ppk, .pgp, .gpg, .asc) are used for authentication, encryption, and digital signatures. SSH private keys enable key-based lateral movement. TLS/SSL private keys enable HTTPS interception. Code signing certificates enable payload signing for defense evasion. PGP keys decrypt archived data. Adversaries including Machete, Kinsing, Hildegard, Mafalda, and various APT groups actively harvest private keys. Mimikatz's CRYPTO::Extract module extracts keys via Windows CNG API. On network devices, 'crypto pki export' extracts PKI credentials.
MITRE ATT&CK
- Tactic
- Credential Access
- Technique
- T1552 Unsecured Credentials
- Sub-technique
- T1552.004 Private Keys
- Canonical reference
- https://attack.mitre.org/techniques/T1552/004/
LogScale Detection Query
// Detection 1: Private key file access by unexpected processes
#event_simpleName IN ("OperationOfInterest", "SuspiciousFileRead", "EndOfProcess")
| #event_simpleName = "OperationOfInterest"
| TargetFileName = /(?i)\.(pem|pfx|p12|ppk|pgp|gpg|asc|key|crt|cer|p7b)$|\/id_(rsa|ecdsa|ed25519|dsa)$/
| ImageFileName != /(?i)(\\ssh\.exe|\\scp\.exe|\\sftp\.exe|\\openssl\.exe|\\putty\.exe|\/ssh$|\/scp$|\/sftp$|\/openssl$|\/gpg$|certbot|nginx|apache|httpd)/
| groupBy([ComputerName, UserName, ImageFileName, TargetFileName], function=count(aid, as=AccessCount))
| sort(AccessCount, order=desc)
// Detection 2: Process search commands targeting private key extensions
| join
(
#event_simpleName = "ProcessRollup2"
| CommandLine = /(?i)\.(pem|pfx|p12|ppk|pgp|gpg|asc|key|id_rsa|id_ecdsa|id_ed25519)/
| CommandLine = /(?i)(\bfind\b|\blocate\b|Get-ChildItem|dir\ \/s|findstr|mimikatz|certutil)/
| groupBy([ComputerName, UserName, FileName, CommandLine], function=[
count(aid, as=SearchCount),
min(timestamp, as=FirstSeen),
max(timestamp, as=LastSeen)
])
| sort(SearchCount, order=desc)
| limit(1000)
), field=ComputerName, include=outer Detects private key file access and search activity in CrowdStrike Falcon via LogScale CQL. First pipeline identifies OperationOfInterest events where non-standard processes access certificate/key files. Second pipeline detects ProcessRollup2 events where search utilities scan for private key extensions via command-line arguments.
Data Sources
Required Tables
False Positives & Tuning
- Enterprise backup solutions (Commvault, Veritas) running as SYSTEM that sweep file systems including certificate directories
- IT asset management agents performing software and file inventory scans that enumerate certificate files
- Key management service agents (CyberArk, Thycotic) that perform scheduled rotations and discovery of SSH private keys
Other platforms for T1552.004
Testing Methodology
Validate this detection against 4 adversary techniques from Atomic Red Team. Each test below lists the behaviour to exercise and the telemetry you should expect to see. Executable commands and cleanup steps are available with Pro.
- Test 1Find SSH Private Keys on Linux
Expected signal: Linux auditd EXECVE records for find with id_rsa and .pem patterns. Multiple OPEN syscalls for each found key file. Process chain visible in auditd.
- Test 2Copy SSH Private Key for Exfiltration
Expected signal: Linux auditd: OPEN for ~/.ssh/id_rsa (read) and /tmp/stolen_key (write). EXECVE for cp and cat commands. File creation event for /tmp/stolen_key.
- Test 3Export Windows Certificate with Private Key via certutil
Expected signal: Sysmon Event ID 1: certutil.exe with -exportPFX, -p (password), and output file path. Sysmon Event ID 11: .pfx file created in C:\Windows\Temp. Windows Security Event 4657 if certificate store auditing enabled.
- Test 4Search for Private Keys with PowerShell
Expected signal: Sysmon Event ID 1: powershell.exe with Get-ChildItem, *.pem, *.pfx, *.ppk patterns. PowerShell ScriptBlock Log Event ID 4104. Multiple file access events for any found key files.
References (6)
- https://attack.mitre.org/techniques/T1552/004/
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1552.004/T1552.004.md
- https://adsecurity.org/?p=2870
- https://www.unit42.paloaltonetworks.com/hildegard-malware-teamtnt/
- https://www.aquasec.com/blog/kinsing-malware-operations/
- https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/certutil
Unlock Pro Content
Get the full detection package for T1552.004 including response playbook, investigation guide, and atomic red team tests.