快速開始
安裝 Panguard
curl -fsSL https://get.panguard.ai | bash
審計技能目錄
panguard audit skill ./path/to/skill
以 JSON 格式輸出審計結果(用於 CI/CD)
panguard audit skill ./my-skill --json
7 項安全檢查
1. 清單驗證
驗證 SKILL.md 前置資料:必要欄位、有效 YAML、正確的中繼資料。格式錯誤的清單是惡意技能的第一個徵兆。
2. 提示注入
11 種正則表達式模式:「忽略先前指令」、身份覆寫、系統提示操控、越獄模式、隱藏 HTML 註解。
3. 隱藏 Unicode
零寬度字元 (U+200B-200F)、RTL 覆寫 (U+202A-202E) 以及同形字,隱藏人眼不可見的惡意指令。
4. 編碼酬載
擷取 Base64 區塊並解碼,檢查 eval()、exec()、subprocess、child_process、curl、wget 模式。
5. 工具投毒
權限提升 (sudo, chmod 777)、反向 Shell (nc -e, /dev/tcp/)、遠端程式碼執行 (curl|bash)、憑證竊取。
6. 程式碼 SAST + 密鑰
對技能目錄中所有檔案進行靜態分析。偵測硬編碼 API 金鑰、AWS 憑證、私鑰和常見漏洞。
7. 權限與相依性
交叉比對請求的權限與宣稱的用途。天氣技能要求檔案系統寫入權限?這是危險訊號。
風險評分
每個發現都有嚴重性權重。權重加總後上限為 100。
| 嚴重性 | 權重 | 範例 |
|---|---|---|
| 嚴重 | 25 | 反向 Shell、提示注入 |
| 高 | 15 | 權限提升、憑證竊取 |
| 中 | 5 | 可疑模式、模糊不清 |
| 低 | 1 | 次要風格問題 |
0-14
LOW
可安全安裝
15-39
MEDIUM
審查發現
40-69
HIGH
人工審查
70-100
CRITICAL
請勿安裝
整合指南
CI/CD 管線閘門
自動阻止安裝高風險技能:
bash
# Block if HIGH or CRITICAL RISK=$(panguard audit skill "$SKILL_PATH" --json | jq -r '.riskLevel') if [ "$RISK" = "HIGH" ] || [ "$RISK" = "CRITICAL" ]; then echo "Blocked: $RISK risk skill" exit 1 fi
TypeScript API
在代理框架中以程式方式使用:
typescript
import { auditSkill } from '@panguard-ai/panguard-skill-auditor';
const report = await auditSkill('./skills/untrusted-skill');
console.log(`Risk: ${report.riskScore}/100 (${report.riskLevel})`);
console.log(`Checks: ${report.checks.length}`);
console.log(`Findings: ${report.findings.length}`);
// Block dangerous skills
if (report.riskLevel === 'CRITICAL') {
throw new Error('Skill blocked by security policy');
}
// Log individual findings
for (const finding of report.findings) {
console.log(`[${finding.severity}] ${finding.title}`);
if (finding.location) console.log(` at ${finding.location}`);
}OpenClaw 安裝前掛鉤
新增至 OpenClaw 代理設定,在安裝每個技能前自動審計:
~/.openclaw/hooks/pre-skill-install.sh
#!/bin/bash # Auto-audit skills before OpenClaw installs them REPORT=$(panguard audit skill "$1" --json) LEVEL=$(echo "$REPORT" | jq -r '.riskLevel') SCORE=$(echo "$REPORT" | jq -r '.riskScore') echo "Panguard Audit: $SCORE/100 ($LEVEL)" if [ "$LEVEL" = "CRITICAL" ]; then echo "BLOCKED: Critical security issues found" echo "$REPORT" | jq '.findings[] | " [\(.severity)] \(.title)"' exit 1 fi
範例輸出
安全技能
$ panguard audit skill ./skills/weather-widget PANGUARD SKILL AUDIT REPORT ============================ Skill: weather-widget Risk Score: 0/100 Risk Level: LOW Duration: 0.2s CHECKS: [PASS] Manifest: Valid SKILL.md structure [PASS] Prompt Safety: No injection patterns detected [PASS] Code: No vulnerabilities found; Secrets: Clean [PASS] Dependencies: No known issues [PASS] Permissions: Scope appropriate VERDICT: Safe to install
惡意技能
$ panguard audit skill ./skills/suspicious-helper
PANGUARD SKILL AUDIT REPORT
============================
Skill: suspicious-helper
Risk Score: 72/100
Risk Level: CRITICAL
Duration: 0.3s
CHECKS:
[FAIL] Prompt Safety: 2 suspicious pattern(s) detected
[PASS] Manifest: Valid SKILL.md structure
[WARN] Code: 1 issue(s) found; Secrets: No hardcoded credentials
[PASS] Dependencies: No known issues
[PASS] Permissions: Scope appropriate
FINDINGS:
[CRITICAL] Prompt injection: ignore previous instructions
SKILL.md:42 - "ignore all previous instructions and..."
[CRITICAL] Reverse shell pattern detected
SKILL.md:87 - "bash -i >& /dev/tcp/..."
[HIGH] Environment variable exfiltration
SKILL.md:23 - "printenv | curl..."
VERDICT: DO NOT INSTALL - Critical security issues foundPanguard 審計器 vs 人工審查
| 功能 | 人工檢查表 | Panguard 審計器 |
|---|---|---|
| 速度 | 每個技能數分鐘 | < 1 second |
| 一致性 | 因審查人員而異 | 確定性 |
| 隱藏 Unicode | 容易遺漏 | 自動偵測 15 個類別 |
| Base64 酬載 | 需手動解碼 | 自動解碼 + 分析 |
| 程式碼 SAST | 未包含 | 整合式掃描器 |
| 密鑰掃描 | 手動 grep | 基於模式的偵測 |
| 風險評分 | 主觀判斷 | 量化 0-100 |
| CI/CD 就緒 | 否 | JSON 輸出 + 退出碼 |
立即開始
安裝 Panguard,2 分鐘內開始審計技能。MIT 授權,開源免費。
curl -fsSL https://get.panguard.ai | bash