T1552.004 Splunk · SPL

Detect Private Keys in Splunk

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/

SPL Detection Query

Splunk (SPL)
spl
index=wineventlog OR index=linux_audit (sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" OR sourcetype="linux_audit")
(
  sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
  (
    (CommandLine="*.pem*" OR CommandLine="*.pfx*" OR CommandLine="*.p12*" OR CommandLine="*.ppk*" OR CommandLine="*.pgp*" OR CommandLine="*.gpg*")
    AND
    (Image="*\\mimikatz.exe" OR Image="*\\certutil.exe" OR CommandLine="*find*" OR CommandLine="*Get-ChildItem*" OR CommandLine="*dir /s*")
  )
| eval AlertType="WinKeySearch"
| table _time, host, User, Image, CommandLine, AlertType
)
OR
(
  sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=11
  (TargetFilename="*.pem" OR TargetFilename="*.pfx" OR TargetFilename="*.p12" OR TargetFilename="*.ppk" OR TargetFilename="*id_rsa" OR TargetFilename="*id_ecdsa" OR TargetFilename="*id_ed25519")
  NOT (Image IN ("*\\ssh.exe", "*\\scp.exe", "*\\openssl.exe", "*\\putty.exe", "*\\backup*"))
| eval AlertType="WinKeyAccess"
| table _time, host, User, Image, TargetFilename, AlertType
)
OR
(
  sourcetype="linux_audit" type=OPEN success="yes"
  (name="*.pem" OR name="*.key" OR name="*.pfx" OR name="*.p12" OR name="*/.ssh/id_rsa" OR name="*/.ssh/id_ecdsa" OR name="*/.ssh/id_ed25519")
  NOT (comm IN ("ssh", "scp", "sftp", "openssl", "curl", "nginx", "apache", "httpd", "certbot"))
| eval AlertType="LinuxKeyAccess"
| table _time, host, auid, comm, name, AlertType
)
| sort - _time
high severity medium confidence

Detects private key access using three patterns: Windows Sysmon Event 1 for key search commands (mimikatz, certutil, find, Get-ChildItem) with key file extensions; Windows Sysmon Event 11 for file creation/access of key files from unexpected processes; and Linux auditd OPEN syscall for key files accessed by non-SSL/SSH applications.

Data Sources

File: File AccessProcess: Process CreationSysmon Event ID 1, 11linux_audit OPEN events

Required Sourcetypes

XmlWinEventLog:Microsoft-Windows-Sysmon/Operationallinux_audit

False Positives & Tuning

  • SSH/SCP clients reading their own private keys for authentication
  • Web servers reading TLS certificate private keys on startup
  • Certificate management tools managing certificate lifecycle
  • Backup agents reading certificate directories
  • Key management and HSM integration software
Download portable Sigma rule (.yml)

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

Unlock Pro Content

Get the full detection package for T1552.004 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections