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.2
Created: 03 December 2019
Last Modified: 15 October 2024

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]

G1023 APT5

APT5 has made modifications to the crontab file including in /var/cron/tabs/.[4]

S0401 Exaramel for Linux

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

S0588 GoldMax

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

S0163 Janicab

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

S0599 Kinsing

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

S0198 NETWIRE

NETWIRE can use crontabs to establish persistence.[10]

S1107 NKAbuse

NKAbuse uses a Cron job to establish persistence when infecting Linux hosts.[11]

S0587 Penquin

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

G0106 Rocke

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

S0468 Skidmap

Skidmap has installed itself via crontab.[16]

S0374 SpeakUp

SpeakUp uses cron tasks to ensure persistence. [17]

S0341 Xbash

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

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 Detects
DS0017 Command Command Execution

Monitor execution of commands related to cron that are out of alignment with known software or administrative tasks. Monitor executed atq command and ensure IP addresses stored in the SSH_CONNECTION and SSH_CLIENT variables, machines that created the jobs, are trusted hosts. All at jobs are stored in /var/spool/cron/atjobs/.

Analytic 1 - Suspicious Cron execution

index=linux_logs sourcetype=cron_logs | search "cron" AND (command="crontab -e" OR command="crontab -l" OR command=" * * * " OR command="/cron.d/")

DS0022 File File Modification

Monitor modifications to crontab files or system-wide cron directories. Monitor for changes made to files for unexpected modifications to access permissions and attributes.

Analytic 1 - Modified Files in Linux Cron Directories

index=linux sourcetype:cron_logs:scheduled_tasks" | search "modification" AND (file_path="/etc/crontab" OR file_path="/var/spool/cron/crontabs/" OR file_path="/etc/cron.d/")

DS0009 Process Process Creation

Create a baseline of cron jobs and the processes that they spawn in your environment. Monitor for newly spawned outlier processes that are executed through cron jobs that have not been seen before when compared against the baseline data.

Analytic 1 - Unusual Cron Job Creation

index=os_logs sourcetype=process_creation (process_name="cron" OR process_name="/usr/sbin/cron")

DS0003 Scheduled Job Scheduled Job Creation

Monitor for newly constructed scheduled jobs. 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.

Analytic 1 - Look for new cron job creation events with unusual parameters.

index=os_logs sourcetype=syslog (command="crontab -e" OR command="crontab -l")| stats count by user host| where user != "root" OR count > 1

References