Detect SSH Authorized Keys in CrowdStrike LogScale
Adversaries may modify the SSH authorized_keys file to maintain persistence on a victim host. The authorized_keys file specifies SSH keys permitted for logging into a user account, typically found at <user-home>/.ssh/authorized_keys. Adversaries add their own public keys to this file, enabling passwordless SSH access using the corresponding private key. This technique is used by multiple threat actors including Earth Lusca, TeamTNT, and Salt Typhoon, as well as malware families like Skidmap, XCSSET, and Bundlore.
MITRE ATT&CK
- Tactic
- Persistence Privilege Escalation
- Technique
- T1098 Account Manipulation
- Sub-technique
- T1098.004 SSH Authorized Keys
- Canonical reference
- https://attack.mitre.org/techniques/T1098/004/
LogScale Detection Query
// SSH Authorized Keys Modification — T1098.004
// Detects process command lines writing to authorized_keys paths via shell utilities or network downloaders
#event_simpleName in (ProcessRollup2, SyntheticProcessRollup2)
| CommandLine = /authorized_keys/i
| regex("(?i)(echo|printf|tee|>>|ssh-keygen|curl|wget|cp |mv |dd |install )", field=CommandLine)
| IsRootSSHDir := if(CommandLine = /\/root\/.ssh/i, 1, 0)
| IsEtcSSHKeys := if(CommandLine = /\/etc\/ssh\/keys-/i, 1, 0)
| IsRedirectAppend := if(CommandLine = />>|tee -a|tee --append/i, 1, 0)
| IsSshKeygen := if(CommandLine = /ssh-keygen/i, 1, 0)
| IsCurlWget := if(CommandLine = /curl|wget/i OR ParentBaseFileName = /^(curl|wget)$/i, 1, 0)
| IsSuspiciousParent := if(ParentBaseFileName = /^(bash|sh|dash|zsh|python[23]?|perl|ruby|nc|ncat|netcat)$/i, 1, 0)
| SuspicionScore := IsRootSSHDir + IsEtcSSHKeys + IsRedirectAppend + IsSshKeygen + IsCurlWget + IsSuspiciousParent
| SuspicionScore > 0
| sort(SuspicionScore, order=desc)
| select([ComputerName, UserName, FileName, CommandLine, ParentBaseFileName, SHA256HashData, IsRootSSHDir, IsEtcSSHKeys, IsRedirectAppend, IsSshKeygen, IsCurlWget, IsSuspiciousParent, SuspicionScore]) Detects SSH authorized_keys modification in CrowdStrike LogScale (Humio) by querying Falcon process telemetry (ProcessRollup2, SyntheticProcessRollup2) for command lines referencing authorized_keys alongside file-writing utilities or download tools. Computes a six-factor suspicion score: root SSH directory access, /etc/ssh/keys- paths, append redirect operators, ssh-keygen invocation, curl/wget parents or command usage, and suspicious scripting/network parent executables. Events with SuspicionScore > 0 are surfaced, sorted by highest risk first.
Data Sources
Required Tables
False Positives & Tuning
- DevOps engineers running Ansible playbooks or custom shell scripts that legitimately add or rotate SSH public keys as part of server provisioning, generating ProcessRollup2 events from python/ansible-playbook with authorized_keys in the command context
- Security hardening scripts that invoke ssh-keygen to generate new host keys or audit existing authorized_keys files for expired or unauthorized entries as part of scheduled compliance checks
- Automated deployment pipelines (Capistrano, Fabric, or custom CI/CD shell scripts) that use SCP or SSH key operations to configure service account access on freshly provisioned Linux build agents or deployment targets
Other platforms for T1098.004
Testing Methodology
Validate this detection against 5 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 1Append Adversary SSH Key to Root authorized_keys
Expected signal: auditd SYSCALL records for open()/write() on /root/.ssh/authorized_keys if auditd watch is configured. syslog entries from auditd. DeviceFileEvents (if MDE for Linux deployed): FileCreated or FileModified event for FileName=authorized_keys with FolderPath=/root/.ssh. DeviceProcessEvents: Process Create for ssh-keygen and echo/bash with ProcessCommandLine containing 'authorized_keys'. Shell history entry in /root/.bash_history.
- Test 2Add SSH Key via curl Download
Expected signal: DeviceProcessEvents: Process Create for curl with ProcessCommandLine containing 'authorized_keys'. DeviceNetworkEvents: Network connection from curl to 127.0.0.1:18080 (Sysmon Event ID 3 if Sysmon for Linux). DeviceFileEvents: FileModified on authorized_keys with InitiatingProcessFileName=bash or sh. Shell history entries for curl and python3 commands.
- Test 3Modify SSH Config to Enable Root Login and Key Auth
Expected signal: auditd SYSCALL records for open()/write() on /etc/ssh/sshd_config if auditd watch is configured. DeviceFileEvents (if MDE for Linux): FileModified for FileName=sshd_config in FolderPath=/etc/ssh. DeviceProcessEvents: Process Create for sed with ProcessCommandLine containing 'sshd_config' and 'PermitRootLogin'. Shell history entries for sed and grep commands.
- Test 4Add SSH Key to Non-Root User Account
Expected signal: DeviceFileEvents: FileCreated or FileModified for FileName=authorized_keys under /home/<user>/.ssh/. DeviceProcessEvents: Process Create for useradd, ssh-keygen, cat with relevant command lines. auditd records for file operations on the authorized_keys path. Shell history for all commands executed.
- Test 5Simulate ESXi authorized_keys Modification
Expected signal: DeviceFileEvents: FileCreated for FileName=authorized_keys with FolderPath containing /etc/ssh/keys-. DeviceProcessEvents: Process Create for ssh-keygen and cat with ProcessCommandLine containing the ESXi key path. On actual ESXi systems, ESXCLI audit logs and /var/log/auth.log entries would also be generated.
References (13)
- https://attack.mitre.org/techniques/T1098/004/
- https://www.ssh.com/ssh/authorized_keys/
- https://www.venafi.com/blog/growing-abuse-ssh-keys-commodity-malware-campaigns-now-equipped-ssh-capabilities
- https://www.cybereason.com/blog/new-pervasive-worm-exploiting-linux-exim-server-vulnerability
- https://cloud.google.com/sdk/gcloud/reference/compute/instances/add-metadata
- https://about.gitlab.com/blog/2020/02/12/plundering-gcp-escalating-privileges-in-google-cloud-platform/
- https://docs.microsoft.com/en-us/rest/api/compute/virtual-machines/update
- https://knowledge.broadcom.com/external/article/313767/allowing-ssh-access-to-vmware-vsphere-es.html
- https://www.trendmicro.com/en_us/research/22/a/earth-lusca-employs-sophisticated-infrastructure-varied-tools-and-techniques.html
- https://www.trendmicro.com/en_us/research/19/f/skidmap-linux-malware-uses-rootkit-capabilities-to-hide-cryptocurrency-mining-payload.html
- https://blog.aquasec.com/teamtnt-activities-summary-and-a-deep-dive-into-a-recent-campaign
- https://www.cisco.com/c/en/us/td/docs/ios-xml/ios/security/d1/sec-d1-cr-book/sec-cr-i3.html#wp1254331478
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1098.004/T1098.004.md
Unlock Pro Content
Get the full detection package for T1098.004 including response playbook, investigation guide, and atomic red team tests.