Detect Systemd Timers in Sumo Logic CSE
Adversaries may abuse systemd timers to perform task scheduling for initial or recurring execution of malicious code. Systemd timers are unit files with file extension .timer that control services. Timers can be set to run on a calendar event or after a time span relative to a starting point. Each .timer file must have a corresponding .service file with the same name. Privileged timers are written to /etc/systemd/system/ and /usr/lib/systemd/system while user level timers are written to ~/.config/systemd/user/. Adversaries may use systemd timers to execute malicious code at system startup or on a scheduled basis for persistence, and may leverage root-level timer paths to maintain privileged persistence.
MITRE ATT&CK
- Technique
- T1053 Scheduled Task/Job
- Sub-technique
- T1053.006 Systemd Timers
- Canonical reference
- https://attack.mitre.org/techniques/T1053/006/
Sumo Detection Query
(_sourceCategory=*linux* OR _sourceCategory=*syslog* OR _sourceCategory=*auditd*)
| where (
(
message matches "*systemctl*"
and message matches "*.timer*"
and (
message matches "*enable*"
or message matches "*start*"
or message matches "*link*"
or message matches "*daemon-reload*"
)
)
or
(
(message matches "*.timer*" or message matches "*.service*")
and (
message matches "*/etc/systemd/system/*"
or message matches "*/usr/lib/systemd/system/*"
or message matches "*/lib/systemd/system/*"
or message matches "*/.config/systemd/user/*"
)
and (
message matches "*write*"
or message matches "*create*"
or message matches "*install*"
or message matches "*SYSCALL*"
)
)
)
| parse regex field=message "(?P<timer_name>[\\w\\-\\.]+\\.timer)" nodrop
| eval is_privileged_path = if(
message matches "*/etc/systemd*"
or message matches "*/usr/lib/systemd*"
or message matches "*/lib/systemd*", 1, 0)
| eval is_user_timer = if(message matches "*/.config/systemd/user/*", 1, 0)
| eval is_suspicious_content = if(
message matches "*/tmp/*"
or message matches "*/dev/shm/*"
or message matches "*/var/tmp/*"
or message matches "*bash -i*"
or message matches "*nc *"
or message matches "*ncat *"
or message matches "*curl *"
or message matches "*wget *"
or message matches "*python*"
or message matches "*perl*"
or message matches "*base64*"
or message matches "*chmod +x*"
or message matches "*chmod 777*", 1, 0)
| eval is_systemctl_action = if(
message matches "*systemctl*" and message matches "*.timer*", 1, 0)
| eval risk_score = is_privileged_path + is_suspicious_content + is_systemctl_action + is_user_timer
| eval path_type = if(is_privileged_path = 1, "privileged", if(is_user_timer = 1, "user", "unknown"))
| fields _messageTime, _sourceHost, _source, timer_name, path_type, is_privileged_path, is_user_timer, is_suspicious_content, is_systemctl_action, risk_score, message
| sort by _messageTime desc Sumo Logic query detecting systemd timer persistence (T1053.006) from Linux syslog and auditd sources. Detects systemctl commands managing .timer units and file creation events in system-level and user-level systemd paths. Produces a risk score based on path privilege level, suspicious content indicators, and action type.
Data Sources
Required Tables
False Positives & Tuning
- OS boot initialization sequences that enable standard system timers such as systemd-tmpfiles-clean.timer, man-db.timer, and logrotate.timer on first startup
- Automated patching workflows (unattended-upgrades, yum-cron) that write updated timer unit files to /usr/lib/systemd/system/ as part of package updates
- Container runtimes or systemd-nspawn instances where user-level timers are legitimately created under .config/systemd/user/ for application scheduling within isolated namespaces
Other platforms for T1053.006
Testing Methodology
Validate this detection against 4 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 1Create and Enable a Privileged Systemd Timer for Persistence
Expected signal: Auditd: SYSCALL openat/write events for /etc/systemd/system/argus-test.timer and /etc/systemd/system/argus-test.service creation. Process creation events for 'systemctl daemon-reload', 'systemctl enable argus-test.timer', 'systemctl start argus-test.timer'. Syslog: systemd entries showing 'argus-test.timer' enabled and started. After 1 minute: process creation for /bin/bash /tmp/argus_payload.sh spawned with parent=systemd.
- Test 2Create User-Level Systemd Timer for Unprivileged Persistence
Expected signal: File creation events for ~/.config/systemd/user/argus-user-test.timer and ~/.config/systemd/user/argus-user-test.service. Process creation events for 'systemctl --user daemon-reload', 'systemctl --user enable', 'systemctl --user start'. User journal entries: 'journalctl --user -u argus-user-test.timer' shows activation. On calendar trigger: process creation for /bin/bash /tmp/user_payload.sh with parent process systemd (user instance).
- Test 3Deploy Systemd Timer with Base64-Encoded Payload in ExecStart
Expected signal: File creation events for /etc/systemd/system/argus-encoded-test.service and /etc/systemd/system/argus-encoded-test.timer. The service unit file content contains 'base64 -d | bash' in ExecStart — detectable via file content inspection. Syslog: systemctl enable/start events. Process creation: /bin/bash spawned by systemd with base64 decode pipe pattern visible in command line arguments.
- Test 4Simulate Remote Systemd Timer Activation via SSH
Expected signal: File creation for unit files in /etc/systemd/system/. Process creation: systemctl enable and start commands. If run via SSH: /var/log/auth.log shows SSH session from source IP, with subsequent systemctl commands in the same session. Syslog: 'argus-remote-test.timer' enabled and started entries. Auditd: EXECVE records for systemctl with timer arguments.
References (12)
- https://attack.mitre.org/techniques/T1053/006/
- https://wiki.archlinux.org/index.php/Systemd/Timers
- https://www.tecmint.com/control-systemd-services-on-remote-linux-server/
- https://www.bleepingcomputer.com/news/security/malware-found-in-arch-linux-aur-package-repository/
- https://gist.github.com/campuscodi/74d0d2e35d8fd9499c76333ce027345a
- https://lists.archlinux.org/pipermail/aur-general/2018-July/034153.html
- https://www.hybrid-analysis.com/sample/28553b3a9d2ad4361d33d29ac4bf771d008e0073cec01b5561c6348a608f8dd7?environmentId=300
- http://man7.org/linux/man-pages/man1/systemd.1.html
- https://www.freedesktop.org/software/systemd/man/systemd.timer.html
- https://github.com/redcanaryco/atomic-red-team/blob/master/atomics/T1053.006/T1053.006.md
- https://github.com/SigmaHQ/sigma/tree/master/rules/linux
- https://pberba.github.io/security/2022/01/30/linux-threat-hunting-for-persistence-systemd-timers-and-cron/
Unlock Pro Content
Get the full detection package for T1053.006 including response playbook, investigation guide, and atomic red team tests.