mirror of
https://github.com/duthaho/claudekit.git
synced 2026-06-10 12:14:57 +03:00
3.5 KiB
3.5 KiB
name, description
| name | description |
|---|---|
| owasp | Use when reviewing code for security vulnerabilities, implementing authentication or authorization flows, handling user input validation, or building web endpoints exposed to untrusted data. Trigger on keywords like XSS, SQL injection, CSRF, input sanitization, password hashing, and security headers. Also apply when auditing existing code for OWASP Top 10 compliance or conducting security-focused code reviews. |
OWASP Security Patterns
When to Use
- Reviewing code for OWASP Top 10 vulnerabilities
- Implementing input validation on user-facing endpoints
- Adding security headers (CSP, HSTS, X-Frame-Options)
- Preventing XSS, SQL injection, CSRF, or SSRF
- Auditing authentication or authorization flows
- Building endpoints that handle untrusted data
When NOT to Use
- Infrastructure security (network, firewall, cloud IAM) — use platform-specific tools
- Cryptographic algorithm selection — consult cryptography experts
- Compliance frameworks (SOC 2, HIPAA) — security patterns help but don't cover audit requirements
Quick Reference
| Topic | Reference | Key content |
|---|---|---|
| All security patterns | references/patterns.md |
Input validation, SQL injection, XSS, CSRF, auth, headers |
| OWASP Top 10 cheatsheet | references/owasp-top10-cheatsheet.md |
Quick reference for each vulnerability category |
| Security headers | references/security-headers.md |
CSP, HSTS, X-Frame-Options, Referrer-Policy |
| Security checklist | references/security-checklist.md |
Pre-deploy security review checklist |
| Security audit script | references/security-audit.py |
Automated security scanning utility |
Best Practices
- Validate all input at the boundary. Use Pydantic (Python) or Zod (TypeScript) for schema validation. Never trust client-side validation alone.
- Use parameterized queries exclusively. Never concatenate user input into SQL strings. Use ORM query builders or prepared statements.
- Encode output based on context. HTML-encode for HTML, URL-encode for URLs, JSON-encode for JSON. No single encoding fits all contexts.
- Set security headers on every response. CSP, HSTS, X-Frame-Options, X-Content-Type-Options, Referrer-Policy.
- Use CSRF tokens for state-changing requests. Every POST/PUT/DELETE from a browser form needs a CSRF token.
- Apply rate limiting to all public endpoints. Especially authentication, registration, and password reset.
- Never expose stack traces or internal errors to clients. Return generic error messages; log details server-side.
- Audit dependencies regularly. Run
npm audit/pip-audit/safety checkin CI.
Common Pitfalls
- Relying on client-side validation only — easily bypassed with curl or browser devtools.
- Using
dangerouslySetInnerHTMLor| safewithout sanitization — XSS vector. - SQL string concatenation — even "just for this one query" is a SQL injection risk.
- Missing CSRF protection on API routes — if cookies are used for auth, CSRF applies.
- Overly permissive CORS —
Access-Control-Allow-Origin: *with credentials is a security hole. - Logging sensitive data — passwords, tokens, and PII in logs persist in storage and backups.
Related Skills
authentication— Secure auth implementation patternserror-handling— Preventing information leakage through errorsbackend-frameworks— Framework-specific security middleware