with one click
security-deep-review
深度程式碼安全審查,檢測注入攻擊、XSS、CSRF、身份驗證和授權問題
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Menu
深度程式碼安全審查,檢測注入攻擊、XSS、CSRF、身份驗證和授權問題
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Based on SOC occupation classification
API 開發流程引導技能,協助開發者選擇合適的開發流程(API First 或 Code First),並提供 OpenAPI 規格管理、程式碼產生等自動化支援。
BDD 測試實作技能,協助開發者使用 Reqnroll 撰寫行為驅動開發測試,包含 Gherkin 語法、測試步驟實作與 Docker 測試環境設定。
快取策略與多層快取設計技能,協助開發者實作 L1 Memory + L2 Redis 分層快取,包含 TTL 管理、版本控制與失效策略。
EF Core 操作與最佳化技能,協助開發者正確使用 Entity Framework Core,包含 DbContextFactory 模式、查詢最佳化、Migration 管理與反向工程。
專案初始化與配置技能,負責引導使用者完成新專案的初始化、配置設定、GitHub 範本套用與專案狀態檢測。
Repository 設計指導技能,協助開發者根據業務需求選擇最合適的 Repository 設計策略(資料表導向 vs 需求導向 vs 混合模式)。
| name | security-deep-review |
| description | 深度程式碼安全審查,檢測注入攻擊、XSS、CSRF、身份驗證和授權問題 |
本 SKILL 須搭配閱讀:開發規則
深度程式碼層級的安全審查,專注於程式設計上的漏洞。
使用 Read 工具讀取要審查的程式碼檔案。如果使用者提供目錄,使用 Glob 找出所有程式碼檔案。
針對每個檔案,檢查以下模式:
SQL Injection (TypeScript/JavaScript):
`SELECT * FROM users WHERE id = ${userId}`"SELECT * FROM users WHERE id = " + userIddb.query("SELECT * FROM users WHERE id = $1", [userId])SQL Injection (Go):
fmt.Sprintf("SELECT * FROM users WHERE id = %s", userID)db.Query("SELECT * FROM users WHERE id = $1", userID)Command Injection:
exec(\ping ${userInput}`)`eval(userCode)execFile("ping", ["-c", "4", validatedHost])React/Next.js:
<div dangerouslySetInnerHTML={{ __html: userInput }} />element.innerHTML = userInput<div>{userInput}</div> (React 自動轉義)Go (html/template):
html/template 而非 text/template密碼處理:
password: req.body.passwordcrypto.createHash("md5").update(password)bcrypt.hash(password, 12)JWT 安全:
jwt.sign({ userId }, "secret")jwt.sign({ userId }, secret)jwt.sign({ userId }, process.env.JWT_SECRET, { algorithm: "HS256", expiresIn: "1h" })檢查是否驗證資源所有權:
❌ 不安全:
app.delete("/api/posts/:id", async (req, res) => {
await db.posts.delete({ id: req.params.id });
});
✅ 安全:
app.delete("/api/posts/:id", async (req, res) => {
const post = await db.posts.findUnique({ where: { id: req.params.id } });
if (post.authorId !== req.user.id) {
return res.status(403).send("Forbidden");
}
await db.posts.delete({ id: req.params.id });
});
弱演算法:
crypto.createCipher("des", key) - DES 已廢棄crypto.createHash("md5") - MD5 不安全crypto.createCipheriv("aes-256-gcm", key, iv)不安全的亂數:
Math.random() - 不安全crypto.randomBytes(32)確認所有使用者輸入都經過驗證:
❌ 未驗證:
const age = req.body.age;
✅ 已驗證:
const schema = z.object({
age: z.number().int().min(0).max(150)
});
const validated = schema.parse(req.body);
對於每個發現的問題,提供:
🔒 程式碼安全審查報告
==========================================
[CRITICAL] SQL Injection
檔案: backend/api/users.go:78
程式碼:
76 | func GetUser(id string) (*User, error) {
> 78 | query := fmt.Sprintf("SELECT * FROM users WHERE id = %s", id)
79 | var user User
問題: 使用字串拼接建構 SQL 查詢,容易受到 SQL Injection 攻擊
風險: 攻擊者可以執行任意 SQL 指令
修復建議:
query := "SELECT * FROM users WHERE id = $1"
err := db.QueryRow(query, id).Scan(&user)
參考: https://owasp.org/www-community/attacks/SQL_Injection
依嚴重程度分類:
Critical (立即修復):
High (7 天內):
Medium (30 天內):
Low (下個版本):
target_path (選填): 要審查的檔案或目錄--language: 指定語言 (typescript, go, python, java)--focus: 專注類型 (injection, xss, csrf, auth)--severity: 最低嚴重程度 (critical, high, medium, low)產生詳細安全審查報告時,請參考:
../security-fast-scan/assets/security-report-template.md - 完整的安全檢查報告範本security-fast-scan - 完整安全掃描security-check-secrets - 敏感資料檢查security-check-config - 安全配置檢查