Kubernetes container permits privilege escalation

Restrict additional privilege gains and run Linux containers with only the permissions they need.

Description

On Linux, allowPrivilegeEscalation: false prevents a process from gaining new privileges when it executes a program such as a setuid binary. Existing privileges remain in effect.

Potential impact

The default permits privilege escalation, which can give a compromised process access to additional files and resources.

Remediation

Remove privileged mode and SYS_ADMIN before setting allowPrivilegeEscalation: false on each app and init container. Review sensitive host mounts and the runtime user. Test initialization and normal operation with your image in the workload template.

Examples

Before

yaml
apiVersion: v1
kind: Pod
metadata:
  name: pod2
spec:
  containers:
    - name: app
      image: images.my-company.example/app:v4
      securityContext:
        allowPrivilegeEscalation: true

After

yaml
apiVersion: v1
kind: Pod
metadata:
  name: pod1
spec:
  containers:
    - name: app
      image: images.my-company.example/app:v4
      securityContext:
        allowPrivilegeEscalation: false

References