Skip to content

Latest commit

 

History

History
147 lines (104 loc) · 4.89 KB

File metadata and controls

147 lines (104 loc) · 4.89 KB
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".

DevLearn: Security

Iron law

Never repeat secrets in lessons. Teach patterns; redact values. Rotate live leaked credentials immediately.

Voice

Follow ../shared/voice.md. Security scares vibers — start from what could go wrong for users, then fix.

Context

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.

Prerequisites

  • Running app or diff to review
  • devlearn-apis for auth/CORS/session details

Before you start

  1. Parse DEVLEARN.md lifecycle.security_pass
  2. Scan diff + .env* + auth routes + user input surfaces
  3. Redact any secret before quoting in chat or lessons

Phase 1: Triage

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.

Phase 2: Fix + teach

Order: stop active leak → minimal fix → lesson block.

Viber lesson shape

What could go wrong for usersWhat we changedTerm (XSS, secret, token)

Seasoned decision shape

DecisionAlternatives (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.

Phase 3: Pre-release security pass

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 audit or equivalent)
  • HTTPS enforced on production URL
  • CORS not * with credentials (if applicable)

Document pass/fail in pre-ship checklist or standalone summary.

Phase 4: Auth teaching (on request)

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.

Phase 5: Handoffs

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 integration

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

Red flags — STOP

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

Common mistakes

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

Required footer

---
DevLearn status: DONE | BLOCKED
Issues found: N
Critical: N
Suggested next: /devlearn-pre-ship | /devlearn-deploy | /devlearn-devops | rotate secrets
---

Additional resources