T1053.003: Cron

Adversaries may abuse the cron utility to perform task scheduling for initial or recurring execution of malicious code. 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.

Positive Technologies products that cover the technique

MaxPatrol SIEM knowledge base

unix_mitre_attck_persistence: PT-CR-1672: Unix_New_Cron_Job: A job in cron job scheduler was created or changed

Detection

IDDS0009Data source and componentProcess: Process CreationDescription

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

source="Linux:" Image= “crontab” OR Image= “cron” AND CommandLine LIKE “crontab -e” OR CommandLine LIKE “cron

Analytic 2 - Unusual Execution Frequency

source="Linux:" Image= “crond” OR Image= “cron” AND ImageCount >= “100”

IDDS0003Data source and componentScheduled Job: Scheduled Job CreationDescription

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.

IDDS0017Data source and componentCommand: Command ExecutionDescription

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/.

IDDS0022Data source and componentFile: File ModificationDescription

Monitor for changes made to files for unexpected modifications to access permissions and attributes.

Analytic 1 - Modified Files in Linux Cron Directories

source="Linux:" (Path LIKE "/etc/cron.allow.d" OR Path LIKE "/etc/cron.d/" OR Path LIKE "/etc/cron.hourly" OR Path LIKE "/etc/cron.daily" OR Path LIKE "/etc/cron.weeky" OR Path LIKE "/etc/cron.monthly")

Mitigation

IDM1047NameAuditDescription

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

IDM1018NameUser Account ManagementDescription

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.