Scheduled Task/Job: Container Orchestration Job

Adversaries may abuse task scheduling functionality provided by container orchestration tools such as Kubernetes to schedule deployment of containers configured to execute malicious code. Container orchestration jobs run these automated tasks at a specific date and time, similar to cron jobs on a Linux system. Deployments of this type can also be configured to maintain a quantity of containers over time, automating the process of maintaining persistence within a cluster.

In Kubernetes, a CronJob may be used to schedule a Job that runs one or more containers to perform specific tasks.[1][2] An adversary therefore may utilize a CronJob to schedule deployment of a Job that executes malicious code in various nodes within a cluster.[3]

ID: T1053.007
Sub-technique of:  T1053
Platforms: Containers
Permissions Required: User
Supports Remote:  Yes
Contributors: Center for Threat-Informed Defense (CTID); Vishwas Manral, McAfee; Yossi Weizman, Azure Defender Research Team
Version: 1.3
Created: 29 March 2021
Last Modified: 15 October 2024

Mitigations

ID Mitigation Description
M1026 Privileged Account Management

Ensure containers are not running as root by default. In Kubernetes environments, consider defining Pod Security Standards that prevent pods from running privileged containers.[4]

M1018 User Account Management

Limit privileges of user accounts and remediate privilege escalation vectors so only authorized administrators can create container orchestration jobs.

Detection

ID Data Source Data Component Detects
DS0032 Container Container Creation

Monitor for container creation events within Kubernetes clusters. This helps track when new containers are being deployed, especially by jobs that could have been scheduled by adversaries.

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

sourcetype=kubernetes:container_creation | stats count by container_name namespace pod_name container_id image_name| where NOT [search index=container_baseline container_name=* earliest=-30d@d latest=now() | table container_name]

DS0022 File File Creation

Monitor for newly constructed files by using the logging agents on Kubernetes nodes and retrieve logs from sidecar proxies for application and resource pods to monitor malicious container orchestration job deployments.

Note: This query monitors for .yaml configuration files that are used to define jobs and container behaviors within Kubernetes. Changes or creations of these files should be closely watched.

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

sourcetype=kubernetes:file_creation file_path="/etc/kubernetes/manifests/*.yaml"

DS0003 Scheduled Job Scheduled Job Creation

Monitor for Kubernetes CronJob or Job creation using Kubernetes API or CLI commands.

Note: This query tracks job creation using kubectl commands or Kubernetes API calls to create or apply CronJobs. It filters out legitimate job creation based on a baseline and identifies unusual CronJob creation or usage.

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

sourcetype=kubernetes:job_creation (command="kubectl create cronjob" OR command="kubectl apply -f .yaml" OR api_call="BatchV1.CronJob.create")

Note: This query monitors Kubernetes events for job creation, start, and completion. These events are useful for tracking the actual execution of scheduled tasks in the cluster.Analytic 2 - Monitoring Kubernetes Events for Job Execution

sourcetype=kubernetes:event type="Normal" (reason="SuccessfulCreate" OR reason="Started" OR reason="Completed")

References