TAM-H-CVR-016 · Human · Cover: Hiding the tracks

Hiding Shell History

The insider deletes, truncates or redirects command history so the commands they ran cannot be reviewed.

Shells and interpreters keep a running list of what was typed. It is one of the first things an investigator reads on a Linux, macOS or Windows machine. An insider can clear it, stop it being saved or point it to nowhere.

Typical moves are deleting the history file, running a clear command, setting HISTFILE or HISTSIZE to nothing, adding a line to a shell startup file, or using a history-off mode for a session.

The commands are not truly gone. Independent records such as EDR process trees, auditd, sudo logs, command-line auditing, and PowerShell script block logs often hold them. The missing history is itself the clue when other telemetry shows commands that history does not.

Collect history early, ship it off the host, and monitor edits to shell config.

What it looks like

  • After copying a database dump with scp, an engineer runs history -c and removes the .bash_history file.
  • A user adds export HISTFILE=/dev/null to their profile.
  • An admin deletes the PowerShell PSReadLine history file.

Variants (4)

TAM-H-CVR-016.1Clearing Bash History+

The insider wipes the Bash command history so earlier commands are lost.

On Linux and older macOS the file is usually ~/.bash_history. Running history -c clears the live session and stops it being written at exit. Check file timestamps and size, startup file edits, auditd or EDR process records, and sudo logs for the commands.

TAM-H-CVR-016.2Clearing PowerShell History+

The insider removes PowerShell's saved command history.

PSReadLine stores history in a text file under the user profile, and any user can delete their own copy. Clear-History only affects the current session. Look for file deletes, script block logging (event 4104), and transcripts. Script block logging and transcript files, if enabled, keep what the history file lost.

TAM-H-CVR-016.3Clearing Zsh History+

The insider clears, truncates or redirects Zsh history.

Methods include deleting .zsh_history, unsetting HISTFILE, setting SAVEHIST to zero, or editing .zshrc. Examine file presence, size and timestamps, startup file edits, macOS file system events, and process telemetry for commands missing from history. Zsh is the default shell on modern Macs, so this is often the first place a Mac user would tidy up.

TAM-H-CVR-016.4Nulling Python History+

The insider points the Python history file at /dev/null so nothing is saved.

Set for one run or placed in a shell profile, this stops interactive Python commands being written to disk. Look for the setting in startup files and in process environment records, and for interactive Python use that appears in EDR but not in any history file.

Detections (12)

Controls (2)