Detect Clear Linux or Mac System Logs in IBM QRadar
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/
QRadar Detection Query
SELECT
DATEFORMAT(devicetime, 'yyyy-MM-dd HH:mm:ss') AS EventTime,
sourceip,
username,
"hostname" AS Host,
"process_name" AS ProcessName,
"filepath" AS FilePath,
"syscall" AS Syscall,
CATEGORYNAME(category) AS EventCategory
FROM events
WHERE LOGSOURCETYPEID IN (13, 88)
AND (
"syscall" IN ('unlink', 'unlinkat', 'truncate', 'ftruncate')
OR ("syscall" IN ('open', 'openat') AND "oflags" LIKE '%O_TRUNC%')
)
AND (
"filepath" LIKE '/var/log/%'
OR "filepath" LIKE '/Library/Logs/%'
OR "filepath" LIKE '/private/var/log/%'
)
AND (
"filepath" LIKE '%.log'
OR "filename" IN ('auth.log', 'syslog', 'messages', 'secure', 'wtmp', 'btmp', 'lastlog', 'kern.log')
)
AND "process_name" NOT IN ('logrotate', 'rsyslog', 'syslogd', 'newsyslog', 'aslmanager')
ORDER BY devicetime DESC
LAST 24 HOURS AQL query against Linux auditd log sources (LOGSOURCETYPEID 13 = Linux OS, 88 = Linux auditd) detecting unlink, truncate, and O_TRUNC open syscalls targeting system log files and directories on Linux and macOS hosts. Excludes known log management processes.
Data Sources
Required Tables
False Positives & Tuning
- Automated log archival scripts running under service accounts that do not match the excluded process list — tune by adding process names or source IPs to the exclusion
- System upgrades or package managers (apt, yum, dnf) that remove old log files as part of package removal post-install scripts
- Penetration testing or red team exercises targeting the same log paths with authorized tooling
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.
- 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.
- 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.
- 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.