Tampering of Bash Command-Line Historyedit

Adversaries may attempt to clear or disable the Bash command-line history in an attempt to evade detection or forensic investigations.

Rule type: eql

Rule indices:

  • auditbeat-*
  • logs-endpoint.events.*

Severity: medium

Risk score: 47

Runs every: 5 minutes

Searches indices from: now-9m (Date Math format, see also Additional look-back time)

Maximum alerts per execution: 100

Tags:

  • Elastic
  • Host
  • Linux
  • macOS
  • Threat Detection
  • Defense Evasion

Version: 100 (version history)

Added (Elastic Stack release): 7.9.0

Last modified (Elastic Stack release): 8.5.0

Rule authors: Elastic

Rule license: Elastic License v2

Investigation guideedit


Rule queryedit

process where event.type in ("start", "process_started") and (
((process.args : ("rm", "echo") or (process.args : "ln" and
process.args : "-sf" and process.args : "/dev/null") or
(process.args : "truncate" and process.args : "-s0")) and
process.args : (".bash_history", "/root/.bash_history",
"/home/*/.bash_history","/Users/.bash_history",
"/Users/*/.bash_history", ".zsh_history",
"/root/.zsh_history", "/home/*/.zsh_history", "/Users/.zsh_history",
"/Users/*/.zsh_history")) or (process.name : "history" and
process.args : "-c") or (process.args : "export" and process.args :
("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") )

Threat mappingedit

Framework: MITRE ATT&CKTM

Rule version historyedit

Version 100 (8.5.0 release)
  • Formatting only
Version 10 (8.4.0 release)
  • Formatting only
Version 8 (8.3.0 release)
  • Updated query, changed from:

    process where event.type in ("start", "process_started") and (
    (process.args : ("rm", "echo") and process.args : (".bash_history",
    "/root/.bash_history", "/home/*/.bash_history")) or (process.name :
    "history" and process.args : "-c") or (process.args : "export" and
    process.args : ("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") )
Version 7 (8.2.0 release)
  • Formatting only
Version 6 (7.12.0 release)
  • Rule name changed from: Deletion of Bash Command Line History
  • Updated query, changed from:

    event.category:process AND event.type:(start or process_started) AND
    process.name:rm AND
    process.args:/\/(home\/.{1,255}|root)\/\.bash_history/
Version 5 (7.11.2 release)
  • Formatting only
Version 4 (7.11.0 release)
  • Formatting only
Version 3 (7.10.0 release)
  • Formatting only
Version 2 (7.9.1 release)
  • Formatting only