Security best practices for authentication, input validation, OWASP patterns, and secure coding. Use when handling user input, auth, secrets, or sensitive data.
View on GitHubFebruary 1, 2026
Select agents to install to:
npx add-skill https://github.com/mnthe/hardworker-marketplace/blob/main/plugins/ultrawork/skills/security-patterns/SKILL.md -a claude-code --skill security-patternsInstallation paths:
.claude/skills/security-patterns/# Security Patterns
Comprehensive security patterns and best practices for secure application development.
## When to Use
- Implementing authentication or authorization
- Handling user input or file uploads
- Working with secrets or environment variables
- Creating API endpoints
- Storing or transmitting sensitive data
- Integrating third-party services
## OWASP Top 10 Patterns
### 1. Broken Access Control
#### ❌ WRONG: Missing Authorization
```typescript
export async function DELETE(request: Request) {
const { userId } = await request.json()
// No authorization check - anyone can delete any user
await db.users.delete({ where: { id: userId } })
return NextResponse.json({ success: true })
}
```
#### ✅ CORRECT: Proper Authorization
```typescript
export async function DELETE(request: Request) {
const session = await getSession(request)
const { userId } = await request.json()
// Check if user is authorized
if (session.userId !== userId && session.role !== 'admin') {
return NextResponse.json(
{ error: 'Unauthorized' },
{ status: 403 }
)
}
await db.users.delete({ where: { id: userId } })
return NextResponse.json({ success: true })
}
```
### 2. Cryptographic Failures
#### ❌ WRONG: Hardcoded Secrets
```typescript
const JWT_SECRET = "my-super-secret-key"
const API_KEY = "sk-proj-xxxxxxxxxxxxx"
const DATABASE_URL = "postgresql://user:password@localhost/db"
```
#### ✅ CORRECT: Environment Variables
```typescript
// .env.local (never commit this file)
JWT_SECRET=use-a-strong-randomly-generated-secret
OPENAI_API_KEY=sk-proj-xxxxxxxxxxxxx
DATABASE_URL=postgresql://user:password@host/db
// app code
const jwtSecret = process.env.JWT_SECRET
if (!jwtSecret) {
throw new Error('JWT_SECRET environment variable not set')
}
const apiKey = process.env.OPENAI_API_KEY
if (!apiKey) {
throw new Error('OPENAI_API_KEY not configured')
}
```
**Verification Steps:**
- [ ] No secrets in source code
- [ ] `.env.local` in `.gitignore`
- [