Container breakout risk: privileged pods, host mounts, and capabilities

Containers share the host kernel, so some settings remove the isolation that remains. How to find privileged containers, host path mounts, and dangerous capabilities with kubectl and policy tools, and enforce Pod Security Standards.

Lesson 14 of 29 · 11 min read · practice only with authorization

Diagram

Settings that weaken container isolation

Follow the path. One example at a time.

Step 1 of 4

Privileged

Full access to host devices.

Illustration: Privileged
securityContext:
  privileged: true

The example on the open step is one illustration, or the fix you can paste into an application you own.

What this page is made of

3 pieces. Each one says what fails, who is affected, what you would notice, and what you change.

  1. Privileged pods

    What fails
    privileged: true removes most isolation.
    Who is affected
    The node and every pod on it.
    What you would notice
    Pods with privileged true outside system namespaces.
    What you change
    Enforce the restricted or baseline Pod Security Standard.
  2. Runtime socket mounts

    What fails
    Mounting the Docker or containerd socket lets a pod control the host’s containers.
    Who is affected
    The node.
    What you would notice
    hostPath volumes pointing at runtime sockets.
    What you change
    Remove them; use build services that do not need the socket.
  3. Capabilities

    What fails
    Capabilities like SYS_ADMIN grant kernel-level power.
    Who is affected
    The node.
    What you would notice
    Added capabilities beyond NET_BIND_SERVICE.
    What you change
    Drop ALL and add back only what is needed.

Finding risky pods

Query the cluster for the settings directly, or run a scanner such as kube-bench for node configuration and Trivy’s Kubernetes mode for workload misconfigurations.

$ kubectl get pods -A -o json | jq -r '.items[] | select(.spec.containers[].securityContext.privileged==true) | "\(.metadata.namespace)/\(.metadata.name)"'
monitoring/node-exporter-7x2kq
ci/build-runner-5f9c
$ trivy k8s --report summary cluster

Runtime detection

Falco and similar tools alert on suspicious behavior inside containers, such as a shell spawning in a production pod or writes to sensitive host paths.

Check yourself

Recognition and the fix. Nothing here is a procedure.

1 / 3

Why is mounting /var/run/docker.sock into a pod risky?

Sibling techniques

Pages at the same depth, plus a lab and a glossary card for this one.

This page stands on its own. The lab and the glossary card are the next reading.

Practice

  1. LabTerminal mission: Not privileged, but close enoughNone of the containers on mon-01 is privileged, but one combines extra capabilities, the host PID namespace, and no seccomp profile. Read docker inspect with jq and explain why that matters.

Glossary

  1. CardContainer breakout riskA container running as root, with the host docker socket, or with broad capabilities can affect the node and its neighbors.