security
Installation
SKILL.md
Elixir/Phoenix Security Reference
Ash projects:
AshAuthenticationhas its own strategy/token patterns — use theash-frameworkskill. CSRF, XSS, and secret management patterns below still apply.
Quick reference for security patterns in Elixir/Phoenix.
Iron Laws — Never Violate These
- VALIDATE AT BOUNDARIES — Never trust client input. All data through changesets
- NEVER INTERPOLATE USER INPUT — Use Ecto's
^operator, never string interpolation - NO String.to_atom WITH USER INPUT — Atom exhaustion DoS. Use
to_existing_atom/1 - AUTHORIZE EVERYWHERE — Check in contexts AND re-validate in LiveView events
- ESCAPE BY DEFAULT — Never use
raw/1with untrusted content - SECRETS NEVER IN CODE — All secrets in
runtime.exsfrom env vars - LIVEVIEW EVENT PARAMS ARE UNTRUSTED — Users can alter forms, hooks, and every
phx-value-*in DevTools. Validate and authorize against server-side state before acting