Shell Command-Line History Deletion Detected via Defend for Containers

Last updated 5 days ago on 2026-02-06
Created 5 days ago on 2026-02-06

About

This rule detects the deletion of shell command-line history files inside a container. The shell command-line history files are used to store the command-line history for the shell. Adversaries may delete these files to cover their tracks or evade detection.
Tags
Data Source: Elastic Defend for ContainersDomain: ContainerOS: LinuxUse Case: Threat DetectionTactic: Defense EvasionLanguage: eql
Severity
high
Risk Score
73
MITRE ATT&CK™

Defense Evasion (TA0005)(external, opens in a new tab or window)

License
Elastic License v2(external, opens in a new tab or window)

Definition

Rule Type
Event Correlation Rule
Integration Pack
Prebuilt Security Detection Rules
Index Patterns
logs-cloud_defend.file*logs-cloud_defend.process*
Related Integrations

cloud_defend(external, opens in a new tab or window)

Query
text code block:
any where host.os.type == "linux" and event.category in ("file", "process") and process.interactive == true and container.id like "?*" and ( (event.category == "file" and event.type == "deletion" and file.name in (".bash_history", ".sh_history", ".zsh_history")) or (event.category == "process" and event.type == "start" and event.action == "exec" and ( ( ( process.args in ( "rm", "/bin/rm", "/usr/bin/rm", "/usr/local/bin/rm", "echo", "/bin/echo", "/usr/bin/echo", "/usr/local/bin/echo" ) or (process.args in ("ln", "/bin/ln", "/usr/bin/ln", "/usr/local/bin/ln") and process.args == "-sf" and process.args == "/dev/null") or (process.args in ("truncate", "/bin/truncate", "/usr/bin/truncate", "/usr/local/bin/truncate") and process.args == "-s0") ) and process.args like ("*.bash_history*", "*.sh_history*", "*.zsh_history*") ) or (process.name == "history" and process.args == "-c") or (process.args == "export" and process.args in ("HISTFILE=/dev/null", "HISTFILESIZE=0")) or (process.args == "unset" and process.args == "HISTFILE") or (process.args == "set" and process.args == "history" and process.args == "+o") ) ) )

Install detection rules in Elastic Security

Detect Shell Command-Line History Deletion Detected via Defend for Containers in the Elastic Security detection engine by installing this rule into your Elastic Stack.

To setup this rule, check out the installation guide for Prebuilt Security Detection Rules(external, opens in a new tab or window).