aif-security-checklist
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSecurity Checklist
安全审计清单
Comprehensive security checklist based on OWASP Top 10 (2021) and industry best practices.
基于OWASP Top 10(2021)及行业最佳实践的全面安全审计清单。
Quick Reference
快速参考
- — Full audit checklist
/aif-security-checklist - — Authentication & sessions
/aif-security-checklist auth - — SQL/NoSQL/Command injection
/aif-security-checklist injection - — Cross-site scripting
/aif-security-checklist xss - — Cross-site request forgery
/aif-security-checklist csrf - — Secrets & credentials
/aif-security-checklist secrets - — API security
/aif-security-checklist api - — Infrastructure security
/aif-security-checklist infra - — LLM prompt injection
/aif-security-checklist prompt-injection - — Race conditions & TOCTOU
/aif-security-checklist race-condition - — Ignore a specific check item
/aif-security-checklist ignore <item>
- — 完整审计清单
/aif-security-checklist - — 身份认证与会话管理
/aif-security-checklist auth - — SQL/NoSQL/命令注入防护
/aif-security-checklist injection - — 跨站脚本攻击(XSS)防护
/aif-security-checklist xss - — 跨站请求伪造(CSRF)防护
/aif-security-checklist csrf - — 密钥与凭证管理
/aif-security-checklist secrets - — API安全
/aif-security-checklist api - — 基础设施安全
/aif-security-checklist infra - — LLM提示注入防护
/aif-security-checklist prompt-injection - — 竞争条件与TOCTOU防护
/aif-security-checklist race-condition - — 忽略特定检查项
/aif-security-checklist ignore <item>
Ignored Items (SECURITY.md)
忽略项(SECURITY.md)
Before running any audit, always read the file in the project root. If it exists, it contains a list of security checks the team has decided to ignore.
.ai-factory/SECURITY.md在执行任何审计前,请务必阅读项目根目录下的文件。若该文件存在,其中包含团队决定忽略的安全检查项列表。
.ai-factory/SECURITY.mdHow ignoring works
忽略机制说明
When the user runs :
/aif-security-checklist ignore <item>- Read the current file (create if doesn't exist)
.ai-factory/SECURITY.md - Ask the user for the reason why this item should be ignored
- Add the item to the file following the format below
- Confirm the item was added
When running any audit ( or a specific category):
/aif-security-checklist- Read at the start
.ai-factory/SECURITY.md - For each ignored item that matches the current audit scope:
- Do NOT flag it as a finding
- Instead, show it in a separate section at the end: "⏭️ Ignored Items"
- Display each ignored item with its reason and date, so the team stays aware
- Non-ignored items are audited as usual
当用户执行时:
/aif-security-checklist ignore <item>- 读取当前文件(若不存在则创建)
.ai-factory/SECURITY.md - 询问用户忽略该检查项的原因
- 按照以下格式将该检查项添加至文件中
- 确认检查项已添加
当执行任何审计(或特定分类)时:
/aif-security-checklist- 首先读取文件
.ai-factory/SECURITY.md - 对于每个匹配当前审计范围的忽略项:
- 不会将其标记为问题
- 而是在末尾的单独部分显示:「⏭️ 已忽略项」
- 展示每个忽略项及其原因和日期,以便团队持续关注
- 未被忽略的检查项将按常规流程审计
.ai-factory/SECURITY.md
format
.ai-factory/SECURITY.md.ai-factory/SECURITY.md
格式
.ai-factory/SECURITY.mdmarkdown
undefinedmarkdown
undefinedSecurity: Ignored Items
Security: Ignored Items
Items below are excluded from security-checklist audits.
Review periodically — ignored risks may become relevant.
| Item | Reason | Date | Author |
|---|---|---|---|
| no-csrf | SPA with token auth, no cookies used | 2025-03-15 | @dev |
| no-rate-limit | Internal microservice, behind API gateway | 2025-03-15 | @dev |
**Item naming convention** — use short kebab-case IDs:
- `no-csrf` — CSRF tokens not implemented
- `no-rate-limit` — Rate limiting not configured
- `no-https` — HTTPS not enforced
- `no-xss-csp` — CSP header missing
- `no-sql-injection` — SQL injection not fully prevented
- `no-prompt-injection` — LLM prompt injection not mitigated
- `no-race-condition` — Race condition prevention missing
- `no-secret-rotation` — Secrets not rotated
- `no-auth-{route}` — Auth missing on specific route
- `verbose-errors` — Detailed errors exposed
- Or any custom descriptive IDItems below are excluded from security-checklist audits.
Review periodically — ignored risks may become relevant.
| Item | Reason | Date | Author |
|---|---|---|---|
| no-csrf | SPA with token auth, no cookies used | 2025-03-15 | @dev |
| no-rate-limit | Internal microservice, behind API gateway | 2025-03-15 | @dev |
**检查项命名规范** — 使用短横线分隔的小写ID:
- `no-csrf` — 未实现CSRF令牌
- `no-rate-limit` — 未配置速率限制
- `no-https` — 未强制使用HTTPS
- `no-xss-csp` — 缺失CSP头
- `no-sql-injection` — 未完全防止SQL注入
- `no-prompt-injection` — 未缓解LLM提示注入
- `no-race-condition` — 缺失竞争条件防护
- `no-secret-rotation` — 未定期轮换密钥
- `no-auth-{route}` — 特定路由缺失身份认证
- `verbose-errors` — 暴露详细错误信息
- 或任何自定义描述性IDOutput example for ignored items
忽略项输出示例
When audit results are shown, append this section at the end:
⏭️ Ignored Items (from .ai-factory/SECURITY.md)
┌─────────────────┬──────────────────────────────────────┬────────────┐
│ Item │ Reason │ Date │
├─────────────────┼──────────────────────────────────────┼────────────┤
│ no-csrf │ SPA with token auth, no cookies used │ 2025-03-15 │
│ no-rate-limit │ Internal service, behind API gateway │ 2025-03-15 │
└─────────────────┴──────────────────────────────────────┴────────────┘
⚠️ 2 items ignored. Run `/aif-security-checklist` without ignores to see full audit.展示审计结果时,在末尾追加以下部分:
⏭️ Ignored Items (from .ai-factory/SECURITY.md)
┌─────────────────┬──────────────────────────────────────┬────────────┐
│ Item │ Reason │ Date │
├─────────────────┼──────────────────────────────────────┼────────────┤
│ no-csrf │ SPA with token auth, no cookies used │ 2025-03-15 │
│ no-rate-limit │ Internal service, behind API gateway │ 2025-03-15 │
└─────────────────┴──────────────────────────────────────┴────────────┘
⚠️ 2 items ignored. Run `/aif-security-checklist` without ignores to see full audit.Quick Automated Audit
快速自动化审计
Run the automated security audit script:
bash
bash ~/{{skills_dir}}/security-checklist/scripts/audit.shThis checks:
- Hardcoded secrets in code
- .env tracked in git
- .gitignore configuration
- npm audit (vulnerabilities)
- console.log in production code
- Security TODOs
执行自动化安全审计脚本:
bash
bash ~/{{skills_dir}}/security-checklist/scripts/audit.sh该脚本检查以下内容:
- 代码中的硬编码密钥
- .env文件被Git追踪
- .gitignore配置情况
- npm audit(漏洞检测)
- 生产代码中的console.log
- 安全相关的TODO项
🔴 Critical: Pre-Deployment Checklist
🔴 关键:部署前检查清单
Must Fix Before Production
生产环境前必须修复的问题
- No secrets in code or git history
- All user input is validated and sanitized
- Authentication on all protected routes
- HTTPS enforced (no HTTP)
- SQL/NoSQL injection prevented
- XSS protection in place
- CSRF tokens on state-changing requests
- Rate limiting enabled
- Error messages don't leak sensitive info
- Dependencies scanned for vulnerabilities
- LLM prompt injection mitigated (if using AI)
- Race conditions prevented on critical operations (payments, inventory)
- 代码或Git历史中无密钥
- 所有用户输入均经过验证和清理
- 所有受保护路由均配置身份认证
- 强制使用HTTPS(禁止HTTP)
- 已防止SQL/NoSQL注入
- 已部署XSS防护措施
- 状态变更请求均携带CSRF令牌
- 已启用速率限制
- 错误信息未泄露敏感数据
- 已扫描依赖项中的漏洞
- 已缓解LLM提示注入(若使用AI)
- 关键操作(支付、库存)已防止竞争条件
Authentication & Sessions
身份认证与会话管理
Password Security
密码安全
✅ Requirements:
- [ ] Minimum 12 characters
- [ ] Hashed with bcrypt/argon2 (cost factor ≥ 12)
- [ ] Never stored in plain text
- [ ] Never logged
- [ ] Breach detection (HaveIBeenPwned API)For implementation patterns (argon2, bcrypt, PHP, Laravel) → read
references/AUTH-PATTERNS.md✅ 要求:
- [ ] 最小长度12位
- [ ] 使用bcrypt/argon2哈希(成本因子≥12)
- [ ] 绝不明文存储
- [ ] 绝不记录日志
- [ ] 泄露检测(调用HaveIBeenPwned API)实现模式参考(argon2、bcrypt、PHP、Laravel)→ 阅读
references/AUTH-PATTERNS.mdSession Management
会话管理
✅ Checklist:
- [ ] Session ID regenerated after login
- [ ] Session timeout implemented (idle + absolute)
- [ ] Secure cookie flags set
- [ ] Session invalidation on logout
- [ ] Concurrent session limits (optional)For secure cookie settings example → read
references/AUTH-PATTERNS.md✅ 检查清单:
- [ ] 登录后重新生成会话ID
- [ ] 已实现会话超时(空闲超时 + 绝对超时)
- [ ] 已设置安全Cookie标志
- [ ] 登出时失效会话
- [ ] 并发会话限制(可选)安全Cookie设置示例→ 阅读
references/AUTH-PATTERNS.mdJWT Security
JWT安全
✅ Checklist:
- [ ] Use RS256 or ES256 (not HS256 for distributed systems)
- [ ] Short expiration (15 min access, 7 day refresh)
- [ ] Validate all claims (iss, aud, exp, iat)
- [ ] Store refresh tokens securely (httpOnly cookie)
- [ ] Implement token revocation
- [ ] Never store sensitive data in payload✅ 检查清单:
- [ ] 使用RS256或ES256(分布式系统请勿使用HS256)
- [ ] 短有效期(15分钟访问令牌,7天刷新令牌)
- [ ] 验证所有声明(iss、aud、exp、iat)
- [ ] 安全存储刷新令牌(使用httpOnly Cookie)
- [ ] 已实现令牌吊销机制
- [ ] 载荷中绝不存储敏感数据Injection Prevention
注入攻击防护
SQL Injection
SQL注入
typescript
// ❌ VULNERABLE: String concatenation
const query = `SELECT * FROM users WHERE id = ${userId}`;
// ✅ SAFE: Parameterized query
const user = await db.query('SELECT * FROM users WHERE id = $1', [userId]);
// ✅ SAFE: ORM (Prisma/Eloquent/SQLAlchemy)
const user = await prisma.user.findUnique({ where: { id: userId } });typescript
// ❌ 存在漏洞:字符串拼接
const query = `SELECT * FROM users WHERE id = ${userId}`;
// ✅ 安全:参数化查询
const user = await db.query('SELECT * FROM users WHERE id = $1', [userId]);
// ✅ 安全:ORM(Prisma/Eloquent/SQLAlchemy)
const user = await prisma.user.findUnique({ where: { id: userId } });NoSQL Injection
NoSQL注入
typescript
// ❌ VULNERABLE: Direct user input — attack: { "$ne": "" }
const user = await db.users.findOne({ username: req.body.username });
// ✅ SAFE: Type validation
const username = z.string().parse(req.body.username);typescript
// ❌ 存在漏洞:直接使用用户输入 — 攻击示例:{ "$ne": "" }
const user = await db.users.findOne({ username: req.body.username });
// ✅ 安全:类型验证
const username = z.string().parse(req.body.username);Command Injection
命令注入
typescript
// ❌ VULNERABLE: exec(`convert ${userFilename} output.png`);
// ✅ SAFE: execFile('convert', [userFilename, 'output.png']);typescript
// ❌ 存在漏洞:exec(`convert ${userFilename} output.png`);
// ✅ 安全:execFile('convert', [userFilename, 'output.png']);Cross-Site Scripting (XSS)
跨站脚本攻击(XSS)
Prevention Checklist
防护检查清单
- [ ] All user output HTML-encoded by default
- [ ] Content-Security-Policy header configured
- [ ] X-Content-Type-Options: nosniff
- [ ] Sanitize HTML if allowing rich text
- [ ] Validate URLs before rendering links- [ ] 默认对所有用户输出进行HTML编码
- [ ] 已配置Content-Security-Policy头
- [ ] 已设置X-Content-Type-Options: nosniff
- [ ] 若允许富文本则清理HTML
- [ ] 渲染链接前验证URLOutput Encoding
输出编码
typescript
// ❌ VULNERABLE: element.innerHTML = userInput; / dangerouslySetInnerHTML
// ✅ SAFE: element.textContent = userInput; / React: <div>{userInput}</div>
// ✅ If HTML needed: DOMPurify.sanitize(userInput)php
// ❌ VULNERABLE: <?= $userInput ?> / {!! $userInput !!}
// ✅ SAFE: {{ $userInput }} (Blade) / htmlspecialchars($input, ENT_QUOTES, 'UTF-8')typescript
// ❌ 存在漏洞:element.innerHTML = userInput; / dangerouslySetInnerHTML
// ✅ 安全:element.textContent = userInput; / React: <div>{userInput}</div>
// ✅ 若需HTML:使用DOMPurify.sanitize(userInput)php
// ❌ 存在漏洞:<?= $userInput ?> / {!! $userInput !!}
// ✅ 安全:{{ $userInput }} (Blade) / htmlspecialchars($input, ENT_QUOTES, 'UTF-8')Content Security Policy
内容安全策略
Set CSP header:
default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; frame-ancestors 'none'; base-uri 'self'; form-action 'self'设置CSP头:
default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; frame-ancestors 'none'; base-uri 'self'; form-action 'self'CSRF Protection
CSRF防护
Checklist
检查清单
- [ ] CSRF tokens on all state-changing requests
- [ ] SameSite=Strict or Lax on cookies
- [ ] Verify Origin/Referer headers
- [ ] Don't use GET for state changes- [ ] 所有状态变更请求均携带CSRF令牌
- [ ] Cookie设置SameSite=Strict或Lax
- [ ] 验证Origin/Referer头
- [ ] 不使用GET请求进行状态变更Implementation
实现方案
- Server-rendered: Use middleware, embed token in hidden form field and AJAX headers
csurf - SPAs: Double-submit cookie pattern — set readable cookie with , client sends token in header, server compares
sameSite: 'strict'
- 服务端渲染:使用中间件,在隐藏表单字段和AJAX头中嵌入令牌
csurf - SPA应用:双提交Cookie模式 — 设置可读Cookie并配置,客户端在请求头中发送令牌,服务端进行比对
sameSite: 'strict'
Secrets Management
密钥管理
Never Do This
禁止操作
❌ Secrets in code
const API_KEY = "sk_live_abc123";
❌ Secrets in git
.env committed to repository
❌ Secrets in logs
console.log(`Connecting with password: ${password}`);
❌ Secrets in error messages
throw new Error(`DB connection failed: ${connectionString}`);❌ 密钥硬编码在代码中
const API_KEY = "sk_live_abc123";
❌ 密钥存入Git
.env文件提交至仓库
❌ 密钥出现在日志中
console.log(`Connecting with password: ${password}`);
❌ 密钥出现在错误信息中
throw new Error(`DB connection failed: ${connectionString}`);Checklist
检查清单
- [ ] Secrets in environment variables or vault
- [ ] .env in .gitignore
- [ ] Different secrets per environment
- [ ] Secrets rotated regularly
- [ ] Access to secrets audited
- [ ] No secrets in client-side code- [ ] 密钥存储在环境变量或密钥管理服务中
- [ ] .env已加入.gitignore
- [ ] 不同环境使用不同密钥
- [ ] 定期轮换密钥
- [ ] 密钥访问权限已审计
- [ ] 客户端代码中无密钥Git History Cleanup
Git历史清理
bash
undefinedbash
undefinedIf secrets were committed, remove from history
若密钥已被提交,从历史中移除
git filter-branch --force --index-filter
"git rm --cached --ignore-unmatch path/to/secret-file"
--prune-empty --tag-name-filter cat -- --all
"git rm --cached --ignore-unmatch path/to/secret-file"
--prune-empty --tag-name-filter cat -- --all
git filter-branch --force --index-filter
"git rm --cached --ignore-unmatch path/to/secret-file"
--prune-empty --tag-name-filter cat -- --all
"git rm --cached --ignore-unmatch path/to/secret-file"
--prune-empty --tag-name-filter cat -- --all
Or use BFG Repo-Cleaner (faster)
或使用BFG Repo-Cleaner(速度更快)
bfg --delete-files .env
bfg --replace-text passwords.txt
bfg --delete-files .env
bfg --replace-text passwords.txt
Force push (coordinate with team!)
强制推送(请与团队协调!)
git push origin --force --all
git push origin --force --all
Rotate ALL exposed secrets immediately!
立即轮换所有暴露的密钥!
---
---API Security
API安全
Authentication
身份认证
- [ ] API keys not in URLs (use headers)
- [ ] Rate limiting per user/IP
- [ ] Request signing for sensitive operations
- [ ] OAuth 2.0 for third-party access- [ ] API密钥不放在URL中(使用请求头)
- [ ] 按用户/IP配置速率限制
- [ ] 敏感操作使用请求签名
- [ ] 第三方访问使用OAuth 2.0Input Validation
输入验证
typescript
// ✅ Validate all input with schema
import { z } from 'zod';
const CreateUserSchema = z.object({
email: z.string().email().max(255),
name: z.string().min(1).max(100),
age: z.number().int().min(0).max(150).optional(),
});
app.post('/users', (req, res) => {
const result = CreateUserSchema.safeParse(req.body);
if (!result.success) {
return res.status(400).json({ error: result.error });
}
// result.data is typed and validated
});typescript
// ✅ 使用Schema验证所有输入
import { z } from 'zod';
const CreateUserSchema = z.object({
email: z.string().email().max(255),
name: z.string().min(1).max(100),
age: z.number().int().min(0).max(150).optional(),
});
app.post('/users', (req, res) => {
const result = CreateUserSchema.safeParse(req.body);
if (!result.success) {
return res.status(400).json({ error: result.error });
}
// result.data已完成类型验证
});Response Security
响应安全
typescript
// ✅ Don't expose internal errors
app.use((err, req, res, next) => {
console.error(err); // Log full error internally
// Return generic message to client
res.status(500).json({
error: 'Internal server error',
requestId: req.id, // For support reference
});
});
// ✅ Don't expose sensitive fields
const userResponse = {
id: user.id,
name: user.name,
email: user.email,
// ❌ Never: password, passwordHash, internalId, etc.
};typescript
// ✅ 不暴露内部错误
app.use((err, req, res, next) => {
console.error(err); // 内部记录完整错误
// 向客户端返回通用信息
res.status(500).json({
error: 'Internal server error',
requestId: req.id, // 用于支持查询
});
});
// ✅ 不暴露敏感字段
const userResponse = {
id: user.id,
name: user.name,
email: user.email,
// ❌ 禁止返回:password、passwordHash、internalId等
};Infrastructure Security
基础设施安全
Headers Checklist
响应头检查清单
typescript
app.use(helmet()); // Sets many security headers
// Or manually:
res.setHeader('X-Content-Type-Options', 'nosniff');
res.setHeader('X-Frame-Options', 'DENY');
res.setHeader('X-XSS-Protection', '0'); // Disabled, use CSP instead
res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
res.setHeader('Referrer-Policy', 'strict-origin-when-cross-origin');
res.setHeader('Permissions-Policy', 'camera=(), microphone=(), geolocation=()');typescript
app.use(helmet()); // 设置多项安全头
// 或手动设置:
res.setHeader('X-Content-Type-Options', 'nosniff');
res.setHeader('X-Frame-Options', 'DENY');
res.setHeader('X-XSS-Protection', '0'); // 禁用,改用CSP
res.setHeader('Strict-Transport-Security', 'max-age=31536000; includeSubDomains');
res.setHeader('Referrer-Policy', 'strict-origin-when-cross-origin');
res.setHeader('Permissions-Policy', 'camera=(), microphone=(), geolocation=()');Dependency Security
依赖安全
bash
undefinedbash
undefinedCheck for vulnerabilities
检查漏洞
npm audit
pip-audit
cargo audit
npm audit
pip-audit
cargo audit
Auto-fix where possible
自动修复可修复的问题
npm audit fix
npm audit fix
Keep dependencies updated
保持依赖更新
npx npm-check-updates -u
undefinednpx npm-check-updates -u
undefinedDeployment Checklist
部署检查清单
- [ ] HTTPS only (redirect HTTP)
- [ ] TLS 1.2+ only
- [ ] Security headers configured
- [ ] Debug mode disabled
- [ ] Default credentials changed
- [ ] Unnecessary ports closed
- [ ] File permissions restricted
- [ ] Logging enabled (but no secrets)
- [ ] Backups encrypted
- [ ] WAF/DDoS protection (for public APIs)- [ ] 仅允许HTTPS(重定向HTTP)
- [ ] 仅使用TLS 1.2+
- [ ] 已配置安全头
- [ ] 已禁用调试模式
- [ ] 已修改默认凭证
- [ ] 已关闭不必要的端口
- [ ] 已限制文件权限
- [ ] 已启用日志记录(但不包含密钥)
- [ ] 备份已加密
- [ ] 已配置WAF/DDoS防护(针对公开API)Race Conditions
竞争条件
For detailed race condition patterns (double-spend, TOCTOU, optimistic locking, idempotency keys, distributed locks) → read
references/RACE-CONDITIONS.md竞争条件模式详情(双花问题、TOCTOU、乐观锁、幂等键、分布式锁)→ 阅读
references/RACE-CONDITIONS.mdPrevention Checklist
防护检查清单
- [ ] Financial operations use database transactions with proper isolation
- [ ] Inventory/stock checks use atomic decrement (not read-then-write)
- [ ] Idempotency keys on payment and mutation endpoints
- [ ] Optimistic locking (version column) on concurrent updates
- [ ] File operations use exclusive locks where needed
- [ ] No TOCTOU gaps between permission check and action
- [ ] Rate limiting to reduce exploitation window- [ ] 金融操作使用数据库事务及正确的隔离级别
- [ ] 库存检查使用原子递减(而非先读后写)
- [ ] 支付及变更端点使用幂等键
- [ ] 并发更新使用乐观锁(版本列)
- [ ] 文件操作按需使用排他锁
- [ ] 权限检查与操作之间无TOCTOU间隙
- [ ] 已启用速率限制以缩小攻击窗口Prompt Injection (LLM Security)
提示注入(LLM安全)
For detailed prompt injection patterns (direct, indirect, tool safety, output validation, RAG) → read
references/PROMPT-INJECTION.md提示注入模式详情(直接注入、间接注入、工具安全、输出验证、RAG)→ 阅读
references/PROMPT-INJECTION.mdPrevention Checklist
防护检查清单
- [ ] User input never concatenated directly into system prompts
- [ ] Input/output boundaries clearly separated (delimiters, roles)
- [ ] LLM output treated as untrusted (never executed as code/commands)
- [ ] Tool calls from LLM validated and sandboxed
- [ ] Sensitive data excluded from LLM context
- [ ] Rate limiting on LLM endpoints
- [ ] Output filtered for PII/secrets leakage
- [ ] Logging & monitoring for anomalous prompts- [ ] 用户输入绝不直接拼接至系统提示词
- [ ] 输入/输出边界清晰分隔(使用分隔符、角色标识)
- [ ] LLM输出视为不可信内容(绝不直接作为代码/命令执行)
- [ ] LLM的工具调用已验证并沙箱化
- [ ] LLM上下文不包含敏感数据
- [ ] LLM端点已配置速率限制
- [ ] 已过滤输出中的PII/密钥泄露内容
- [ ] 已记录并监控异常提示词Quick Audit Commands
快速审计命令
bash
undefinedbash
undefinedFind hardcoded secrets
查找硬编码密钥
grep -rn "password|secret|api_key|token" --include=".ts" --include=".js" .
grep -rn "password|secret|api_key|token" --include=".ts" --include=".js" .
Check for vulnerable dependencies
检查依赖项漏洞
npm audit --audit-level=high
npm audit --audit-level=high
Find TODO security items
查找安全相关的TODO项
grep -rn "TODO.*security|FIXME.*security|XXX.*security" .
grep -rn "TODO.*security|FIXME.*security|XXX.*security" .
Check for console.log in production code
检查生产代码中的console.log
grep -rn "console.log" src/
grep -rn "console.log" src/
Find prompt injection risks (unsanitized input in LLM calls)
查找提示注入风险(LLM调用中未清理的输入)
grep -rn "system.${.}" --include=".ts" --include=".js" .
grep -rn "innerHTML.*llm|innerHTML.response|innerHTML.completion" --include=".ts" --include=".js" .
---grep -rn "system.${.}" --include=".ts" --include=".js" .
grep -rn "innerHTML.*llm|innerHTML.response|innerHTML.completion" --include=".ts" --include=".js" .
---Severity Reference
严重程度参考
| Issue | Severity | Fix Timeline |
|---|---|---|
| SQL Injection | 🔴 Critical | Immediate |
| Auth Bypass | 🔴 Critical | Immediate |
| Secrets Exposed | 🔴 Critical | Immediate |
| XSS (Stored) | 🔴 Critical | < 24 hours |
| Prompt Injection (Direct) | 🔴 Critical | Immediate |
| Race Condition (Financial) | 🔴 Critical | Immediate |
| Prompt Injection (Indirect) | 🟠 High | < 1 week |
| Race Condition (Data) | 🟠 High | < 1 week |
| CSRF | 🟠 High | < 1 week |
| XSS (Reflected) | 🟠 High | < 1 week |
| Missing Rate Limit | 🟡 Medium | < 2 weeks |
| Verbose Errors | 🟡 Medium | < 2 weeks |
| Missing Headers | 🟢 Low | < 1 month |
Tip: Context is heavy after security audit. Consideror/clearbefore continuing with other tasks./compact
| 问题 | 严重程度 | 修复时限 |
|---|---|---|
| SQL注入 | 🔴 关键 | 立即修复 |
| 认证绕过 | 🔴 关键 | 立即修复 |
| 密钥泄露 | 🔴 关键 | 立即修复 |
| 存储型XSS | 🔴 关键 | 24小时内 |
| 直接提示注入 | 🔴 关键 | 立即修复 |
| 金融场景竞争条件 | 🔴 关键 | 立即修复 |
| 间接提示注入 | 🟠 高 | 1周内 |
| 数据场景竞争条件 | 🟠 高 | 1周内 |
| CSRF | 🟠 高 | 1周内 |
| 反射型XSS | 🟠 高 | 1周内 |
| 缺失速率限制 | 🟡 中 | 2周内 |
| 冗余错误信息 | 🟡 中 | 2周内 |
| 缺失安全头 | 🟢 低 | 1个月内 |
提示:安全审计后上下文信息较多。在继续其他任务前,可考虑执行或/clear命令。/compact