
# cronjob_vuln.yaml - CronJob that checks current time without external validation
apiVersion: batch/v1
kind: CronJob
metadata:
name: backup
spec:
schedule: "0 2 * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: backup
image: alpine
command: ["/bin/sh", "-c", "if [ $(date +%H) -eq 2 ]; then echo doing backup; fi"]
restartPolicy: OnFailure
A Kubernetes CronJob relies on the node’s system clock to decide whether to run. An attacker with node‑level privileges can manipulate the clock to force an early execution, potentially triggering a scheduled task (e.g., backup) that may have unintended consequences.
(Simulated) With node root access, run:
python exploit_cronjob_time.py
If the cronjob container trusts the host time, it will execute the job.