Lion Cipher Lab

Sandbox a program's filesystem access from scratch with Landlock

Why it matters

Most Linux sandboxing is something an ADMINISTRATOR does TO a program from the outside: AppArmor and SELinux profiles are written by whoever owns the box, loaded into the kernel, and enforced on processes that have no say in it. That is powerful, but it means the developer who knows EXACTLY which files their parser should ever touch cannot express that knowledge — they have to file a ticket and hope the sysadmin writes the policy. Landlock flips this. It is a Linux Security Module — an LSM, a kernel subsystem that hooks security decisions like 'may this process open this file' — that lets an…

What you'll learn

Steps in this lab

  1. What Landlock is, and why 'self-sandboxing' is the whole point
  2. Set up a scratch box and confirm Landlock is actually enabled
  3. Create a ruleset — and understand what it means to HANDLE a right
  4. Add a rule: allow read-only access beneath one directory
  5. Lock it in: PR_SET_NO_NEW_PRIVS, then landlock_restrict_self — the full program
  6. Prove confinement: run it and read the EACCES
  7. The named failure modes (this is the advanced part)
  8. The judgment: Landlock vs seccomp vs AppArmor/SELinux — and layering them

Open the full interactive lab →