agentleFS
seikaikyoseikaikyo/dash-skills/skills/security-reviewer/SKILL.md

security-reviewer

Skill2 starsChanged 10 months agoMITView on GitHub

安全漏洞檢測與修復專家。在撰寫處理用戶輸入、認證、API 端點、敏感資料或 AI agent/MCP 工具的程式碼後主動使用。檢測機密資料外洩、SSRF、注入攻擊、不安全加密,對照 OWASP Top 10:2025、OWASP Top 10 for Agentic Applications 2026 與 OWASP GenAI LLM Top 10 2026。

  • Pipes a download into a shell
  • Reads credentials
Files
SKILL.md

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 未設定')
}

檢查項目:

  • 無硬編碼 API keys、tokens、密碼
  • 所有機密資料使用環境變數
  • .env.local 已加入 .gitignore
  • Git 歷史中無機密資料
  • 生產環境機密存放於 Vercel/Render

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)
}

檢查項目:

  • 所有用戶輸入使用 Zod 驗證
  • 檔案上傳限制 (大小、類型、副檔名)
  • 錯誤訊息不洩露敏感資訊

3. SQL 注入防護 (CRITICAL)

// 禁止: 字串串接 SQL
const query = `SELECT * FROM users WHERE email = '${userEmail}'`

// 正確: 參數化查詢
const { data } = await supabase
  .from('users')
  .select('*')
  .eq('email', userEmail)

檢查項目:

  • 所有資料庫查詢使用參數化查詢
  • 無字串串接 SQL
  • ORM/Query Builder 正確使用

4. 認證與授權

// 正確: JWT Token 使用 httpOnly cookies
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 } })
}

檢查項目:

  • Tokens 存放於 httpOnly cookies (非 localStorage)
  • 敏感操作前驗證授權
  • Supabase 啟用 Row Level Security
  • 實作 RBAC

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 }} />
}

檢查項目:

  • 用戶提供的 HTML 已清理
  • 設定 CSP 標頭
  • 使用 React 內建的 XSS 防護

6. CSRF 防護

// SameSite Cookies
res.setHeader('Set-Cookie',
  `session=${sessionId}; HttpOnly; Secure; SameSite=Strict`)

檢查項目:

  • 狀態變更操作使用 CSRF tokens
  • 所有 cookies 設定 SameSite=Strict

7. 速率限制

import rateLimit from 'express-rate-limit'

const limiter = rateLimit({
  windowMs: 15 * 60 * 1000, // 15 分鐘
  max: 100, // 每視窗 100 請求
  message: '請求過多,請稍後再試'
})

app.use('/api/', limiter)

檢查項目:

  • 所有 API 端點啟用速率限制
  • 昂貴操作有更嚴格的限制

8. 敏感資料外洩

// 禁止: 記錄敏感資料
console.log('User login:', { email, password })

// 正確: 清理日誌
console.log('User login:', {
  email: email.replace(/(?<=.).(?=.*@)/g, '*'),
  passwordProvided: !!password
})

檢查項目:

  • 日誌中無密碼、tokens、機密資料
  • 錯誤訊息對用戶是通用的
  • 詳細錯誤僅在伺服器日誌

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

檢查項目:

  • 依賴保持最新
  • npm audit 無已知漏洞
  • lock 檔案已提交
  • GitHub Dependabot 已啟用
  • CI 動作 pin 完整 commit SHA:.github/workflows/ 內第三方 uses: 一律 owner/action@<40 碼 SHA> # vX.Y.Z, 不得用 @master、@main、@v1 這類可被改指向的 tag(可用 zizmor 自動檢查)
  • 容器映像不用 :latest:CI 與 Dockerfile 的第三方映像固定版本,關鍵映像以 @sha256: digest 固定
  • 不 curl | sh 安裝工具:改下載固定版本的 release 並驗 checksum / cosign 簽章

已知遭入侵的發行版本(出現即列 CRITICAL,並要求輪替該 pipeline 可存取的所有 secrets):

套件 / Action受影響版本與期間公告
aquasecurity/trivy-action2026-03-19 ~17:43 至 03-20 ~05:40 UTC 期間,77 個 tag 中 76 個被改指向竊密 commit(v0.35.0 未受影響)GHSA-69fq-xp46-6x23
aquasecurity/setup-trivy2026-03-19 ~17:43–21:44 UTC,v0.2.0–v0.2.6 全部 tag同上
trivy binaryv0.69.4(2026-03-19 約 3 小時,含 GitHub release、GHCR、ECR、deb/rpm、get.trivy.dev)同上
aquasec/trivy Docker Hub 映像v0.69.5、v0.69.6(2026-03-22 15:43 至 03-23 ~01:40 UTC)同上
litellm(PyPI)1.82.7、1.82.8(2026-03-24 約 40 分鐘)BerriAI/litellm#24518

pin 了也要看版本:trivy-action 的 tag v0.35.0 / v0.36.0 預設安裝 trivy v0.69.3 / v0.70.0, 早於 CVE-2026-54448、CVE-2026-55092、CVE-2026-63328 的修補(0.71.0–0.72.0),內部也還用 setup-trivy v0.2.6。 workflow 用這兩個 tag 卻沒傳 version: 列 HIGH,要求加 version: v0.74.0 或改釘 master d2a0b60; 直接用 setup-trivy 的要 ≥v0.3.1(v0.3.0 修 run 區塊 script injection,上游未發 GHSA)。

判斷是否受害:看 workflow 是否以 tag(非 SHA)引用上表 Action、或安裝了上表版本,且在上述期間實際執行過(查 Actions run 紀錄)。 兩者都成立 → 視為 secrets 已外洩:輪替 pipeline 可存取的所有 secrets,並在組織內搜尋名為 tpcp-docs 的 repo(攻擊者外送憑證的落點之一)。

OWASP 對照

OWASP Top 10:2025(最新正式版,2026-01 定稿)

相對 2021 版:SSRF 併入 A01;新增 A03 軟體供應鏈失效、A10 例外狀況處理不當;A02 設定錯誤升至第二。

代碼分類對應本清單審查重點
A01Broken Access Control(含 SSRF)4 認證與授權、6 CSRF每個端點都有物件層授權;伺服器端發出的 URL 必須白名單
A02Security Misconfiguration部署前檢查清單安全標頭、CSP、預設帳密、除錯模式、CORS 範圍
A03Software Supply Chain Failures10 依賴安全lockfile 提交、依賴來源可信、CI 動作版本 pinning
A04Cryptographic Failures1 機密資料管理、8 敏感資料外洩演算法與金鑰長度、傳輸與靜態加密、勿自製加密
A05Injection2 輸入驗證、3 SQL 注入、5 XSS參數化查詢、輸出編碼、命令列與模板注入
A06Insecure Design(設計階段)威脅建模、信任邊界、業務邏輯濫用情境
A07Authentication Failures4 認證與授權、7 速率限制token 驗證完整(iss/aud/exp/alg)、暴力破解防護、session 固定
A08Software or Data Integrity Failures10 依賴安全反序列化來源、未簽章更新、CI/CD 產物完整性
A09Security Logging and Alerting Failures緊急應變關鍵事件有紀錄且可告警;log 不含機密
A10Mishandling of Exceptional Conditions2 輸入驗證錯誤路徑 fail-closed、例外不洩漏內部資訊、資源釋放

OWASP Top 10 for Agentic Applications 2026(ASI,2025-12 發布)

審查 AI agent、MCP server、tool-calling、自動化 routine 相關程式碼時,額外對照本表。 來源:OWASP GenAI Security Project。

代碼分類審查重點
ASI01Agent Goal Hijack外部內容(網頁、文件、issue、commit message)視為資料而非指令;prompt injection 防線與工具輸出隔離
ASI02Tool Misuse & Exploitation每個 tool 有明確參數 schema 與範圍限制;破壞性操作需確認;工具描述不可被外部內容改寫
ASI03Identity & Privilege Abuseagent 憑證最小權限、短效、可撤銷;勿把人類的長效 token 直接交給 agent;操作可歸因到觸發者
ASI04Agentic Supply Chain VulnerabilitiesMCP server、plugin、skill、模型來源可信且 pinning;第三方 skill 進 repo 前掃描(本 repo 的 SkillSpector)
ASI05Unexpected Code Execution (RCE)agent 產生的程式碼在沙箱執行;shell / eval / 檔案寫入範圍限制;禁止把模型輸出直接餵給直譯器
ASI06Memory & Context Poisoning長期記憶與 RAG 來源有寫入控管;快照 / 狀態檔的內容視為不可信資料;記憶可清除與稽核
ASI07Insecure Inter-Agent Communicationagent 之間訊息需驗證來源與完整性;不因訊息「來自另一個 agent」就提升信任
ASI08Cascading Failures單一 agent 出錯不應連鎖擴散;有熔斷、重試上限、預算上限(token / 次數 / 費用)
ASI09Human-Agent Trust Exploitationagent 輸出不得偽裝成人類決定或系統訊息;高風險動作留人類確認點
ASI10Rogue Agents排程 / 常駐 agent 有停止開關、行為監控與異常告警;權限與範圍可隨時收回

OWASP GenAI LLM Top 10 2026(LLM,2026-08 發布)

任何直接呼叫模型的程式碼(prompt 組裝、RAG、輸出解析)對照本表;agent 相關另看上方 ASI 表。

代碼分類審查重點
LLM01Prompt Injection使用者與外部內容與系統指令分層;工具輸出不回灌為指令
LLM02Sensitive Information Disclosureprompt / context 不含機密;輸出過濾 PII 與憑證
LLM03Excessive Agency模型可觸發的動作最小化;高風險動作需確認
LLM04Supply Chain模型、權重、prompt 模板、第三方 API 來源可信且 pinning
LLM05Data and Model Poisoning訓練 / 微調 / RAG 資料來源控管與稽核
LLM06Unbounded Consumptiontoken、請求數、費用上限;防 DoS 與錢包耗盡
LLM07Misinformation關鍵輸出有驗證或引用來源;不把模型輸出當事實直接落庫
LLM08Hidden Context Exposure系統提示、檢索文件、記憶、工具回應皆視為可能外洩面
LLM09Vector and Embedding Weaknesses向量庫存取控制、多租戶隔離、嵌入反演風險
LLM10Improper Output Handling模型輸出進 HTML / SQL / shell 前一律編碼或參數化

檢查項目(agent 程式碼):

  • 外部輸入(工具結果、抓取內容、通知)標示為不可信並隔離
  • 每個 tool 有 schema、範圍與破壞性操作確認
  • agent 憑證最小權限且可撤銷;操作可追溯到觸發者
  • 第三方 skill / MCP / plugin 來源可信並掃描
  • 程式碼執行沙箱化;預算與重試上限;有緊急停止開關

安全審查報告格式

# 安全審查報告

**檔案:** [path/to/file.ts]
**審查日期:** YYYY-MM-DD
**審查者:** security-reviewer

## 摘要

- **嚴重問題:** X
- **高風險問題:** Y
- **中風險問題:** Z
- **風險等級:** 高 / 中 / 低

## 嚴重問題 (立即修復)

### 1. [問題標題]
**嚴重程度:** CRITICAL
**類別:** SQL 注入 / XSS / 認證 / 等
**位置:** `file.ts:123`

**問題描述:**
[漏洞描述]

**影響:**
[被利用時的後果]

**修復方案:**
[安全實作範例]

部署前安全檢查清單

  • 機密資料: 無硬編碼,全部使用環境變數
  • 輸入驗證: 所有用戶輸入已驗證
  • SQL 注入: 所有查詢已參數化
  • XSS: 用戶內容已清理
  • CSRF: 防護已啟用
  • 認證: 正確的 token 處理
  • 授權: 角色檢查已就位
  • 速率限制: 所有端點已啟用
  • HTTPS: 生產環境強制
  • 安全標頭: CSP、X-Frame-Options 已設定
  • 依賴: 最新且無漏洞
  • CI 供應鏈: 第三方 Action pin SHA、映像不用 :latest、無已知遭入侵版本

緊急應變

發現 CRITICAL 漏洞時:

  1. 記錄 - 建立詳細報告
  2. 通知 - 立即警告專案負責人
  3. 建議修復 - 提供安全程式碼範例
  4. 測試修復 - 驗證修復有效
  5. 輪換機密 - 如有外洩則更換

相關資源

Download now (ZIP)

  • Other versions29 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 29

    1. Jeffallan/claude-skills★ 12ksame name
    2. kumaran-is/claude-code-onboarding★ 35same name
    3. codeApe-7/ai-agent-workflowGroup★ 18same name
    4. conectlens/lenserfight★ 18same name
    5. PIXARTSeu/Synapse★ 9same name
    6. Ecoa-PUC-Rio/GAIDE★ 7same name
    7. jcarlos78/GAIDE★ 7same name
    8. itsthatladydev/my-agent-skills★ 6same name
    9. u9401066/template-is-all-you-need★ 3same name
    10. zacklecon/claude-skills★ 3same name

    19 more not listed

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • Used alongsideProjects with it also use api-contract-reviewer, ddd-architect and 8 more.

    Other files people use alongside this one.

    Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
    • conectlensSkill

      api-contract-reviewer

      Review Supabase RPC/PostgREST API contracts for DTO correctness, response consistency, validation quality, and backward-compatibility risk. Use when changing libs/api/*, shared response types, or API-facing behavior.

      Also in 3 projects that use this

    • u9401066Skill

      ddd-architect

      Ensure code follows DDD architecture and DAL separation principles. Triggers: DDD, arch, 架構, 新功能, 新模組, new feature, scaffold, 骨架, domain.

      Also in 3 projects that use this

    • JohnJBorenSkill

      test-engineer

      Testing strategy, test patterns, and coverage optimization for unit, integration, and E2E tests

      Also in 3 projects that use this

    • u9401066Skill

      test-generator

      Generate comprehensive test suites including static analysis, unit tests, integration tests, E2E tests, and coverage reports. Triggers: TG, test, 測試, 寫測試, coverage, 覆蓋率, pytest, unittest, 驗證.

      Also in 3 projects that use this

    • victoralbinoSkill

      spec-writer

      Activity planning via deep interview. Use when the user asks to plan, specify, or detail any activity. Accepts an existing file or a direct description. Interviews with AskUserQuestion and writes the final spec.

      Also in 3 projects that use this

    • lodetomasiSkill

      tdd-workflow

      Test-Driven Development workflow with red-green-refactor pattern and best practices

      Also in 3 projects that use this

  • In this repository14 other files it gives its agents.

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

Reviews can't be read right now.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.