Scheduled Task/Job: Systemd Timers
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. They can be used as an alternative to Cron in Linux environments.
.timer file must have a corresponding
.service file with the same name, e.g.,
.service files are Systemd Service unit files that are managed by the systemd system and service manager. Privileged timers are written to
/usr/lib/systemd/system while user level are written to
An adversary may use systemd timers to execute malicious code at system startup or on a scheduled basis for persistence. Timers installed using privileged paths may be used to maintain root level persistence. Adversaries may also install user level timers to achieve user level persistence.
|Privileged Account Management||
Limit access to the root account and prevent users from creating and/or modifying systemd timer unit files.
|Restrict File and Directory Permissions||
Restrict read/write access to systemd
|User Account Management||
Limit user access to system utilities such as 'systemctl' or 'systemd-run' to users who have a legitimate need.
Systemd timer unit files may be detected by auditing file creation and modification events within the
~/.config/systemd/user/ directories, as well as associated symbolic links. Suspicious processes or scripts spawned in this manner will have a parent process of ‘systemd’, a parent process ID of 1, and will usually execute as the ‘root’ user.
Suspicious systemd timers can also be identified by comparing results against a trusted system baseline. Malicious systemd timers may be detected by using the systemctl utility to examine system wide timers:
systemctl list-timers –all. Analyze the contents of corresponding
.service files present on the file system and ensure that they refer to legitimate, expected executables.
Audit the execution and command-line arguments of the 'systemd-run' utility as it may be used to create timers.