Operator On The Wire
Join
← Back to Knowledge Base
BLUE TEAM / THREAT HUNT / LINUX / EVASION

History Tampering

This note documents detection patterns related to history tampering on Linux systems.


Direct Indicators

ArtifactString / SignalDetection UseForensic ValueNotes
bash historymissing recent commandsDetect removed shell evidenceCriticalSession activity exists elsewhere but history absent
bash historyhistory -cDetect explicit clearingCriticalDirect shell history wipe
bash historyunset HISTFILEDetect disabling history writesCriticalPrevents persistence of command trail
bash historyexport HISTFILE=/dev/nullDetect redirected history sinkCriticalCommon stealth pattern
shell configHISTSIZE=0Detect disabled history retentionHighPrevents command storage
shell configHISTFILESIZE=0Detect no file retentionHighOften set temporarily before actions
shell configset +o historyDetect shell history disabledHighSession-local stealth
shell config.bash_history timestamp gapsDetect inconsistent timelineHighMissing commands during suspicious window

Indirect Indicators

IndicatorWhat To Look ForForensic ValueNotes
Authenticated session but no historySSH logon exists but no shell commandsCriticalStrong anti-forensic signal
History ends abruptlyCommands stop before suspicious eventHighMay indicate cleanup
Commands seen in journald but absent in historyShell evidence mismatchCriticalConfirms tampering
Root shell with empty historyHigh-value account lacks activityCriticalOften deliberate
Recent file mtime but old contentHistory rewrittenHighManual edit possible

Common Tools

ToolUsage
bash builtinshistory -c, unset HISTFILE
sedDelete lines from history
truncateEmpty history file
rmRemove history file
manual editingRewrite selected commands

Relevant Artifacts

  • /home/*/.bash_history
  • /root/.bash_history
  • /home/*/.zsh_history
  • /etc/profile
  • /etc/bash.bashrc
  • /home/*/.bashrc
  • /home/*/.profile
  • auth.log
  • journalctl
  • shell session timestamps
  • file metadata for history files

MITRE ATT&CK References

  • T1070 Indicator Removal on Host
  • T1070.003 Clear Command History

Decision Tree

  1. Was there an authenticated session?
    • Confirm via auth.log / journald.
  2. Does history exist?
    • Compare user shell history.
  3. Is history incomplete?
    • Identify suspicious gaps.
  4. Pivot:
    • journald
    • auth.log
    • process execution
  5. Confirm anti-forensics
    • Match session time against missing commands.

Example Detection Templates

Grep

grep -R "unset HISTFILE\|history -c\|HISTSIZE=0\|HISTFILESIZE=0\|set +o history" /home /root /etc 2>/dev/null

Journalctl

journalctl | grep -Ei "history|bash"

File Metadata

stat /root/.bash_history
stat /home/*/.bash_history

Timeline Correlation

grep "Accepted" /var/log/auth.log

Mitigation & Hardening

Control AreaMitigationEffectivenessNotes
AuditdRecord shell execution independentlyCriticalSurvives history deletion
Central loggingForward auth and shell eventsCriticalPreserves evidence
Shell restrictionsRestrict root shell abuseHighLimits stealth
Session recordingEnable shell session captureHighStrong forensic value
File integrity monitoringMonitor history filesMediumDetects tampering