Scheduled Task/Job: Cron

Adversaries may abuse the cron utility to perform task scheduling for initial or recurring execution of malicious code.[1] The cron utility is a time-based job scheduler for Unix-like operating systems. The crontab file contains the schedule of cron entries to be run and the specified times for execution. Any crontab files are stored in operating system-specific file paths.

An adversary may use cron in Linux or Unix environments to execute programs at system startup or on a scheduled basis for Persistence.

ID: T1053.003
Sub-technique of:  T1053
Platforms: Linux, macOS
Permissions Required: User
Version: 1.1
Created: 03 December 2019
Last Modified: 24 March 2022

Procedure Examples

ID Name Description
S0504 Anchor

Anchor can install itself as a cron job.[2]

G0082 APT38

APT38 has used cron to create pre-scheduled and periodic background jobs on a Linux system.[3]

S0401 Exaramel for Linux

Exaramel for Linux uses crontab for persistence if it does not have root privileges.[4][5]

S0588 GoldMax

The GoldMax Linux variant has used a crontab entry with a @reboot line to gain persistence.[6]

S0163 Janicab

Janicab used a cron job for persistence on Mac devices.[7]

S0599 Kinsing

Kinsing has used crontab to download and run shell scripts every minute to ensure persistence.[8]

S0198 NETWIRE

NETWIRE can use crontabs to establish persistence.[9]

S0587 Penquin

Penquin can use Cron to create periodic and pre-scheduled background jobs.[10]

G0106 Rocke

Rocke installed a cron job that downloaded and executed files from the C2.[11][12][13]

S0468 Skidmap

Skidmap has installed itself via crontab.[14]

S0374 SpeakUp

SpeakUp uses cron tasks to ensure persistence. [15]

S0341 Xbash

Xbash can create a cronjob for persistence if it determines it is on a Linux system.[16]

Mitigations

ID Mitigation Description
M1047 Audit

Review changes to the cron schedule. cron execution can be reviewed within the /var/log directory. To validate the location of the cron log file, check the syslog config at /etc/rsyslog.conf or /etc/syslog.conf

M1018 User Account Management

cron permissions are controlled by /etc/cron.allow and /etc/cron.deny. If there is a cron.allow file, then the user or users that need to use cron will need to be listed in the file. cron.deny is used to explicitly disallow users from using cron. If neither files exist, then only the super user is allowed to run cron.

Detection

ID Data Source Data Component
DS0017 Command Command Execution
DS0022 File File Modification
DS0009 Process Process Creation
DS0003 Scheduled Job Scheduled Job Creation

Monitor scheduled task creation from common utilities using command-line invocation. Legitimate scheduled tasks may be created during installation of new software or through system administration functions. Look for changes to tasks that do not correlate with known software, patch cycles, etc.

Suspicious program execution through scheduled tasks may show up as outlier processes that have not been seen before when compared against historical data. Data and events should not be viewed in isolation, but as part of a chain of behavior that could lead to other activities, such as network connections made for Command and Control, learning details about the environment through Discovery, and Lateral Movement.

References