| name | security-reviewer |
| description | 安全漏洞檢測與修復專家。在撰寫處理用戶輸入、認證、API 端點或敏感資料的程式碼後主動使用。檢測機密資料外洩、SSRF、注入攻擊、不安全加密和 OWASP Top 10 漏洞。 |
| source | everything-claude-code (MIT License) |
| original_author | affaan-m |
| updated | "2026-01-22T00:00:00.000Z" |
Security Reviewer (安全審查)
When to Use
在以下情況主動使用此 Skill:
- 實作認證或授權功能
- 處理用戶輸入或檔案上傳
- 建立新的 API 端點
- 處理機密資料或憑證
- 實作支付功能
- 整合第三方 API
- 處理金融/交易相關程式碼
安全檢查清單 (10 大類別)
1. 機密資料管理 (CRITICAL)
const apiKey = "sk-proj-xxxxx"
const password = "admin123"
const apiKey = process.env.OPENAI_API_KEY
if (!apiKey) {
throw new Error('OPENAI_API_KEY 未設定')
}
檢查項目:
2. 輸入驗證
import { z } from 'zod'
const CreateUserSchema = z.object({
email: z.string().email(),
name: z.string().min(1).max(100),
age: z.number().int().min(0).max(150)
})
export async function createUser(input: unknown) {
const validated = CreateUserSchema.parse(input)
return await db.users.create(validated)
}
檢查項目:
3. SQL 注入防護 (CRITICAL)
const query = `SELECT * FROM users WHERE email = '${userEmail}'`
const { data } = await supabase
.from('users')
.select('*')
.eq('email', userEmail)
檢查項目:
4. 認證與授權
res.setHeader('Set-Cookie',
`token=${token}; HttpOnly; Secure; SameSite=Strict; Max-Age=3600`)
export async function deleteUser(userId: string, requesterId: string) {
const requester = await db.users.findUnique({ where: { id: requesterId } })
if (requester.role !== 'admin') {
return NextResponse.json({ error: 'Unauthorized' }, { status: 403 })
}
await db.users.delete({ where: { id: userId } })
}
檢查項目:
5. XSS 防護
import DOMPurify from 'isomorphic-dompurify'
function renderUserContent(html: string) {
const clean = DOMPurify.sanitize(html, {
ALLOWED_TAGS: ['b', 'i', 'em', 'strong', 'p'],
ALLOWED_ATTR: []
})
return <div dangerouslySetInnerHTML={{ __html: clean }} />
}
檢查項目:
6. CSRF 防護
res.setHeader('Set-Cookie',
`session=${sessionId}; HttpOnly; Secure; SameSite=Strict`)
檢查項目:
7. 速率限制
import rateLimit from 'express-rate-limit'
const limiter = rateLimit({
windowMs: 15 * 60 * 1000,
max: 100,
message: '請求過多,請稍後再試'
})
app.use('/api/', limiter)
檢查項目:
8. 敏感資料外洩
console.log('User login:', { email, password })
console.log('User login:', {
email: email.replace(/(?<=.).(?=.*@)/g, '*'),
passwordProvided: !!password
})
檢查項目:
9. 區塊鏈安全 (Solana)
import { verify } from '@solana/web3.js'
async function verifyWalletOwnership(publicKey: string, signature: string, message: string) {
return verify(
Buffer.from(message),
Buffer.from(signature, 'base64'),
Buffer.from(publicKey, 'base64')
)
}
檢查項目:
10. 依賴安全
npm audit
npm audit fix
npm update
檢查項目:
安全審查報告格式
# 安全審查報告
**檔案:** [path/to/file.ts]
**審查日期:** YYYY-MM-DD
**審查者:** security-reviewer
## 摘要
- **嚴重問題:** X
- **高風險問題:** Y
- **中風險問題:** Z
- **風險等級:** 高 / 中 / 低
## 嚴重問題 (立即修復)
### 1. [問題標題]
**嚴重程度:** CRITICAL
**類別:** SQL 注入 / XSS / 認證 / 等
**位置:** `file.ts:123`
**問題描述:**
[漏洞描述]
**影響:**
[被利用時的後果]
**修復方案:**
[安全實作範例]
部署前安全檢查清單
緊急應變
發現 CRITICAL 漏洞時:
- 記錄 - 建立詳細報告
- 通知 - 立即警告專案負責人
- 建議修復 - 提供安全程式碼範例
- 測試修復 - 驗證修復有效
- 輪換機密 - 如有外洩則更換
相關資源