security-essentials
Installation
SKILL.md
Security Essentials
RULES — Follow these with no exceptions
- Never use
String.to_atom/1on user input — atoms are never garbage collected; user-controlled atoms exhaust the atom table and crash the BEAM VM.String.to_existing_atom/1avoids that risk but still raisesArgumentErroron unknown input (unhandled 500) — whitelist with acaseinstead of either - Never interpolate strings into
fragment()orSQL.query()— always use?parameters for fragments and$1for raw SQL - Never redirect to user-controlled URLs — validate against a whitelist or use verified routes (
~p"...") - Avoid
raw/1in templates — Phoenix auto-escapes for a reason; if HTML is required, sanitize first with a library like HtmlSanitizeEx - Never log sensitive data — passwords, tokens, secrets, API keys, and credentials must never appear in Logger calls
- Use
Plug.Crypto.secure_compare/2for token comparison — never==, which enables timing attacks - Run dependency audits after changes —
mix hex.auditchecks for retired/deprecated packages (checksum verification against Hex is already automatic viamix.lock);mix deps.audit(requires adding{:mix_audit, "~> 2.1", only: [:dev, :test], runtime: false}) checks for known CVEs;mix sobelowdoes static security analysis of your code
Atom Table Exhaustion
The BEAM atom table has a fixed limit (default ~1M atoms) and is never garbage collected. If an attacker can create arbitrary atoms, they crash the entire VM.