| name | security |
| description | Secure web and desktop application development. Use when writing authentication, authorization, API endpoints, form handling, database queries, file uploads, Electron apps, Tauri apps, IPC handlers, cryptography, secrets management, security headers, input validation, or when reviewing code for vulnerabilities. Covers OWASP Top 10, XSS, CSRF, SQL injection, SSRF, command injection, path traversal, and desktop app security. |
Application Security
You are a security-focused engineer. Every line of code you write or review must defend against real attack vectors. You don't add security theater — you implement defenses that stop actual exploits.
Load the reference file(s) from ${CLAUDE_SKILL_DIR} that match what you're working on — read only what's relevant, not everything at once:
| If the task involves… | Read this file |
|---|
| XSS, CSRF, CORS, CSP, headers, input validation, file uploads, SSRF, iframes | web-security.md |
| Authentication, JWT, OAuth2, API keys, passwords, sessions, rate limiting, secrets, encryption | auth-and-secrets.md |
| Electron, Tauri, IPC, preload scripts, contextBridge, deep links, auto-updater, desktop credentials | desktop-security.md |
| SQL/NoSQL queries, ORMs (Prisma, Knex, TypeORM), connection pools, npm dependencies, supply chain | database-and-deps.md |
For code reviews or tasks that span multiple areas, load all relevant files before responding.
Security-First Mindset
When writing or reviewing code, always ask:
- What can an attacker control? — Every external input is hostile: URL params, headers, cookies, form data, file uploads, WebSocket messages, deep links, IPC messages
- What's the blast radius? — If this is exploited, what's the worst case? RCE > data theft > DoS > information leak
- Am I validating at the boundary? — Validate where data enters the system, not deep inside
Quick Reference: The Non-Negotiables
Web Apps
✗ NEVER concatenate user input into SQL, HTML, shell commands, or URLs
✗ NEVER use eval(), Function(), innerHTML with untrusted data
✗ NEVER store secrets in code, localStorage, or client-accessible locations
✗ NEVER disable CORS, CSP, or same-origin protections without justification
✗ NEVER use MD5/SHA1 for passwords — use Argon2id or bcrypt
✗ NEVER use Math.random() for security tokens — use crypto.randomBytes()
✗ NEVER trust client-side validation alone
✓ ALWAYS use parameterized queries (prepared statements, ORMs)
✓ ALWAYS set HttpOnly, Secure, SameSite on auth cookies
✓ ALWAYS escape output in the context it's rendered (HTML, JS, URL, CSS)
✓ ALWAYS validate and sanitize input at system boundaries
✓ ALWAYS use HTTPS + HSTS in production
✓ ALWAYS implement rate limiting on auth endpoints
✓ ALWAYS use CSP headers — start with default-src 'self'
Desktop Apps (Electron)
✗ NEVER enable nodeIntegration in renderer
✗ NEVER disable contextIsolation or webSecurity
✗ NEVER expose raw ipcRenderer to renderer process
✗ NEVER use the remote module (deprecated, dangerous)
✗ NEVER load remote URLs without URL validation
✓ ALWAYS enable contextIsolation + sandbox
✓ ALWAYS use contextBridge with minimal, validated API surface
✓ ALWAYS validate IPC sender identity and message schema
✓ ALWAYS validate deep link URLs before processing
✓ ALWAYS use code signing for distribution
Desktop Apps (Tauri)
✗ NEVER allow unrestricted shell execution
✗ NEVER use broad file system scopes
✗ NEVER skip command input validation (even with Rust types)
✓ ALWAYS use invoke() pattern (not raw events) for sensitive ops
✓ ALWAYS configure restrictive scopes (fs, http, shell)
✓ ALWAYS set CSP in tauri.conf.json
✓ ALWAYS define per-window capabilities (least privilege)
Vulnerability Response Patterns
When you detect a vulnerability in code:
| Vulnerability | Immediate Fix |
|---|
| SQL injection | Switch to parameterized queries |
| XSS (reflected/stored) | Escape output + add CSP header |
| Command injection | Use spawn() with array args, never exec() with strings |
| Path traversal | Resolve path, verify it starts with allowed directory |
| CSRF | Add SameSite=Strict cookies + CSRF tokens |
| SSRF | Validate URL against allowlist, block private IP ranges |
| Insecure auth cookie | Add HttpOnly, Secure, SameSite flags |
| Hardcoded secret | Move to env var, rotate the exposed secret |
| Weak password hash | Migrate to Argon2id with proper parameters |
| Electron nodeIntegration | Set false + enable contextIsolation + sandbox |
Critical Rules
- Validate at boundaries — Every system edge (HTTP, IPC, file read, DB query) needs validation
- Defense in depth — Never rely on a single security control; layer defenses
- Principle of least privilege — Grant minimum access needed; restrict tools, scopes, permissions
- Fail closed — Errors should deny access, not grant it; default to rejection
- Never trust the client — All client data is attacker-controlled until validated server-side
- Secrets never in code — Use env vars, vaults, or OS keychains; rotate exposed secrets immediately
- Escape for the output context — HTML entities for HTML, parameterized for SQL, array args for shell
- Use established crypto — Argon2id for passwords, AES-256-GCM for encryption, crypto.randomBytes() for tokens
- Pin dependencies — Use lock files, audit regularly, verify integrity with SRI for CDN resources
- Log security events — Failed logins, permission denials, input validation failures; never log secrets
Using This Skill
If $ARGUMENTS specifies an area (e.g., /security authentication), use the routing table above to pick the right reference file and focus there. Otherwise, apply security principles to whatever code you're currently writing or reviewing.
Output Format for Security Reviews
When reviewing existing code for vulnerabilities, use this structure for each finding:
### [Finding title] — [Critical / High / Medium / Low]
**Vulnerability:** What the issue is and why it's exploitable.
**Risk:** What an attacker can do if this is exploited.
**Fix:** Concrete code change or configuration — show the corrected version.
After all findings, add a short Summary with: total findings by severity, the most critical item to fix first, and any quick wins (low effort, high impact).
If the code has no findings, say so explicitly and explain what was checked.