Lion Cipher Lab

Encrypt a service's secrets at rest with systemd-creds and LoadCredential

Why it matters

Secrets end up in plaintext because the easiest way to pass one to a service is also the worst. A SYSTEMD UNIT (the file that tells systemd — the program that starts and supervises everything on a modern Linux box — how to run a service, i.e. a long-running background program) can hand a password to its process with `Environment=DBPASS=hunter2` or by pointing `EnvironmentFile=` at a file full of `KEY=value` lines. It works on the first try, so it spreads everywhere. The problem is that an ENVIRONMENT VARIABLE (a named value the operating system hands to a process when it starts) is one of the…

What you'll learn

Steps in this lab

  1. The one idea: the environment is the worst place to put a secret
  2. Confirm the ground truth: systemd 250+ and the tools exist
  3. Stand up the demo service the INSECURE way (the finding)
  4. Measure the leak three ways — this is the BEFORE half of the lab
  5. Encrypt the secret at rest with systemd-creds
  6. Deliver it to the service and read it from $CREDENTIALS_DIRECTORY
  7. Re-run the SAME three probes — this is the AFTER half
  8. The honest negative: what this does NOT protect against
  9. Do it better — the workflow worth keeping, and clean up

Open the full interactive lab →