T1552.003 Elastic Security · Elastic

Detect Bash History in Elastic Security

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/

Elastic Detection Query

Elastic Security (Elastic)
eql
any where
  (
    event.category == "file" and
    (
      file.name in (".bash_history", ".zsh_history", ".sh_history", ".history", ".fish_history", ".ksh_history", ".csh_history") or
      file.path : "*ConsoleHost_history.txt*" or
      file.path : "*PSReadLine*"
    ) and
    not process.name in ("bash", "zsh", "sh", "fish", "powershell", "pwsh", "sshd", "rsync")
  )
  or
  (
    event.category == "process" and
    event.type == "start" and
    (
      process.command_line : "*.bash_history*" or
      process.command_line : "*.zsh_history*" or
      process.command_line : "*ConsoleHost_history.txt*" or
      process.command_line : "*PSReadLine*" or
      process.command_line : "*Get-History*"
    ) and
    not process.name in ("bash", "zsh", "sh", "fish", "powershell", "pwsh")
  )
high severity high confidence

Detects access to shell history files (.bash_history, .zsh_history, ConsoleHost_history.txt) by unexpected processes, and process executions with command lines explicitly referencing history file paths. Uses Elastic Common Schema file and process event categories to cover both Linux/macOS shell histories and Windows PowerShell history targeted for credential harvesting (T1552.003).

Data Sources

Elastic Endpoint SecurityAuditbeat (Linux)Winlogbeat with SysmonElastic Agent

Required Tables

logs-endpoint.events.file-*logs-endpoint.events.process-*auditbeat-*winlogbeat-*

False Positives & Tuning

  • Backup software (rsync, Veeam agents, Duplicati) scanning home directories as part of scheduled backup jobs will trigger file access events on shell history files
  • Security and compliance tools such as osquery, AIDE, or Wazuh performing file integrity monitoring or scheduled home directory audits
  • Terminal multiplexers and IDE plugins (tmux, VS Code Remote SSH, JetBrains Gateway) that access shell history files for session restoration or autocomplete features
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