Lion Cipher Lab

Harden a container: non-root, drop capabilities, seccomp

Why it matters

Getting a container to run is easy; making it hard to escape is the part that keeps an attacker who lands inside from reaching your host. A container shares the host kernel, so the amount of damage a compromised process can do is decided by exactly one thing: how much power you handed the container at launch. The default is far more power than any app needs — root inside the box, the full set of Linux capabilities, a writable filesystem, and no restriction on gaining new privileges. This lab flips each of those to the safe setting and proves it worked by making the dangerous action fail with…

What you'll learn

Steps in this lab

  1. The model: your launch flags decide the blast radius
  2. Baseline: build the over-privileged container and see the danger
  3. Control 1 (highest value): stop being root inside the container
  4. Control 2: drop every capability, add back only what's needed
  5. Control 3: forbid gaining new privileges (--security-opt=no-new-privileges)
  6. Control 4: make the root filesystem read-only
  7. Control 5: filter syscalls with seccomp
  8. One layer beyond seccomp: AppArmor / SELinux (MAC)
  9. Put it together: the fully hardened run command
  10. Where this goes next: Kubernetes securityContext
  11. What you just did — and the judgment to keep

Open the full interactive lab →