T1552.003 Google Chronicle · YARA-L

Detect Bash History in Google Chronicle

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/

YARA-L Detection Query

Google Chronicle (YARA-L)
yaral
rule t1552_003_bash_history_credential_access {
  meta:
    author = "Detection Engineering"
    description = "Detects shell history file access for credential harvesting - T1552.003"
    severity = "HIGH"
    mitre_attack_tactic = "Credential Access"
    mitre_attack_technique = "T1552.003"
    reference = "https://attack.mitre.org/techniques/T1552/003/"

  events:
    (
      $e.metadata.event_type = "FILE_OPEN" or
      $e.metadata.event_type = "FILE_READ" or
      $e.metadata.event_type = "FILE_CREATION"
    )
    (
      re.regex($e.target.file.full_path, `\.bash_history$`) or
      re.regex($e.target.file.full_path, `\.zsh_history$`) or
      re.regex($e.target.file.full_path, `\.sh_history$`) or
      re.regex($e.target.file.full_path, `\.fish_history$`) or
      re.regex($e.target.file.full_path, `/\.history$`) or
      re.regex($e.target.file.full_path, `ConsoleHost_history\.txt`) or
      re.regex($e.target.file.full_path, `PSReadLine`)
    )
    not re.regex($e.principal.process.file.full_path, `/(bash|zsh|sh|fish|sshd)$`) nocase
    not re.regex($e.principal.process.file.full_path, `(powershell|pwsh)\.exe$`) nocase

    $hostname = $e.principal.hostname

  condition:
    $e
}
high severity high confidence

YARA-L 2.0 rule detecting UDM FILE_OPEN, FILE_READ, and FILE_CREATION events targeting shell history files on Linux/macOS and Windows PowerShell history. Uses Chronicle Unified Data Model file event types with regex matching against known history file name patterns. Excludes legitimate shell interpreter binary paths to reduce false positive volume.

Data Sources

Google Chronicle SIEMChronicle UDM (Unified Data Model)CrowdStrike Falcon via Chronicle ingestionLinux Auditd via Chronicle ForwarderWindows Sysmon via Chronicle Forwarder

Required Tables

UDM Events (FILE_OPEN, FILE_READ, FILE_CREATION)

False Positives & Tuning

  • Automated configuration management tools (Ansible, SaltStack, Puppet) that read home directory dotfiles including shell history to verify or apply configuration state
  • Authorized administrators explicitly searching .bash_history for troubleshooting or internal forensic investigation purposes from privileged workstations
  • Cloud VM backup solutions that include home directory contents in their backup scope, triggering FILE_READ events on shell history files during scheduled backup windows
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