Lion Cipher Lab

Confine a Linux service with an AppArmor profile (mandatory access control)

Why it matters

Ordinary Linux permissions decide what a USER can touch. But when an attacker exploits your web server, they are running AS that server's user — so every file that user could read, they can now read too. Mandatory access control flips this: you write a profile that says "this program may only ever touch these exact paths," and the kernel enforces it even against a fully compromised, root-adjacent process. A web server confined by AppArmor cannot read /etc/shadow or your SSH keys even after it is popped, because those paths were never in its profile. That containment — turning a full…

What you'll learn

Steps in this lab

  1. The one idea: permissions vs. confinement (DAC vs MAC)
  2. Get on a real Ubuntu box (not WSL)
  3. Install the AppArmor tools
  4. See what is already confined: aa-status
  5. Build a tiny target — and prove plain permissions allow the read
  6. Write a minimal AppArmor profile
  7. Stage it in complain mode first (log, don't block)
  8. Flip to enforce — and watch the confinement bite
  9. Read the denial in the log — how you debug a profile
  10. The judgment: when to reach for this, and when not to

Open the full interactive lab →