Lesson 14 of 14 · 15m
The Hardening Checklist
Every lesson lands in a config line: dropped caps, no-new-privileges, RuntimeDefault seccomp, read-only rootfs, PSA enforcement, and a patch cadence.
The full stack, in order
Every lesson in this course lands in a config line. Here are all of them.
The container spec
Docker, single container:
docker run \
--cap-drop=ALL --cap-add=NET_BIND_SERVICE \
--security-opt=no-new-privileges:true \
--security-opt seccomp=default \
--read-only --tmpfs /tmp --tmpfs /run \
--memory=512m --cpus=1.5 \
-u 1000 \
appEach flag maps to a lesson: --cap-drop=ALL collapses the bounding set to nothing and you add back only what's needed; no-new-privileges sets PR_SET_NO_NEW_PRIVS so setuid binaries can't elevate; seccomp=default is the syscall gate (never unconfined); --read-only makes the image filesystem immutable with tmpfs for the directories that must write; --memory/--cpus are DoS meters, not walls; -u 1000 runs non-root so even a full cap set means less. Never --privileged, never --network host / --pid host / --ipc host, never -v /var/run/docker.sock, and keep bind mounts minimal and read-only where possible.
Kubernetes, the equivalent pod spec:
spec:
automountServiceAccountToken: false
runtimeClassName: gvisor # for untrusted workloads
securityContext:
runAsNonRoot: true
runAsUser: 1000
fsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: ["ALL"]
add: ["NET_BIND_SERVICE"]Pod-level vs container-level securityContext is a real distinction — capabilities and allowPrivilegeEscalation are per-container; runAsNonRoot/seccompProfile can sit at pod level and cover everything in it.
Enforcement, because YAML drifts
Checking specs by eye fails at scale. The controls that persist:
- Pod Security Admission — built into Kubernetes since 1.23 (GA in 1.25). Label a namespace
pod-security.kubernetes.io/enforce=restrictedand every pod there must satisfy the restricted profile: no privileged, no host namespaces, caps dropped,runAsNonRoot, seccomp set.enforce,audit, andwarnmodes exist per level (privileged/baseline/restricted) so you can phase it in withwarnbeforeenforce. - Gatekeeper / Kyverno — admission policies for the rules PSA doesn't cover: "no hostPath," "only images from these registries," "runtimeClassName must be gvisor in this namespace."
- Runtime detection — Falco's syscall rules detect drift after deployment: shells spawned in containers, unexpected mounts, writes to sensitive paths, outbound connections that the workload never makes. Post-exploit detection is the layer for the zero-day you don't have yet.
Images, because the box starts shipped
Hardening the runtime doesn't help if the image itself is hostile or ancient. Pull by digest or signed tag where provenance matters — Sigstore/cosign signatures verify who built it, an SBOM tells you what's in it, and a scanner (Trivy, Grype) maps its packages to known CVEs. Minimal base images pay twice: fewer packages to patch, and fewer tools an attacker inherits — a distroless image with no shell makes "run a shell in the container" a harder post-exploit step. None of this is escape defense strictly, but a compromised workload that can't curl out or sh around moves slower, and slower is detectable. Ship images you can explain.
Audit, because configuration decays
For a running Docker host:
docker inspect --format '{{.HostConfig.Privileged}} {{.HostConfig.CapAdd}} {{.HostConfig.CapDrop}} {{.HostConfig.PidMode}} {{.HostConfig.NetworkMode}} {{.HostConfig.IpcMode}}' <ctr>
readlink /proc/<pid>/ns/*
capsh --decode=<CapBnd hex>For Kubernetes: kube-bench against the CIS Kubernetes Benchmark; docker bench security for the CIS Docker Benchmark; a cron'd grep over manifests for privileged, hostPath, hostPID, hostNetwork, hostIPC, docker.sock, mountPropagation: Bidirectional, seccompProfile: Unconfined.
For hosts: kernel version vs the distro security channel, kernel.unprivileged_userns_clone, user.max_user_namespaces, runc/containerd/dockerd/kubelet/toolkit versions.
The cadence
Two things hold the wall up after config is done. First, patch cadence — kernel, runtime, kubelet, toolkit — because every LPE is an escape and runc is host code. Second, the architecture choice: namespaces for trusted workloads, userns-remap or rootless for semi-trusted, gVisor or Kata for untrusted code. Pick the wall to match who wrote the code, and the checklist keeps the wall honest.
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.
A Password-Free Path to Root: Inside the macOS Screen Sharing Vulnerability Now Under Attack
A logic bug in screensharingd let attackers skip authentication entirely and land as root — no password required. Here's how it was found, patched, reverse-engineered, and finally weaponized.
CVE-2026-31431 "Copy Fail": How a 9-Year-Old Linux Kernel Bug Gives Any Local User Root in 732 Bytes
CVE-2026-31431 chains AF_ALG, splice(), and authencesn's ESN scratch write into a deterministic 4-byte page cache write that gives an unprivileged local user root. Full technical breakdown, exploit mechanics, detection, mitigation, and patch status per distro.
BlueHammer: The Unpatched Windows Zero-Day That Weaponizes Microsoft Defender Against Your Own System
BlueHammer is an unpatched, publicly released Windows local privilege escalation exploit that chains Microsoft Defender's update workflow, Volume Shadow Copy, Cloud Files callbacks, and opportunistic locks to reach NT AUTHORITY\SYSTEM from a standard user account.