Lion Cipher Lab

Harden a Django project for production: drive check --deploy to zero, and know what it cannot see

Why it matters

Django is one of the most widely deployed Python web frameworks, and the most common way a Django site gets hurt is not an exotic bug: it is a project deployed with the development settings still on. DEBUG=True leaks source code and settings on every error page, a guessable SECRET_KEY lets an attacker forge signed data, and missing HTTPS settings send session cookies in clear text. Django ships a linter for exactly this, but most people never run it, and the ones who do often stop at 'zero warnings' and believe the app is secure. This lab teaches both halves: drive the linter to zero with…

What you'll learn

Steps in this lab

  1. What check --deploy is, and when you reach for it
  2. Install Django and record the version
  3. Create a project and lint the untouched defaults
  4. Split the settings: base, dev, prod
  5. Fix 1 to 3: DEBUG, SECRET_KEY, ALLOWED_HOSTS
  6. Fix 4 to 6: the HTTPS trio
  7. Fix 7: HSTS, and why the warning count goes UP
  8. The headers that are already right, and how to keep them right
  9. Fix 8: a real email backend (mail.E001)
  10. Measure it: the ladder from 8 findings to 0
  11. Run the real command against prod
  12. Measure the headers and cookies before vs after
  13. Behind a proxy: the redirect loop, the fix, and the trap in the fix
  14. What check --deploy cannot see: three broken views, zero findings
  15. Gate CI on warnings, not just errors
  16. How a pro uses this, and where to go next

Open the full interactive lab →