Kubernetes container has the SYS_ADMIN capability

SYS_ADMIN grants broad Linux administration powers and should not be added to ordinary application containers.

Description

SYS_ADMIN allows a Linux container to perform many administrative tasks, including mounting filesystems.

Potential impact

A compromised process with this capability and host mounts can affect the node or other workloads.

Remediation

Remove SYS_ADMIN from securityContext.capabilities.add and disable privileged mode before setting allowPrivilegeEscalation: false. Review host mounts and the runtime user. Test with narrower permissions, or isolate the task if it requires SYS_ADMIN.

Examples

Use your application image in place of the example image.

Before

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

After

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

The Pod removes the added SYS_ADMIN and keeps the runtime’s other default capabilities.

References