T1552.003 Splunk · SPL

Detect Bash History in Splunk

Adversaries may search the command-line history on compromised systems for insecurely stored credentials. On Linux and macOS, shells like Bash and Zsh maintain history files (~/.bash_history, ~/.zsh_history) that capture all commands including those containing passwords passed as arguments. On Windows, PowerShell maintains a persistent history file at %USERPROFILE%\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadline\ConsoleHost_history.txt. Users frequently type credentials as command-line arguments to tools like curl, ssh, mysql, psql, git, and aws CLI, which then persist in shell history. Kinsing malware is a known user of this technique to harvest credentials from containerized environments.

MITRE ATT&CK

Tactic
Credential Access
Technique
T1552 Unsecured Credentials
Sub-technique
T1552.003 Shell History
Canonical reference
https://attack.mitre.org/techniques/T1552/003/

SPL Detection Query

Splunk (SPL)
spl
index=linux_audit OR index=wineventlog (sourcetype="linux_audit" OR sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational")
(
  sourcetype="linux_audit" type=OPEN
  (name="*.bash_history" OR name="*.zsh_history" OR name="*.sh_history" OR name="*/.history")
  success="yes"
  NOT (comm="bash" OR comm="zsh" OR comm="sh" OR comm="sshd" OR comm="rsync")
| eval FileAccessed=name
| eval ProcessName=comm
| eval AlertType="LinuxHistoryAccess"
| table _time, host, auid, ProcessName, FileAccessed, AlertType
)
OR
(
  sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=1
  (CommandLine="*ConsoleHost_history.txt*" OR CommandLine="*PSReadLine*history*" OR CommandLine="*Get-History*")
  NOT (Image="*\\powershell.exe" OR Image="*\\pwsh.exe")
| eval AlertType="PSHistoryAccess"
| table _time, host, User, Image, CommandLine, AlertType
)
OR
(
  sourcetype="XmlWinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=11
  TargetFilename="*ConsoleHost_history.txt*"
  NOT (Image="*\\powershell.exe" OR Image="*\\pwsh.exe" OR Image="*\\MicrosoftEdge*")
| eval AlertType="PSHistoryFileAccess"
| table _time, host, User, Image, TargetFilename, AlertType
)
| sort - _time
medium severity medium confidence

Detects shell history access using two log sources: Linux auditd OPEN syscall for .bash_history, .zsh_history, and .sh_history accessed by non-shell processes; and Sysmon Event ID 1/11 for processes explicitly referencing PowerShell ConsoleHost_history.txt or executing Get-History from non-PowerShell parents. The AlertType field identifies the detection category.

Data Sources

File: File AccessProcess: Process Creationlinux_audit (auditd OPEN events)Sysmon Event ID 1, 11

Required Sourcetypes

linux_auditXmlWinEventLog:Microsoft-Windows-Sysmon/Operational

False Positives & Tuning

  • Shell processes reading their own history files at session start/end
  • Backup agents reading home directories including shell history
  • System administration scripts processing history files
  • IDE and terminal applications integrating with shell history
  • Compliance tools auditing shell history for sensitive data exposure
Download portable Sigma rule (.yml)

Other platforms for T1552.003


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 1Read bash_history File for Credentials

    Expected signal: Linux auditd EXECVE records for cat and grep with .bash_history path. OPEN syscall for .bash_history. Process chain visible in auditd records.

  2. Test 2Access Another User's bash_history

    Expected signal: Linux auditd: SYSCALL with uid of calling user but auid of root for the cat command. OPEN syscall for /root/.bash_history. sudo usage logged in /var/log/auth.log.

  3. Test 3Read Windows PowerShell History

    Expected signal: Sysmon Event ID 1: cmd.exe with 'type' and 'ConsoleHost_history.txt' in command line. Sysmon Event ID 11: file access for ConsoleHost_history.txt.

  4. Test 4Enumerate All Shell History Files on System

    Expected signal: Linux auditd EXECVE for find with .bash_history pattern. Multiple OPEN syscalls for each discovered history file. Process chain showing find then cat.

Unlock Pro Content

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

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections