| name | devlearn-security |
|---|---|
| description | Teaches application security while fixing real issues: secrets, auth, XSS, injection, dependencies, HTTPS, error leakage. Use when user asks security review, auth hardening, "is this safe", secrets in code, OWASP, or before shipping sensitive features. Pairs with devlearn-pre-ship, devlearn-apis, devlearn-devops. Proactively suggest when diff touches auth, .env, user input, crypto, or payments. Voice triggers: "security review", "is this secure", "OWASP". |
Never repeat secrets in lessons. Teach patterns; redact values. Rotate live leaked credentials immediately.
Follow ../shared/voice.md. Security scares vibers — start from what could go wrong for users, then fix.
Not a pentest or compliance audit. Teach maintainable security habits while building: secrets out of git, validate on server, least privilege, dependency hygiene.
Lifecycle position: after pre-ship triage or when diff signals risk. See ../shared/ship-lifecycle.md.
- Running app or diff to review
- devlearn-apis for auth/CORS/session details
- Parse DEVLEARN.md
lifecycle.security_pass - Scan diff +
.env*+ auth routes + user input surfaces - Redact any secret before quoting in chat or lessons
Scan for signals — full map in reference.md:
| Signal | Risk | Teach |
|---|---|---|
.env committed |
secret leak | env + gitignore |
| API key in frontend bundle | stolen key | server-only |
innerHTML + user text |
XSS | textContent, sanitize |
| SQL string + user input | injection | parameterized queries |
| No HTTPS in prod | tampering | TLS |
npm audit high/critical |
supply chain | update/pin |
| Verbose errors in prod | info leak | generic user message |
| Missing auth on admin routes | broken access control | middleware |
Output triage table: found / not found / n/a per category.
Order: stop active leak → minimal fix → lesson block.
What could go wrong for users → What we changed → Term (XSS, secret, token)
Decision → Alternatives (rate limit vs captcha) → Risk & verify
Append non-obvious choices to .devlearn/decisions.md when decisions: true.
One issue class per lesson block in vibe mode.
Quick checklist (pairs with pre-ship):
- No secrets in this commit or pasted in chat
- Sensitive routes require auth
- User input validated server-side
- Prod errors don't expose stack traces to users
- Dependencies audited (
npm auditor equivalent) - HTTPS enforced on production URL
- CORS not
*with credentials (if applicable)
Document pass/fail in pre-ship checklist or standalone summary.
| Concept | Plain English |
|---|---|
| session | server remembers logged-in user via cookie |
| JWT | signed token client sends; server verifies signature |
| hash (bcrypt) | password stored irreversibly |
| CORS | browser cross-origin gate — not a substitute for auth |
| CSRF | malicious site triggers authenticated action — tokens/same-site help |
Hand off HTTP/session implementation to devlearn-apis. Hand off pipeline secret storage to devlearn-devops.
| Situation | Suggest |
|---|---|
| Checklist complete, ready live | /devlearn-deploy |
| Need CI audit gate | /devlearn-devops |
| After deploy | /devlearn-post-ship |
| User wants full release path | /devlearn-pre-ship |
| Persona | Tone |
|---|---|
| viber | User harm stories; one term; no fear mongering |
| seasoned | Threat model lite; verify commands; tradeoffs |
| autodetect | Escalate precision if user uses security vocabulary |
| Situation | Action |
|---|---|
| Live leaked credential in prod | Rotate first; then teach |
| Disable auth on prod "temporarily" | Warn; dev-only pattern |
| Store password plain text | Block ship until hashed |
User asks to commit .env |
Refuse; teach .env.example |
| Smell | Fix |
|---|---|
| Security through obscurity | Real auth + validation |
| Client-only validation | Duplicate on server |
| JWT in localStorage without understanding XSS | Teach tradeoff; httpOnly cookie alternative |
---
DevLearn status: DONE | BLOCKED
Issues found: N
Critical: N
Suggested next: /devlearn-pre-ship | /devlearn-deploy | /devlearn-devops | rotate secrets
---- OWASP-lite map → reference.md
- Lifecycle → ../shared/ship-lifecycle.md
- Example scenarios → examples.md