Loading...
Loading...
Compare original and translation side by side
Security Basics:
- [ ] Authentication required for protected routes
- [ ] Passwords hashed (bcrypt/argon2), never stored plain text
- [ ] API keys in environment variables, not code
- [ ] HTTPS only in production
- [ ] Input validated on server side
- [ ] SQL injection prevented (use parameterized queries)
- [ ] XSS prevented (sanitize user input)
- [ ] CSRF tokens on forms
- [ ] Rate limiting on API endpoints
- [ ] User sessions expire (30min-1hr typical)Security Basics:
- [ ] 受保护路由需身份验证
- [ ] 密码已哈希处理(bcrypt/argon2),绝不明文存储
- [ ] API密钥存储在环境变量中,而非代码里
- [ ] 生产环境仅使用HTTPS
- [ ] 服务器端验证输入
- [ ] 防止SQL注入(使用参数化查询)
- [ ] 防止XSS攻击(清理用户输入)
- [ ] 表单添加CSRF令牌
- [ ] API端点设置速率限制
- [ ] 用户会话自动过期(通常30分钟-1小时)Store API keys in .env file, not in code.
Add .env to .gitignore.
Access via process.env.API_KEYStore API keys in .env file, not in code.
Add .env to .gitignore.
Access via process.env.API_KEYAdd authentication:
- bcrypt for password hashing (12 rounds)
- Email verification required
- Session timeout: 30 minutes
- Password requirements: 8+ chars, 1 number, 1 symbolAdd authentication:
- bcrypt for password hashing (12 rounds)
- Email verification required
- Session timeout: 30 minutes
- Password requirements: 8+ chars, 1 number, 1 symbolNever log sensitive data.
Replace passwords/tokens with "[REDACTED]" in logs.Never log sensitive data.
Replace passwords/tokens with "[REDACTED]" in logs.Add to all API routes:
- Require valid auth token
- Rate limit: 100 requests/minute per IP
- Validate all inputs (reject invalid)
- Generic error messages (no stack traces to users)Add to all API routes:
- Require valid auth token
- Rate limit: 100 requests/minute per IP
- Validate all inputs (reject invalid)
- Generic error messages (no stack traces to users)Add authentication to this route.
Require valid JWT token.
Return 401 if missing/invalid.
Don't expose error details.Add rate limiting:
- 100 requests/minute per IP
- Return 429 "Too many requests" if exceeded
- Use sliding window, not fixedValidate all user inputs:
- Email: valid format
- Password: 8+ chars, 1 number, 1 symbol
- Username: alphanumeric only, 3-20 chars
Reject invalid input with clear error messageAdd authentication to this route.
Require valid JWT token.
Return 401 if missing/invalid.
Don't expose error details.Add rate limiting:
- 100 requests/minute per IP
- Return 429 "Too many requests" if exceeded
- Use sliding window, not fixedValidate all user inputs:
- Email: valid format
- Password: 8+ chars, 1 number, 1 symbol
- Username: alphanumeric only, 3-20 chars
Reject invalid input with clear error messageProduction Security:
- [ ] All secrets in environment variables
- [ ] HTTPS enforced (no HTTP)
- [ ] Database backups configured
- [ ] Rate limiting on all APIs
- [ ] Error pages don't show stack traces
- [ ] Admin routes protected
- [ ] File uploads validated (type, size)
- [ ] CORS configured (not wildcard "*")Production Security:
- [ ] 所有密钥存储在环境变量中
- [ ] 强制使用HTTPS(禁止HTTP)
- [ ] 配置数据库备份
- [ ] 所有API设置速率限制
- [ ] 错误页面不显示堆栈跟踪
- [ ] 管理员路由受保护
- [ ] 文件上传已验证(类型、大小)
- [ ] CORS已配置(非通配符"*")| Mistake | Fix |
|---|---|
| API keys in code | Move to .env |
| No rate limiting | Add to all endpoints |
| Plain text passwords | Use bcrypt |
| HTTP in production | Force HTTPS |
| Accepting all CORS | Whitelist domains |
| No input validation | Validate server-side |
| Detailed error messages | Generic messages only |
| 错误 | 修复方案 |
|---|---|
| API密钥在代码中 | 转移到.env |
| 无速率限制 | 为所有端点添加 |
| 明文密码 | 使用bcrypt |
| 生产环境使用HTTP | 强制HTTPS |
| 接受所有CORS请求 | 白名单域名 |
| 无输入验证 | 服务器端验证 |
| 详细错误信息 | 仅使用通用信息 |
Add helmet.js for security headers.
Configure for production (HTTPS, CSP, XSS protection).Add helmet.js for security headers.
Configure for production (HTTPS, CSP, XSS protection).grep -r "api_key" src/
grep -r "password" src/grep -r "api_key" src/
grep -r "password" src/
**No auth bypass:**
- Try accessing protected routes without login
- Should redirect to login or return 401
**Rate limiting works:**
- Hit API endpoint 100 times quickly
- Should get 429 error
---
**身份验证绕过检查:**
- 尝试无需登录访问受保护路由
- 应重定向到登录页或返回401
**速率限制有效性检查:**
- 快速调用API端点100次
- 应收到429错误
---