Sub topic 3
What the Baseline profile blocks
This chapter assumes you can read Pod YAML, know what a Linux capability is, and have seen the three Pod Security Standards profiles (Privileged, Baseline, Restricted) named. Baseline is the middle profile. It aims to stop known privilege escalations while still letting most existing workloads run without changes.
What Baseline is for
Baseline targets the common route from a container to the host. A pod that shares the host's network or process space, or runs with full privileges, can read other workloads' data or take over the node. Baseline forbids those settings. It does not require you to add hardening fields, so a plain pod with default settings usually passes. That is the main difference from Restricted, which you will meet in the next chapters.
Main controls
The table lists the controls you will meet most often. Each one names the pod field and the values Baseline allows.
| Area | Field | What Baseline requires |
|---|---|---|
| Host namespaces | `hostNetwork`, `hostPID`, `hostIPC` | Must be unset or `false` |
| Privileged containers | `securityContext.privileged` | Must be unset or `false` |
| Capabilities | `securityContext.capabilities.add` | Only a short allowed list, such as `NET_BIND_SERVICE` and `CHOWN` |
| Host ports | `hostPort` | Must be unset or `0` |
| HostPath volumes | `volumes[*].hostPath` | Must not be used |
| Proc mount | `procMount` | Must be unset or `Default` |
| Sysctls | `securityContext.sysctls` | Only a safe list |
| SELinux | `seLinuxOptions.type` | Only allowed types, and no custom user or role |
| Seccomp | `seccompProfile.type` | Must not be `Unconfined` |
The allowed capability list and the safe sysctl list can change between Kubernetes versions. Check the official Pod Security Standards page for your cluster's version.
A pod that Baseline rejects
This pod uses hostNetwork and a privileged container. Both break Baseline.
apiVersion: v1
kind: Pod
metadata:
name: privileged-demo
namespace: payments
spec:
hostNetwork: true
containers:
- name: app
image: busybox:1.36
command: ["sleep", "3600"]
securityContext:
privileged: trueSuppose the payments namespace carries this label:
apiVersion: v1
kind: Namespace
metadata:
name: payments
labels:
pod-security.kubernetes.io/enforce: baseline
pod-security.kubernetes.io/enforce-version: latest
pod-security.kubernetes.io/audit: restricted
pod-security.kubernetes.io/warn: restrictedApplying the pod then fails. The API server returns a Forbidden error that names each violated check, along the lines of violates PodSecurity "baseline:latest": host namespaces (hostNetwork=true), privileged (container "app" must not set securityContext.privileged=true). The message lists every violation at once, so you can fix them in one pass.
How the checks are evaluated
The admission step looks at the pod spec at creation time. It checks every container, including init containers and ephemeral containers. A single failing container rejects the whole pod.
Common errors
- Treating Baseline as hardening. A pod running as root with no seccomp profile still passes Baseline. Baseline blocks escalation paths. It does not make a container safe.
- Missing init containers. An init container with
privileged: truefails the pod even if the main container is clean. - Adding too many capabilities.
NET_ADMINandSYS_ADMINare not on the allowed list, so adding them fails. Add only what the process needs, such asNET_BIND_SERVICEfor ports below 1024. - Using hostPath for convenience. Log collectors and node agents often need it. Run them in a namespace labeled
privilegedinstead of weakening the shared one.
Exercise
A pod sets hostPID: true and adds the capability NET_ADMIN. It runs in a namespace with pod-security.kubernetes.io/enforce: baseline. Is it admitted, and why?
Show answer
No. Baseline requires hostPID to be unset or false, and NET_ADMIN is not on the allowed capability list. The API server rejects the pod with a Forbidden error that lists both violations.
Exercise
A pod runs as root, sets no seccomp profile, and uses no host namespaces or privileged containers. Does it pass Baseline?
Show answer
Yes. Baseline does not require a non-root user or a seccomp profile. It only forbids Unconfined seccomp. Those requirements belong to Restricted.