Detect Private Keys in Google Chronicle
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/
YARA-L Detection Query
rule T1552_004_private_key_access {
meta:
author = "Argus Detection Engineering"
description = "Detects access to or search for private key and certificate files (T1552.004). Covers SSH keys, TLS certs, PGP keys, and PKCS formats accessed by non-standard processes."
severity = "HIGH"
priority = "HIGH"
mitre_attack_tactic = "Credential Access"
mitre_attack_technique = "T1552.004"
reference = "https://attack.mitre.org/techniques/T1552/004/"
created = "2026-04-13"
events:
(
$e.metadata.event_type = "FILE_OPEN"
and (
re.regex($e.target.file.full_path, `(?i)\.(pem|pfx|p12|ppk|pgp|gpg|asc|key|crt|cer|p7b)$`)
or re.regex($e.target.file.full_path, `(?i)(id_rsa|id_ecdsa|id_ed25519|id_dsa)$`)
)
and not re.regex($e.principal.process.file.full_path,
`(?i)(\bssh\b|\bscp\b|\bsftp\b|openssl|gpg|putty|certbot|nginx|apache|httpd|backup)`)
)
or
(
$e.metadata.event_type = "PROCESS_LAUNCH"
and (
re.regex($e.target.process.command_line, `(?i)\.(pem|pfx|p12|ppk|pgp|gpg|asc|key|id_rsa|id_ecdsa|id_ed25519)`)
and re.regex($e.target.process.command_line,
`(?i)(\bfind\b|\blocate\b|Get-ChildItem|dir /s|findstr|mimikatz)`)
)
)
condition:
$e
} Chronicle YARA-L 2.0 rule detecting private key and certificate file access (T1552.004) via UDM FILE_OPEN events and process launch events. Covers SSH, TLS, PGP, and PKCS key formats accessed by untrusted processes, and command-line searches targeting private key extensions.
Data Sources
Required Tables
False Positives & Tuning
- Secrets management integrations (HashiCorp Vault Agent, AWS Secrets Manager) that read and rotate TLS certificates on a schedule
- Penetration testing tools run by authorized red team operations targeting SSH key stores
- Monitoring agents (Datadog, New Relic) that inspect certificate expiry by reading cert files periodically
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.