Security Best Practices Skill
Overview
This skill provides security guidelines following OWASP Top 10, secure coding patterns, authentication/authorization best practices, secrets management, and vulnerability prevention across multiple languages.
OWASP Top 10 Summary
- Injection - Use parameterized queries, never concatenate user input into SQL/commands
- Broken Authentication - Implement strong passwords, secure sessions, rate limiting
- Sensitive Data Exposure - Encrypt data at rest, use HTTPS, hash passwords
- XML External Entities (XXE) - Disable external entities in XML parsers
- Broken Access Control - Enforce authorization checks, implement resource-level controls
- Security Misconfiguration - Secure defaults, minimal privileges, regular updates
- Cross-Site Scripting (XSS) - Escape output, sanitize input, use CSP headers
- Insecure Deserialization - Use JSON instead of pickle, validate data
- Known Vulnerabilities - Regular dependency scanning, keep components updated
- Insufficient Logging - Log security events, monitor for anomalies
Quick Security Checklist
Input Validation
Authentication
Authorization
Data Protection
Secrets Management
Common Vulnerabilities Prevention
SQL Injection
# ✅ SAFE: Parameterized query
cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))
# ❌ UNSAFE: String concatenation
query = f"SELECT * FROM users WHERE id = '{user_id}'"
XSS Prevention
# ✅ SAFE: Template auto-escaping
return render_template('profile.html', username=username)
# ❌ UNSAFE: Raw HTML
return f"<div>{user_input}</div>"
Command Injection
# ✅ SAFE: Use list, not shell
subprocess.run(["ls", "-la", directory], shell=False)
# ❌ UNSAFE: Shell with user input
os.system(f"ls -la {directory}")
Language-Specific Patterns
See detailed guides in references/:
- OWASP Top 10 Details - Comprehensive prevention for all 10 categories
- Secure Coding - Python - Python-specific security patterns
- Secure Coding - JavaScript - Node.js/Frontend security
- Secure Coding - Go - Go security patterns
- Secrets Management - AWS, Vault, GCP secret management
Security Headers
Always include these headers:
Strict-Transport-Security: max-age=31536000; includeSubDomains
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
Content-Security-Policy: default-src 'self'
Referrer-Policy: strict-origin-when-cross-origin
When to Use This Skill
Use this skill when:
- Implementing authentication and authorization systems
- Handling user input and data validation
- Setting up HTTPS and security headers
- Managing secrets and credentials
- Configuring CORS and CSP policies
- Reviewing code for security vulnerabilities
- Setting up logging and monitoring
- Configuring Docker and deployment security
Related Skills
@docker-patterns - Container security hardening
@ci-cd-pipelines - Security scanning in CI/CD
@api-rest-design - API security patterns
@postgresql-patterns - Database security
@feature-development - Secure development workflow
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: security-best-practices-133description: Security best practices, OWASP guidelines, secure coding patterns, and vulnerability prevention. Use when implementing authentication, handling user input, securing APIs, managing secrets, or reviewing code for security vulnerabilities. Use when this capability is needed.4---56# Security Best Practices Skill78## Overview910This skill provides security guidelines following OWASP Top 10, secure coding patterns, authentication/authorization best practices, secrets management, and vulnerability prevention across multiple languages.1112## OWASP Top 10 Summary13141. **Injection** - Use parameterized queries, never concatenate user input into SQL/commands152. **Broken Authentication** - Implement strong passwords, secure sessions, rate limiting163. **Sensitive Data Exposure** - Encrypt data at rest, use HTTPS, hash passwords174. **XML External Entities (XXE)** - Disable external entities in XML parsers185. **Broken Access Control** - Enforce authorization checks, implement resource-level controls196. **Security Misconfiguration** - Secure defaults, minimal privileges, regular updates207. **Cross-Site Scripting (XSS)** - Escape output, sanitize input, use CSP headers218. **Insecure Deserialization** - Use JSON instead of pickle, validate data229. **Known Vulnerabilities** - Regular dependency scanning, keep components updated2310. **Insufficient Logging** - Log security events, monitor for anomalies2425## Quick Security Checklist2627### Input Validation28- [ ] Validate all user input on server side29- [ ] Use allowlists, not denylists30- [ ] Sanitize data before display (prevent XSS)31- [ ] Validate file uploads (type, size, extension)3233### Authentication34- [ ] Use strong password requirements (12+ chars, complexity)35- [ ] Hash passwords with bcrypt/Argon2 (not MD5/SHA1)36- [ ] Implement rate limiting on login endpoints37- [ ] Use secure session management (HttpOnly, Secure, SameSite)3839### Authorization40- [ ] Check permissions on every request41- [ ] Implement principle of least privilege42- [ ] Use resource-level access controls43- [ ] Never rely on client-side checks4445### Data Protection46- [ ] Encrypt sensitive data at rest47- [ ] Use TLS 1.2+ for all connections48- [ ] Set security headers (HSTS, CSP, X-Frame-Options)49- [ ] Never log sensitive data (passwords, tokens, PII)5051### Secrets Management52- [ ] Use environment variables or secret managers53- [ ] Never commit secrets to version control54- [ ] Rotate secrets regularly55- [ ] Use different secrets per environment5657## Common Vulnerabilities Prevention5859### SQL Injection60```python61# ✅ SAFE: Parameterized query62cursor.execute("SELECT * FROM users WHERE id = %s", (user_id,))6364# ❌ UNSAFE: String concatenation65query = f"SELECT * FROM users WHERE id = '{user_id}'"66```6768### XSS Prevention69```python70# ✅ SAFE: Template auto-escaping71return render_template('profile.html', username=username)7273# ❌ UNSAFE: Raw HTML74return f"<div>{user_input}</div>"75```7677### Command Injection78```python79# ✅ SAFE: Use list, not shell80subprocess.run(["ls", "-la", directory], shell=False)8182# ❌ UNSAFE: Shell with user input83os.system(f"ls -la {directory}")84```8586## Language-Specific Patterns8788See detailed guides in references/:8990- **[OWASP Top 10 Details](references/owasp-top10.md)** - Comprehensive prevention for all 10 categories91- **[Secure Coding - Python](references/secure-coding-python.md)** - Python-specific security patterns92- **[Secure Coding - JavaScript](references/secure-coding-javascript.md)** - Node.js/Frontend security93- **[Secure Coding - Go](references/secure-coding-go.md)** - Go security patterns94- **[Secrets Management](references/secrets-management.md)** - AWS, Vault, GCP secret management9596## Security Headers9798Always include these headers:99100```101Strict-Transport-Security: max-age=31536000; includeSubDomains102X-Content-Type-Options: nosniff103X-Frame-Options: DENY104X-XSS-Protection: 1; mode=block105Content-Security-Policy: default-src 'self'106Referrer-Policy: strict-origin-when-cross-origin107```108109## When to Use This Skill110111Use this skill when:112- Implementing authentication and authorization systems113- Handling user input and data validation114- Setting up HTTPS and security headers115- Managing secrets and credentials116- Configuring CORS and CSP policies117- Reviewing code for security vulnerabilities118- Setting up logging and monitoring119- Configuring Docker and deployment security120121## Related Skills122123- `@docker-patterns` - Container security hardening124- `@ci-cd-pipelines` - Security scanning in CI/CD125- `@api-rest-design` - API security patterns126- `@postgresql-patterns` - Database security127- `@feature-development` - Secure development workflow128129---130> Converted and distributed by [TomeVault](https://tomevault.io/claim/jonathan0823) — claim your Tome and manage your conversions.131<!-- tomevault:4.0:skill_md:2026-04-13 -->