Lesson 5 of 13 · 12m
The securityContext Fields That Matter
runAsNonRoot, allowPrivilegeEscalation, drop ALL capabilities, readOnlyRootFilesystem, and RuntimeDefault seccomp — what each field actually blocks.
Five fields carry the whole load
securityContext has maybe thirty knobs across pod and container level. Five of them decide whether a container escape is plausible or a punchline:
securityContext:
runAsNonRoot: true
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
seccompProfile:
type: RuntimeDefaultEach one closes a different door. None of them is decorative.
runAsNonRoot: true tells the kubelet to refuse starting a container that would resolve to UID 0. It checks the image's USER (which must be numeric — USER app with no passwd entry fails open to root on some runtimes) and any explicit runAsUser. The failure mode you will actually see: Error: container has runAsNonRoot and image will run as root. Fix it in the image (USER 1000) or pin runAsUser: 1000 in the pod. Note the asymmetry — this is a kubelet check, not an admission check, so it fails at pod start, not at deploy apply.
allowPrivilegeEscalation: false sets the kernel's no_new_privs bit: no process in the container can gain more privilege than it started with, no matter what setuid binaries or capability games it plays. Without it, a setuid-root binary — or a kernel bug reachable from inside — can raise effective privilege even when runAsNonRoot held.
capabilities.drop: ["ALL"] strips the Linux capability set. Capabilities are real kernel powers, not config metadata: CAP_NET_ADMIN rewrites iptables and reroutes traffic, CAP_SYS_ADMIN is root-by-another-name, CAP_DAC_READ_SEARCH reads files ignoring permission bits, CAP_SYS_PTRACE inspects any process's memory. The restricted standard's pattern is drop-everything then re-add NET_BIND_SERVICE only if you must bind :80.
readOnlyRootFilesystem: true makes the image's filesystem immutable — an attacker can't write a poisoned binary, drop a webshell, or modify app config on disk. The cost: anything the app writes (/tmp, caches) needs an explicit emptyDir or ephemeral volume mount:
volumes:
- name: scratch
emptyDir: {}emptyDir is per-pod, node-disk (or memory-backed via medium: Memory), and destroyed with the pod — the right kind of scratch space. Apps that silently write to their own rootfs are the common breakage; fix them by giving scratch space, not by turning this off. Distroless images pair naturally with the whole posture: no shell, no package manager, nothing for an attacker to apt install their toolkit with.
seccompProfile.type: RuntimeDefault applies the container runtime's default syscall filter — containerd and CRI-O ship a profile built on Docker's, which allows the ~300 syscalls ordinary processes use and blocks the escape-primitive set: mount, kexec_load, open_by_handle_at, init_module, ptrace, keyctl-family abuse. Custom Localhost profiles exist for workloads that need tighter (loaded from files on the node's filesystem), but RuntimeDefault is free: it almost never breaks an application, which is why the restricted standard requires seccomp at all.
The privileged: true confession
One flag undoes all of it. privileged: true grants all capabilities, all host devices, disables seccomp, and drops device cgroup limits. A privileged pod is root on the node wearing a container costume — it can read /dev/sda, load kernel modules, and see every other container's traffic. Pod Security's baseline level exists largely to make this flag rejectable.
The evidence for why this matters: Siloscape, disclosed by Unit 42 in June 2021, was the first malware built specifically for Kubernetes — it compromised Windows containers, escaped to the node, and opened a backdoor into the cluster. Its escape path ran through exactly the privileges this lesson's five fields remove: host access, elevated caps, writable everything.
The practice
Ship the five-field block as your org's pod spec default — template it, lint it, enforce restricted PSA where you control the images. Each field has a stated cost (scratch volumes, fixed USER, DNS port juggling); pay those. They're configuration costs, not risk costs.
Was this lesson helpful?
Keep reading
Related articles from the SudoSecurity blog.
A 257-Byte Password Is the Key: Inside the OpenSSH musl Bypass
CVE-2026-123158 lets an attacker log into a locked account on musl-based systems like Alpine by sending a password nobody set. The trigger is one number, 257, and the reason is a C library returning a single asterisk. I reproduced the exact boundary against musl 1.2.4 and read the fix.
Immich Had Fourteen Advisories and One Bug It Fixed Three Times
Immich's 2026 security record runs to fourteen advisories, and they cluster hard: the sharing features, the OAuth plumbing, and one login redirect parameter that took three separate fixes across eighty-three days. Plus the 3.0 migration traps still waiting for anyone who hasn't jumped yet.
Jellyfin's Threat Model Is Your Brother-in-Law
Four Jellyfin CVEs landed in 2026 and not one of them needs an admin account. One needs only the ability to name a file. Meanwhile Jellyfin 12 shipped in September, the version numbers stopped starting with 10, and every "am I patched" check you wrote is now wrong.
Node.js Fixed 16 Flaws in One Release. Most of Them Live in HTTP/2 and TLS.
The November 11 Node.js security releases fix 16 CVEs across the 26, 24 and 22 lines, seven of them rated high. Nearly all sit in HTTP/2 and TLS, where a remote client can crash a server, leak memory, or get past per-host client-certificate checks.