Loading...
Loading...
Compare original and translation side by side
.envSet.has().envSet.has()assets/output-report-template.mdassets/output-report-template.md/accelint-security-best-practices <path>- [ ] Phase 1: Discover - Identify security vulnerabilities through systematic code analysis
- [ ] Phase 2: Categorize - Classify issues by OWASP category and severity
- [ ] Phase 3: Remediate - Apply security patterns from references/
- [ ] Phase 4: Verify - Validate fixes and confirm vulnerability closure/accelint-security-best-practices <path>- [ ] Phase 1: Discover - Identify security vulnerabilities through systematic code analysis
- [ ] Phase 2: Categorize - Classify issues by OWASP category and severity
- [ ] Phase 3: Remediate - Apply security patterns from references/
- [ ] Phase 4: Verify - Validate fixes and confirm vulnerability closure| OWASP Category | Common Issues | Severity Range |
|---|---|---|
| A01: Broken Access Control | Missing auth, no ownership checks, IDOR | Critical-High |
| A02: Cryptographic Failures | Hardcoded secrets, weak hashing, insecure storage | Critical-Medium |
| A03: Injection | SQL, NoSQL, Command, XSS vulnerabilities | Critical-High |
| A04: Insecure Design | Missing rate limiting, no input validation | High-Medium |
| A05: Security Misconfiguration | Default configs, missing headers, dev mode in prod | High-Low |
| A06: Vulnerable Components | Outdated dependencies, known CVEs | Critical-Low |
| A07: Auth Failures | Weak session management, no MFA, credential stuffing | Critical-High |
| A08: Data Integrity Failures | Missing CSRF, unsigned updates | High-Medium |
| A09: Logging Failures | No security logging, insufficient monitoring | Medium-Low |
| A10: SSRF | Unvalidated URL fetching, internal network access | High-Medium |
| OWASP分类 | 常见问题 | 严重程度范围 |
|---|---|---|
| A01: 访问控制失效 | 缺失身份验证、无所有权检查、IDOR | 关键-高 |
| A02: 加密失败 | 硬编码密钥、弱哈希算法、不安全存储 | 关键-中 |
| A03: 注入 | SQL、NoSQL、命令注入、XSS漏洞 | 关键-高 |
| A04: 不安全设计 | 缺失速率限制、无输入验证 | 高-中 |
| A05: 安全配置错误 | 默认配置、缺失安全头、生产环境使用开发模式 | 高-低 |
| A06: 易受攻击的组件 | 过时依赖项、已知CVE | 关键-低 |
| A07: 身份验证失败 | 弱会话管理、无MFA、凭证填充攻击 | 关键-高 |
| A08: 数据完整性失败 | 缺失CSRF保护、未签名的更新 | 高-中 |
| A09: 日志记录失败 | 无安全日志、监控不足 | 中-低 |
| A10: SSRF | 未验证的URL请求、内部网络访问 | 高-中 |
| Category | MANDATORY Files | Optional | Do NOT Load |
|---|---|---|---|
| Secrets Management | secrets-management.md | — | all others |
| Input Validation | input-validation.md | file-uploads.md (for file upload features) | secrets, auth |
| Injection Prevention | injection-prevention.md | — | input validation, XSS |
| Authentication | authentication.md | mfa.md (for multi-factor auth features) | authorization, secrets |
| Authorization | authorization.md | — | authentication |
| XSS Prevention | xss-prevention.md | — | injection, CSRF |
| CSRF Protection | csrf-protection.md | — | XSS, auth |
| Rate Limiting | rate-limiting.md | — | auth, injection |
| Sensitive Data | sensitive-data.md | — | secrets, logging |
| Dependency Security | dependency-security.md | — | all others |
| Security Headers | security-headers.md | — | XSS, CSRF |
| SSRF Prevention | ssrf-prevention.md | — | injection, input validation |
// ❌ Before: SQL Injection vulnerability
const query = `SELECT * FROM users WHERE email = '${email}'`;
const user = await db.query(query);
// ✅ After: Parameterized query prevents injection
// Security: injection-prevention.md - parameterized queries
const user = await db.query(
'SELECT * FROM users WHERE email = $1',
[email]
);| 类别 | 必填文件 | 可选文件 | 禁止加载 |
|---|---|---|---|
| 密钥管理 | secrets-management.md | — | 所有其他文件 |
| 输入验证 | input-validation.md | file-uploads.md(针对文件上传功能) | 密钥管理、身份验证相关文件 |
| 注入防护 | injection-prevention.md | — | 输入验证、XSS防护相关文件 |
| 身份验证 | authentication.md | mfa.md(针对多因素身份验证功能) | 授权、密钥管理相关文件 |
| 授权 | authorization.md | — | 身份验证相关文件 |
| XSS防护 | xss-prevention.md | — | 注入防护、CSRF防护相关文件 |
| CSRF防护 | csrf-protection.md | — | XSS防护、身份验证相关文件 |
| 速率限制 | rate-limiting.md | — | 身份验证、注入防护相关文件 |
| 敏感数据保护 | sensitive-data.md | — | 密钥管理、日志记录相关文件 |
| 依赖项安全 | dependency-security.md | — | 所有其他文件 |
| 安全头配置 | security-headers.md | — | XSS防护、CSRF防护相关文件 |
| SSRF防护 | ssrf-prevention.md | — | 注入防护、输入验证相关文件 |
// ❌ 修复前:存在SQL注入漏洞
const query = `SELECT * FROM users WHERE email = '${email}'`;
const user = await db.query(query);
// ✅ 修复后:参数化查询防止注入
// Security: injection-prevention.md - parameterized queries
const user = await db.query(
'SELECT * FROM users WHERE email = $1',
[email]
);// Security fix applied: 2026-02-01
// Vulnerability: SQL injection via email parameter (Critical)
// OWASP Category: A03 - Injection
// Pattern: injection-prevention.md - parameterized queries
// Verified: All tests pass, manual SQL injection attempts blocked// Security fix applied: 2026-02-01
// Vulnerability: SQL injection via email parameter (Critical)
// OWASP Category: A03 - Injection
// Pattern: injection-prevention.md - parameterized queries
// Verified: All tests pass, manual SQL injection attempts blocked| Issue | ❌ Wrong Approach | ✅ Correct Approach |
|---|---|---|
| Parameterized queries break dynamic column sorting | Add try-catch, fall back to concatenation | Use column name whitelist: |
| Rate limiting breaks load tests | Disable rate limiting in test environment | Use separate rate limit config for tests based on environment detection |
| CSRF tokens break API integration tests | Skip CSRF validation in tests | Generate valid CSRF tokens in test setup using your CSRF library's token generation function |
| Input validation rejects legitimate edge cases | Loosen validation rules | Investigate the edge case - is it legitimate? If yes, update schema. If no, reject it. Real users shouldn't hit validation errors. |
| Authorization checks break admin impersonation | Skip auth checks for admin users | Implement proper impersonation: admin gets temporary token with target user's permissions, logged for audit |
| HTTPOnly cookies break mobile app auth | Store tokens in localStorage for mobile | Use secure token storage: iOS Keychain, Android Keystore, or platform-specific secure storage APIs |
| 问题 | ❌ 错误做法 | ✅ 正确做法 |
|---|---|---|
| 参数化查询破坏动态列排序 | 添加try-catch,回退到字符串拼接 | 使用列名白名单: |
| 速率限制破坏负载测试 | 在测试环境中禁用速率限制 | 根据环境检测,为测试环境使用单独的速率限制配置 |
| CSRF令牌破坏API集成测试 | 在测试中跳过CSRF验证 | 使用CSRF库的令牌生成函数在测试设置中生成有效的CSRF令牌 |
| 输入验证拒绝合法的边缘场景 | 放宽验证规则 | 调查边缘场景——是否合法?如果是,更新模式;如果否,拒绝该输入。真实用户不应触发验证错误。 |
| 授权检查破坏管理员模拟功能 | 为管理员用户跳过授权检查 | 实现正确的模拟机制:管理员获取具有目标用户权限的临时令牌,并记录该操作用于审计 |
| HTTPOnly Cookie破坏移动应用身份验证 | 为移动应用将令牌存储在localStorage中 | 使用安全令牌存储:iOS Keychain、Android Keystore或平台特定的安全存储API |
// SECURITY TRADE-OFF DOCUMENTED: 2026-02-01
// Issue: Rate limiting breaks webhook ingestion from trusted partner
// Decision: Exempt partner IP range from rate limiting
// Compensating controls:
// - IP whitelist strictly maintained (only 2 partner IPs)
// - Separate monitoring for partner traffic
// - Manual review of partner traffic daily
// - 30-day review scheduled to implement alternative solution
// Risk accepted by: [Name], [Title]// SECURITY TRADE-OFF DOCUMENTED: 2026-02-01
// Issue: Rate limiting breaks webhook ingestion from trusted partner
// Decision: Exempt partner IP range from rate limiting
// Compensating controls:
// - IP whitelist strictly maintained (only 2 partner IPs)
// - Separate monitoring for partner traffic
// - Manual review of partner traffic daily
// - 30-day review scheduled to implement alternative solution
// Risk accepted by: [Name], [Title]| Vulnerability Severity | Freedom Level | Guidance Format | Example |
|---|---|---|---|
| Critical (data breach, RCE) | Low freedom | Exact pattern from reference, no deviation | "Use parameterized query: |
| High (unauthorized access) | Medium freedom | Pattern with examples, verify coverage | "Implement RBAC or ownership checks before resource access" |
| Medium (defense in depth) | Medium freedom | Multiple valid approaches, pick based on architecture | "Use rate limiting with express-rate-limit or implement custom middleware" |
| Low (best practices) | High freedom | General guidance, implementation varies | "Consider adding security headers for defense in depth" |
| 漏洞严重程度 | 自由度 | 指导格式 | 示例 |
|---|---|---|---|
| 关键(数据泄露、远程代码执行) | 低自由度 | 参考文件中的精确模式,不允许偏离 | "使用参数化查询: |
| 高风险(未授权访问) | 中等自由度 | 带示例的模式,需验证覆盖范围 | "在访问资源前实现RBAC或所有权检查" |
| 中风险(纵深防御) | 中等自由度 | 多种有效方案,根据架构选择 | "使用express-rate-limit实现速率限制,或自定义中间件" |
| 低风险(最佳实践) | 高自由度 | 通用指导,实现方式灵活 | "考虑添加安全头以增强纵深防御" |
| If You See... | Vulnerability Type | OWASP Category | Typical Severity |
|---|---|---|---|
| API key, password, or token in source code | Hardcoded secrets | A02: Cryptographic Failures | Critical |
| User input directly in SQL/NoSQL query | Injection vulnerability | A03: Injection | Critical |
No | Missing authentication | A01: Broken Access Control | Critical |
| No ownership/permission check before resource access | Missing authorization | A01: Broken Access Control | High |
JWT token in | Insecure token storage | A07: Auth Failures | High |
| User input without schema validation | Missing input validation | A04: Insecure Design | High |
No rate limiting on | Missing rate limiting | A04: Insecure Design | High |
| XSS vulnerability | A03: Injection | High |
| State-changing operation without CSRF token | Missing CSRF protection | A08: Data Integrity Failures | High |
Password, token, or PII in | Sensitive data in logs | A09: Logging Failures | Medium |
| Stack trace or database error sent to user | Information leakage | A05: Security Misconfiguration | Medium |
| Vulnerable dependencies | A06: Vulnerable Components | Critical-Low (varies) |
| SSRF vulnerability | A10: SSRF | High |
| No security headers (CSP, HSTS) | Missing security headers | A05: Security Misconfiguration | Medium |
| Sequential user IDs without ownership check | IDOR vulnerability | A01: Broken Access Control | High |
| Permissive CORS | A05: Security Misconfiguration | Medium |
| Dev mode in production | A05: Security Misconfiguration | Medium-Low |
| 如果发现... | 漏洞类型 | OWASP分类 | 典型严重程度 |
|---|---|---|---|
| 源代码中的API密钥、密码或令牌 | 硬编码密钥 | A02: 加密失败 | 关键 |
| 用户输入直接嵌入SQL/NoSQL查询 | 注入漏洞 | A03: 注入 | 关键 |
受保护路由上缺失 | 缺失身份验证 | A01: 访问控制失效 | 关键 |
| 访问资源前缺失所有权/权限检查 | 缺失授权 | A01: 访问控制失效 | 高 |
JWT令牌存储在 | 不安全的令牌存储 | A07: 身份验证失败 | 高 |
| 用户输入未经过模式验证 | 缺失输入验证 | A04: 不安全设计 | 高 |
| 缺失速率限制 | A04: 不安全设计 | 高 |
| XSS漏洞 | A03: 注入 | 高 |
| 状态变更操作缺失CSRF令牌 | 缺失CSRF保护 | A08: 数据完整性失败 | 高 |
| 日志中的敏感数据 | A09: 日志记录失败 | 中 |
| 向用户返回堆栈跟踪或数据库错误 | 信息泄露 | A05: 安全配置错误 | 中 |
| 易受攻击的依赖项 | A06: 易受攻击的组件 | 关键-低(视情况而定) |
| SSRF漏洞 | A10: SSRF | 高 |
| 缺失安全头(CSP、HSTS) | 缺失安全头 | A05: 安全配置错误 | 中 |
| 连续用户ID未经过所有权检查 | IDOR漏洞 | A01: 访问控制失效 | 高 |
生产环境中 | 宽松的CORS策略 | A05: 安全配置错误 | 中 |
缺失 | 生产环境使用开发模式 | A05: 安全配置错误 | 中-低 |