skills/security/SKILL.md
Guides secure development using defense-in-depth and attacker's mindset. ALWAYS trigger on "security review", "vulnerability", "authentication", "authorization", "input validation", "XSS", "SQL injection", "CSRF", "secrets management", "OWASP", "threat model", "security scan", "path traversal", "mass assignment", "privilege escalation", "security headers", "bandit", "dependency audit", "hardening". Use when implementing auth, handling user input, storing secrets, reviewing code for vulnerabilities, or preparing for production deployment. Different from devops skill which covers infrastructure; this covers application-level security patterns.
npx skillsauth add aj-geddes/unicorn-team securityInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Defense in Depth + Least Privilege. Layer multiple controls. Grant minimum permissions. Assume every layer can fail.
| # | Vulnerability | Key Defense |
|---|--------------|-------------|
| 1 | Broken Access Control | Auth check per resource, deny by default |
| 2 | Cryptographic Failures | Argon2/bcrypt, never MD5/SHA1 for passwords |
| 3 | Injection (SQL, XSS, Command) | Parameterized queries, escaping, allowlists |
| 4 | Insecure Design | Rate limiting, STRIDE threat modeling |
| 5 | Security Misconfiguration | Debug off in prod, generic error messages |
| 6 | Vulnerable Components | safety check / npm audit |
| 7 | Authentication Failures | Secure cookies, crypto-random session IDs |
| 8 | Data Integrity Failures | JSON with validation, never pickle |
| 9 | Logging Failures | Log security events, failed auth, admin actions |
| 10 | SSRF | URL allowlist, block internal IPs |
See references/owasp-top-10.md for detailed bad/good code examples per vulnerability.
Allowlist over Denylist:
# BAD: Denylist (easy to bypass)
if username in ['admin', 'root']:
raise ValueError()
# GOOD: Allowlist (explicit)
if not re.match(r'^[a-zA-Z0-9_]{3,20}$', username):
raise ValueError("Invalid format")
Layered Validation:
from pydantic import BaseModel, validator, constr
class UserInput(BaseModel):
username: constr(min_length=3, max_length=20, regex=r'^[a-zA-Z0-9_]+$')
email: str
age: int
@validator('email')
def validate_email(cls, v):
if not re.match(r'^[\w\.-]+@[\w\.-]+\.\w+$', v):
raise ValueError('Invalid email')
return v.lower()
@validator('age')
def validate_age(cls, v):
if not (0 <= v <= 150):
raise ValueError('Age 0-150')
return v
Context-Aware:
from markupsafe import escape
from urllib.parse import quote
html = f"<div>{escape(username)}</div>" # HTML context
url = f"https://example.com/search?q={quote(term)}" # URL context
js = f"var name = {json.dumps(username)};" # JS context
db.execute("SELECT * FROM users WHERE name = ?", [username]) # SQL: parameterize
# BAD: Hardcoded
API_KEY = "sk_live_abc123"
# GOOD: Environment with verification
import os
for secret in ['API_KEY', 'DATABASE_URL', 'SECRET_KEY']:
if secret not in os.environ:
raise RuntimeError(f"Missing: {secret}")
# .env (add to .gitignore, NEVER commit)
API_KEY=sk_live_abc123
# .env.example (commit this)
API_KEY=your_api_key_here
Production: Use AWS Secrets Manager, HashiCorp Vault, or platform-native secret stores.
from pathlib import Path
BASE_DIR = Path('/var/data')
file_path = (BASE_DIR / filename).resolve()
if not file_path.is_relative_to(BASE_DIR):
abort(403)
# BAD: user.update(**request.json) # Attack: {"is_admin": true}
ALLOWED = ['name', 'email', 'bio']
for field in ALLOWED:
if field in request.json:
setattr(user, field, request.json[field])
from flask_wtf.csrf import CSRFProtect
csrf = CSRFProtect(app)
app.config['SESSION_COOKIE_SAMESITE'] = 'Strict'
bandit -r src/ -f json -o report.json # Static analysis
safety check # Python dependency scan
npm audit # Node dependency scan
trivy image myapp:latest # Container scan
See references/security-tooling.md for pre-commit hooks, security headers config, and CI/CD integration.
Auth:
Input/Output:
Secrets & Crypto:
secrets module for random tokensMonitoring:
Config:
development
Guides the user through test-first development and test strategy decisions. ALWAYS trigger on "write tests", "TDD", "test coverage", "mock", "test fails", "flaky test", "how to test", "unit test", "integration test", "e2e test", "test structure", "what to test", "test organization", "coverage report", "testing strategy", "arrange act assert". Use when writing new tests, choosing test types, setting up mocking, debugging flaky tests, improving coverage, or designing testable code. Different from qa-security agent which focuses on code review and security audits rather than test authoring.
development
Guides deliberate management of technical debt: recognition, tracking, prioritization, and paydown. ALWAYS trigger on "technical debt", "code shortcut", "pay down debt", "debt tracking", "just for now", "temporary hack", "hardcoded value", "copy-paste code", "missing tests", "TODO cleanup", "refactor plan", "debt priority", "interest cost", "boy scout rule", "code quality backlog". Use when taking a shortcut, discovering suboptimal code, planning debt paydown, or quantifying ongoing cost of compromises.
development
Guides the user through systematic pre-commit quality verification. ALWAYS trigger on "review my code", "check my work", "before commit", "self-review", "quality check", "am I ready to commit", "pre-commit review", "code quality", "verify my changes", "sanity check", "review before merge", "is this ready". Use before any commit, merge, or code review submission.
tools
Guides Python development with modern idioms, tooling, and project structure. ALWAYS trigger on "python project", "pyproject.toml", "ruff", "mypy", "pytest", "poetry", "python setup", "type hints", "pydantic", "dataclass", "async python", "asyncio", "python anti-pattern", "python best practices", "python tooling", "python lint". Use when setting up Python projects, configuring tooling, choosing data modeling approaches, or writing tests. Different from testing skill which covers general test strategy; this covers Python-specific pytest patterns and tooling configs.