这套模板现在是一个更偏 harness engineering 的 staged audit harness,而不只是多 prompt 工作流。
它的目标是让越权扫描具备这些特性:
- 用多个 subagent 拆分任务
- 用结构化 artifact 控制上下文
- 用 schema gate 约束输出格式
- 用独立 verifier 挑战高置信发现
- 用 staged runner 在每一阶段做 stop/go 决策
- 用 scan manifest 记录一次扫描的运行元数据和阶段结果
claude-priv-esc-template/
agents/
prompts/
reports/
schemas/
scripts/
run-one-shot-audit.sh
默认执行顺序:
route-inventoryauthz-traceridor-checkerfinding-verifierreport-normalizer
关键改动:
route-inventory默认保留Bash,因为它可能需要小脚本做路由抽取authz-tracer、idor-checker、finding-verifier默认收紧到Read,Grep,Globreport-normalizer默认只需要Read,Glob- 每个 JSON artifact 生成后都会立即校验
- 校验失败会触发一次 repair pass
- repair 后仍不合法就 fail closed
在目标仓库中会生成:
audit/artifacts/routes.json
audit/artifacts/authz_map.json
audit/artifacts/idor_suspects.json
audit/artifacts/verified_findings.json
audit/artifacts/scan_manifest.json
audit/reports/privilege-escalation-report.md
audit/reports/privilege-escalation-report.template.md
audit/logs/
audit/schemas/
这套模板默认按项目级方式使用,不建议复制到全局 ~/.claude/agents/。
先把 subagent、schema 和报告模板复制到你要扫描的项目目录。
TARGET_REPO=/path/to/your/repo
mkdir -p "$TARGET_REPO/.claude/agents"
mkdir -p "$TARGET_REPO/audit/artifacts" "$TARGET_REPO/audit/reports" "$TARGET_REPO/audit/logs" "$TARGET_REPO/audit/schemas"
cp /home/lb/tmp/claude-priv-esc-template/agents/*.md "$TARGET_REPO/.claude/agents/"
cp /home/lb/tmp/claude-priv-esc-template/schemas/*.json "$TARGET_REPO/audit/schemas/"
cp /home/lb/tmp/claude-priv-esc-template/reports/privilege-escalation-report.template.md "$TARGET_REPO/audit/reports/"例如扫描 crAPI:
TARGET_REPO=/home/lb/tmp/crAPI
mkdir -p "$TARGET_REPO/.claude/agents"
mkdir -p "$TARGET_REPO/audit/artifacts" "$TARGET_REPO/audit/reports" "$TARGET_REPO/audit/logs" "$TARGET_REPO/audit/schemas"
cp /home/lb/tmp/claude-priv-esc-template/agents/*.md "$TARGET_REPO/.claude/agents/"
cp /home/lb/tmp/claude-priv-esc-template/schemas/*.json "$TARGET_REPO/audit/schemas/"
cp /home/lb/tmp/claude-priv-esc-template/reports/privilege-escalation-report.template.md "$TARGET_REPO/audit/reports/"复制完成后,最简单的方式是直接运行 staged runner。
TARGET_REPO=/path/to/your/repo
bash /home/lb/tmp/claude-priv-esc-template/run-one-shot-audit.sh "$TARGET_REPO"如果你已经 cd 到项目目录,也可以这样:
cd /path/to/your/repo
bash /home/lb/tmp/claude-priv-esc-template/run-one-shot-audit.sh "$(pwd)"这条命令会一键调用 Claude Code 的无头模式,对该项目执行完整扫描。
例如扫描 crAPI:
cd /home/lb/tmp/crAPI
bash /home/lb/tmp/claude-priv-esc-template/run-one-shot-audit.sh "$(pwd)"脚本会自动:
- 使用项目目录下的
.claude/agents/ - 复制 schema 到
audit/schemas/ - 复制报告模板到
audit/reports/ - 逐阶段调用 Claude
- 对每个阶段的输出做 schema 或 section 校验
- 把阶段结果写入
audit/artifacts/scan_manifest.json
如果你不想走无头模式,而是想先进入 Claude Code 再手工观察每一轮扫描,可以这样:
cd /path/to/your/repo
claude进入后执行 /agents 确认项目目录下的 agent 已加载,然后按模板里的 staged prompts 逐轮运行。
环境变量:
MODEL- 默认
sonnet
- 默认
EFFORT- 默认
medium
- 默认
CLAUDE_PERMISSION_MODE- 默认
acceptEdits
- 默认
MAX_BUDGET_USD- 视为整次运行总预算,runner 会按阶段均分
STAGE_MAX_BUDGET_USD- 如果显式设置,会直接作为每一阶段的预算上限
PROMPT_VERSION- 默认
v2-hardened
- 默认
阶段级工具权限:
ROUTE_ALLOWED_TOOLS- 默认
Read,Grep,Glob,Bash
- 默认
AUTHZ_ALLOWED_TOOLS- 默认
Read,Grep,Glob
- 默认
IDOR_ALLOWED_TOOLS- 默认
Read,Grep,Glob
- 默认
VERIFY_ALLOWED_TOOLS- 默认
Read,Grep,Glob
- 默认
REPORT_ALLOWED_TOOLS- 默认
Read,Glob
- 默认
如果你不使用一键脚本,而是手工逐轮运行,也建议在每一轮后执行校验。
示例:
python3 /home/lb/tmp/claude-priv-esc-template/scripts/validate_json_artifact.py \
audit/schemas/routes.schema.json \
audit/artifacts/routes.jsonpython3 /home/lb/tmp/claude-priv-esc-template/scripts/validate_report.py \
audit/reports/privilege-escalation-report.md \
audit/reports/privilege-escalation-report.template.md这套模板现在更强调:
- schema 是硬约束,不是“建议长这样”
confirmed需要经过 verifier,而不是由发现者自己宣布- 中间结果要可复查、可回放、可追踪
- 失败时宁可停下来,也不要把脏 artifact 传给下游阶段