Detect Impair Command History Logging in CrowdStrike LogScale
Adversaries may impair command history logging to hide commands they run on a compromised system. On Linux and macOS, this involves manipulating HISTFILE, HISTFILESIZE, HISTSIZE, and HISTCONTROL environment variables, or redirecting history to /dev/null. On Windows, adversaries may modify PSReadLine settings to disable PowerShell command history. On network devices, adversaries may disable command logging entirely.
MITRE ATT&CK
- Tactic
- Defense Evasion
- Technique
- T1562 Impair Defenses
- Sub-technique
- T1562.003 Impair Command History Logging
- Canonical reference
- https://attack.mitre.org/techniques/T1562/003/
LogScale Detection Query
#event_simpleName=ProcessRollup2
| CommandLine = /(?i)(unset\s+HISTFILE|HISTFILE=\/dev\/null|HISTFILESIZE=0|HISTSIZE=0|HISTCONTROL=(ignoreboth|ignorespace)|set\s+\+o\s+history|history\s+-c|history\s+-w\s+\/dev\/null|Set-PSReadline[Oo]ption.*SaveNothing|Set-PSReadLine[Oo]ption.*HistorySavePath|Remove-Item.*ConsoleHost_history|del.*ConsoleHost_history)/
OR (CommandLine = /(?i)(rm\s+-[rf]+|truncate\s+-s\s+0|ln\s+-sf\s+\/dev\/null)/ AND CommandLine = /(?i)(bash_history|zsh_history|fish_history)/)
| case {
CommandLine = /(?i)unset\s+HISTFILE|HISTFILE=\/dev\/null/ | TamperMethod := "HISTFILE Disabled";
CommandLine = /(?i)HISTFILESIZE=0|HISTSIZE=0/ | TamperMethod := "History Size Zeroed";
CommandLine = /(?i)HISTCONTROL/ | TamperMethod := "HISTCONTROL Modified";
CommandLine = /(?i)history\s+-c/ | TamperMethod := "History Cleared";
CommandLine = /(?i)set\s+\+o\s+history/ | TamperMethod := "History Disabled";
CommandLine = /(?i)SaveNothing|HistorySavePath/ | TamperMethod := "PSReadLine Tampered";
CommandLine = /(?i)ConsoleHost_history/ | TamperMethod := "PS History File Deleted";
CommandLine = /(?i)(bash_history|zsh_history|fish_history)/ | TamperMethod := "History File Manipulated";
* | TamperMethod := "Other";
}
| case {
CommandLine = /(?i)(PSReadline|ConsoleHost_history)/ | Platform := "Windows";
CommandLine = /(?i)(HISTFILE|bash_history|history -c|set \+o history)/ | Platform := "Linux/macOS";
* | Platform := "Unknown";
}
| table([timestamp, ComputerName, UserName, FileName, CommandLine, TamperMethod, Platform, ParentBaseFileName])
| sort(timestamp, order=desc) CrowdStrike LogScale CQL query detecting T1562.003 impairment of command history logging. Queries ProcessRollup2 events for shell and PowerShell commands that disable, clear, redirect, or delete command history. Classifies events by tamper method and platform to support triage. Covers HISTFILE/HISTSIZE/HISTCONTROL manipulation on Linux/macOS and PSReadLine abuse on Windows.
Data Sources
Required Tables
False Positives & Tuning
- Falcon sensor deployment scripts and CrowdStrike-managed scripts that clear shell history as part of sensor installation or upgrade procedures on Linux endpoints
- Vulnerability scanners and compliance tools (Tenable, Qualys) running authenticated checks that invoke history manipulation as part of their Linux assessment modules
- Developer workstations where engineers manually run history -c or set +o history before pasting multi-line secrets or API tokens into terminal sessions during local development
Other platforms for T1562.003
Testing Methodology
Validate this detection against 3 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 1Disable Bash History via HISTFILE
Expected signal: Auditd execve record for the shell session showing 'unset HISTFILE'. Process creation event in MDE. No bash_history entries will be written for subsequent commands.
- Test 2Redirect History to /dev/null (BPFDoor Pattern)
Expected signal: Auditd execve record. The process /proc/<PID>/environ will show HISTFILE=/dev/null.
- Test 3Disable PSReadLine History on Windows
Expected signal: Sysmon Event ID 1: powershell.exe with CommandLine containing 'Set-PSReadlineOption'. PowerShell ScriptBlock Log Event ID 4104.
References (5)
- https://attack.mitre.org/techniques/T1562/003/
- https://sandflysecurity.com/blog/bpfdoor-an-evasive-linux-backdoor-technical-analysis/
- https://www.cisa.gov/sites/default/files/publications/AA20-239A_Joint_Advisory.pdf
- https://learn.microsoft.com/en-us/powershell/module/psreadline/set-psreadlineoption
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1562.003/T1562.003.md
Unlock Pro Content
Get the full detection package for T1562.003 including response playbook, investigation guide, and atomic red team tests.