| name | security-checklist |
| description | Security checklist for web applications. Use when reviewing code security, implementing authentication, handling user input, or working with sensitive data. Covers OWASP Top 10, secrets detection, and security best practices. |
Security Checklist
Comprehensive security checklist for identifying and preventing vulnerabilities in web applications.
Quick Security Scan
Before committing code, verify:
OWASP Top 10 Checklist
1. Injection (SQL, NoSQL, Command)
Red Flags:
db.query(`SELECT * FROM users WHERE id = ${userId}`)
db.query("DELETE FROM posts WHERE id = " + postId)
exec(`git log --author=${username}`)
Secure Patterns:
db.query('SELECT * FROM users WHERE id = ?', [userId])
db.query('DELETE FROM posts WHERE id = $1', [postId])
const safeUsername = escapeShellArg(username)
exec(`git log --author=${safeUsername}`)
Checklist:
2. Broken Authentication
Red Flags:
const hash = md5(password)
const hash = sha1(password)
jwt.verify(token)
jwt.sign(data, 'hardcoded-secret')
session.id = req.query.sessionId
Secure Patterns:
import bcrypt from 'bcrypt'
const hash = await bcrypt.hash(password, 10)
const secret = process.env.JWT_SECRET
jwt.verify(token, secret, { algorithms: ['HS256'] })
session.regenerate()
Checklist:
3. Sensitive Data Exposure
Red Flags:
const apiKey = "sk-proj-xxxxx"
const dbPassword = "admin123"
console.log('User data:', { password, ssn })
logger.info(`API Key: ${apiKey}`)
fetch(`/api/user?ssn=${ssn}&creditCard=${cc}`)
Secure Patterns:
const apiKey = process.env.OPENAI_API_KEY
if (!apiKey) throw new Error('Missing API key')
console.log('User data:', { id, email })
logger.info('API call successful')
fetch('/api/user', {
method: 'POST',
body: JSON.stringify({ ssn, creditCard })
})
Checklist:
4. XML External Entities (XXE)
Checklist:
5. Broken Access Control
Red Flags:
app.delete('/api/users/:id', async (req, res) => {
await db.deleteUser(req.params.id)
})
const file = req.query.file
fs.readFile(`/uploads/${file}`)
Secure Patterns:
app.delete('/api/users/:id', auth, async (req, res) => {
if (req.user.id !== req.params.id && !req.user.isAdmin) {
return res.status(403).json({ error: 'Forbidden' })
}
await db.deleteUser(req.params.id)
})
const fileId = req.query.fileId
const file = await db.getFile(fileId, req.user.id)
Checklist:
6. Security Misconfiguration
Checklist:
7. Cross-Site Scripting (XSS)
Red Flags:
element.innerHTML = userInput
dangerouslySetInnerHTML={{ __html: comment }}
eval(userCode)
Secure Patterns:
element.textContent = userInput
<div>{comment}</div> // React escapes by default
res.setHeader('Content-Security-Policy', "default-src 'self'")
Checklist:
8. Insecure Deserialization
Checklist:
9. Using Components with Known Vulnerabilities
Commands:
npm audit
npm audit --audit-level=high
npm audit fix
Checklist:
10. Insufficient Logging & Monitoring
Checklist:
Secrets Detection
Common Secret Patterns
grep -r "api[_-]?key\|password\|secret\|token" \
--include="*.js" --include="*.ts" --include="*.json" .
git log -p | grep -i "password\|api_key\|secret"
npx trufflehog filesystem . --json
Secret Patterns to Flag
- API keys:
sk-, pk_, api_key
- Tokens:
ghp_, gho_, token
- Passwords:
password=, pwd=
- Private keys:
-----BEGIN PRIVATE KEY-----
- Database URLs:
postgresql://, mongodb:// with credentials
Security Tools
Dependency Scanning
npm audit
npm audit fix
npm audit --audit-level=high
Static Analysis
npx eslint . --plugin security
npx semgrep --config auto .
Secrets Scanning
npx trufflehog filesystem . --json
git-secrets --scan
Quick Reference
Must-Have Security Headers
app.use(helmet())
res.setHeader('X-Frame-Options', 'DENY')
res.setHeader('X-Content-Type-Options', 'nosniff')
res.setHeader('Strict-Transport-Security', 'max-age=31536000')
res.setHeader('Content-Security-Policy', "default-src 'self'")
Environment Variables Checklist
OPENAI_API_KEY=sk-...
DATABASE_URL=postgresql://...
JWT_SECRET=random-secret-here
.env
.env.local
.env.*.local
Rate Limiting
import rateLimit from 'express-rate-limit'
const limiter = rateLimit({
windowMs: 15 * 60 * 1000,
max: 100
})
app.use('/api/', limiter)
When to Use This Checklist
- ✅ Before committing code
- ✅ During code reviews
- ✅ After implementing authentication
- ✅ When handling user input
- ✅ Before deploying to production
- ✅ When adding new API endpoints
- ✅ After dependency updates
Security Review Workflow
-
Run automated tools
npm audit
- eslint-plugin-security
- grep for secrets
-
Check high-risk areas
- Authentication code
- API endpoints with user input
- Database queries
- File uploads
- Payment processing
-
Verify OWASP Top 10
- Go through checklist above
- Test each category
-
Review findings
- Fix CRITICAL immediately
- Plan HIGH severity fixes
- Document MEDIUM issues
Common Vulnerabilities Summary
| Vulnerability | Detection | Fix |
|---|
| Hardcoded secrets | grep, git log | Move to .env |
| SQL injection | Code review | Parameterized queries |
| XSS | Code review | Escape output |
| Missing auth | Code review | Add auth middleware |
| Weak passwords | Code review | Use bcrypt |
| Insecure JWT | Code review | Proper validation |
| Path traversal | Code review | Validate paths |
| CORS misconfigured | Headers check | Configure properly |
Resources