T1070.002 Splunk · SPL

Detect Clear Linux or Mac System Logs in Splunk

Adversaries clear system logs on Linux and macOS to remove evidence of intrusion. Primary targets include /var/log/auth.log or /var/log/secure (authentication), /var/log/syslog or /var/log/messages (general), /var/log/wtmp and /var/log/btmp (login records), and web server logs (/var/log/apache2/, /var/log/nginx/). Common methods include truncating files (echo > /var/log/auth.log), deletion (rm /var/log/*.log), or overwriting with zeros. TeamTNT (crypto-mining), Rocke, Sea Turtle (DNS hijacking), Salt Typhoon (telecom espionage), UPSTYLE (Volt Typhoon PANW exploit), and MacMa (macOS) have all cleared Linux/macOS logs post-compromise.

MITRE ATT&CK

Tactic
Defense Evasion
Technique
T1070 Indicator Removal
Sub-technique
T1070.002 Clear Linux or Mac System Logs
Canonical reference
https://attack.mitre.org/techniques/T1070/002/

SPL Detection Query

Splunk (SPL)
spl
index=linux_auditd sourcetype="linux:audit" type=SYSCALL (syscall=unlink OR syscall=unlinkat OR syscall=truncate OR syscall=ftruncate OR syscall=open OR syscall=openat)
| rex field=msg_audit "name=\"(?<filepath>[^\"]+)\""
| where match(filepath, "(/var/log/|/Library/Logs/)")
| where match(filepath, "(\.log$|auth\.log|syslog|messages|secure|wtmp|btmp|lastlog|kern\.log)")
| where NOT match(exe, "(logrotate|rsyslog|syslogd|newsyslog)")
| eval ActionType=case(syscall="unlink" OR syscall="unlinkat", "FileDeleted", syscall="truncate" OR syscall="ftruncate", "FileTruncated", match(oflags, "O_TRUNC"), "FileTruncated", true(), "FileAccess")
| where ActionType in ("FileDeleted", "FileTruncated")
| table _time, host, auid, uid, exe, filepath, ActionType, syscall
| sort - _time
high severity high confidence

Detects Linux system log clearing using auditd syscall monitoring. Catches file deletion (unlink/unlinkat), truncation (truncate/ftruncate), and open-with-truncate (O_TRUNC flag) operations on log files in /var/log/. The auditd approach captures the exact syscall and the responsible executable, providing higher fidelity than file monitoring alone for detecting 'echo > logfile' truncation attacks.

Data Sources

File: File DeletionFile: File ModificationLinux auditd

Required Sourcetypes

linux:audit

False Positives & Tuning

  • Logrotate running as root with copytruncate option for files that can't be renamed
  • Custom log management scripts that rotate or clear logs
  • Container orchestration systems cleaning up log files
  • Backup scripts that truncate logs after archiving
Download portable Sigma rule (.yml)

Other platforms for T1070.002


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.

  1. Test 1Clear Linux Auth Log via Truncation

    Expected signal: auditd: SYSCALL records showing open with O_TRUNC flag on /var/log/auth.log. File modification event captured by endpoint telemetry. rsyslog may log a restart after the file is truncated if it monitors file size.

  2. Test 2Delete /var/log Files Using rm

    Expected signal: auditd: SYSCALL records for creat/open (file creation) and unlink (file deletion). File creation and deletion events in endpoint telemetry. The file creation followed immediately by deletion pattern is anomalous.

  3. Test 3Clear Login History via wtmp Manipulation

    Expected signal: auditd: SYSCALL for open with O_TRUNC on /var/log/wtmp. Any process monitoring wtmp (e.g., login daemons) may detect the size change. File modification event in endpoint telemetry for wtmp.

Unlock Pro Content

Get the full detection package for T1070.002 including response playbook, investigation guide, and atomic red team tests.

Response PlaybookInvestigation GuideHunting QueriesAtomic Red Team TestsTuning Guidance

Related Detections