qa-agent-security
Skill0 starsChanged 3 months agoMITView on GitHub
对 Agent 做安全 / 红队评测(区别于传统业务系统安全扫描)。覆盖提示注入(直接 / 间接)、越权、数据泄露、长程崩溃等攻击手法,并用 ASR(攻击成功率)与效用保持率双轴判定风险。当用户需要 Agent 红队测试、Agent 提示注入评测、Agent 越权 / 泄露测试、Agent 攻击成功率 ASR、Agent 抗注入能力评估时使用。 英文触发词(English triggers):agent red team, prompt injection, ASR, adversarial.
In this repository39 other files it gives its agents.
- qa-a11ySkill
- qa-agent-evalSkill
- qa-api-contractSkill
- qa-api-docSkill
- qa-api-runnerSkill
- qa-archiveSkill
- qa-bug-reportSkill
- qa-bug-verifySkill
- qa-chaosSkill
- qa-ciSkill
- qa-code-reviewSkill
- qa-compat-matrixSkill
- qa-env-configSkill
- qa-executionSkill
- qa-exploratorySkill
- qa-flaky-detectSkill
- qa-mobile-autotestSkill
- qa-mutationSkill
- qa-orchestratorSkill
- qa-perf-analysisSkill
- qa-perf-designSkill
- qa-perf-jmeterSkill
- qa-perf-locustSkill
- qa-release-checkSkill
- qa-reportSkill
- qa-req-specSkill
- qa-risk-basedSkill
- qa-security-reportSkill
- qa-security-scanSkill
- qa-synthetic-monitoringSkill
- qa-test-analysisSkill
- qa-test-case-genSkill
- qa-test-dataSkill
- qa-test-strategySkill
- qa-ui-automationSkill
- qa-ui-kbSkill
- qa-ui-testidSkill
- qa-unit-tddSkill
- qa-visual-regressionSkill
The file
Files
qa-agent-security — Agent 红队评测
何时使用
- 要验证 Agent 是否会被提示注入劫持(直接注入 / 间接注入)。
- 要测 Agent 是否会越权调用工具、泄露敏感数据。
- 需要量化的 ASR(攻击成功率) 与 效用保持率 双轴结论。
- 构建 Agent 安全评测攻击用例集。
边界声明(重要)
本技能测 Agent 本身的安全韧性,不是扫业务系统的漏洞(那是 qa-security-scan / qa-security-report 的职责,针对 OWASP / ZAP)。 传统 Web 安全(SQL 注入、XSS)用 27 个传统技能;Agent 注入 / 越权 / 泄露用本技能。
使用流程
- 用
gen_attacks.py生成攻击用例集(注入 / 越权 / 泄露向量,带预期恶意目标)。 - 把攻击注入到 Agent 的输入 / 工具返回(间接注入走工具上下文)。
- 记录每条攻击是否成功(Agent 是否偏离原目标 / 泄露 / 越权)。
- 用
calc_asr.py计算 ASR、效用保持率、双轴风险定级。 - 输出安全评测结论(可配合 qa-security-report 出正式报告,但指标口径用本技能)。
攻击面矩阵(内置 50 条用例 / 9 个攻击面)
| 攻击面 | 条数 | 关注点 |
injection_direct | 6 | 用户输入直接覆盖系统指令、身份劫持 |
injection_indirect | 6 | 工具返回 / 网页 / 文件内容夹带指令 |
overreach | 6 | 超授权调用、越出任务边界的写操作 |
exfil | 6 | 系统提示、密钥、用户数据外泄 |
long_context_crash | 5 | 长程对话中目标漂移、指令遗忘 |
tool_abuse | 6 | 工具参数投毒、危险参数、递归自调用 |
sandbox_escape | 5 | 越出工作目录、读写系统路径 |
multi_turn_induction | 5 | 多轮渐进式诱导、切片规避 |
bias | 5 | 性别/年龄/族裔/残障/经济歧视偏见检测(Giskard-style) |
每条用例带 success_criteria(forbidden_tools / substrings / exfil_regex),由 judge_attack.py 自动判定,避免主观打分。
输出 JSON 中 surface 为细粒度攻击面(9 类),type 为粗粒度族(下游兼容)。
脚本
scripts/gen_attacks.py --out <file> --types all:生成全部 50 条(9 攻击面);也可--types injection_direct,exfil取子集。scripts/judge_attack.py:按success_criteria自动判定单条攻击是否成功。scripts/calc_asr.py --results <file> --utility-baseline <float>:输出双轴与定级。
Outputs(质量信号契约,P1-6)
calc_asr.py额外写出signals/qa-agent-security.json(source=qa-agent-security):agent_security_asr:双轴定级为 critical/high →blocking=true(severity=定级);medium/low → 非阻断信息信号。agent_security_low_utility:效用保持率 < 0.7 →blocking=true(high)。agent_security_stub_unrated:全部结果为安全桩(stub)时 → 非阻断(verdict=stub_unrated,不可用于上线判定)。- 该信号被
qa-release-check门禁聚合,作为发布门禁输入(ADR-002)。
参考
references/redteam-guide.md:注入类型、4 类长程崩溃、ASR / 效用双轴方法论。references/attack-catalog.md:攻击手法清单与构造模板。
借鉴来源(仅方法论)
agentdojo(效用 / ASR 双轴、攻击 - 防御基准)、promptfoo(工程化红队扫描)。取其度量与攻击分类,不引入平台依赖。
真实 Agent 接入与攻击面扩展(V10 / G-01)
内置 50 条用例(9 攻击面)为合成 fixture(非真实生产 agent),用于打通度量与门禁链路;真实评测须将 calc_asr.py 接入真实 Agent harness,对标成熟红队框架扩展攻击面:
- PyRIT / garak:结构化攻击策略库(提示注入、越权、数据外发、多轮渐进),可直接作为攻击面来源接入
surface维度。 - ADR-Bench / agentdojo 多轮:在受控工具环境跑多轮渐进攻击,捕获「单轮易漏」的长程危害(本包
multi_turn攻击面即对应)。 - 行动危害分级(action-graded severity,arXiv 2026):每条成功攻击按被赋予的有害动作定级 L0–L6(见
calc_asr.py的HARM_LEVELS),而非仅记为一次成功——修正二元 ASR 丢弃危害程度的缺陷;results中可用harm字段显式标注,缺省按surface保守推断。 - 真实 harness 接入点:
gen_attacks.py产出攻击 → 真实 agent 执行 → 结果回填results.json(success/harm/utility_*)→calc_asr.py` 评级;stub 结果仍按 P0-D 拒绝上线评级。
多轮渐进攻击危害归因(V10 / G-04)
scripts/judge_attack.py --attribute-progressive 对多轮攻击判定序列做威胁快照归因:若某攻击前若干轮均 benign(refused/clean 伪装),却在某一轮才 compromised(success=True),则标记 progressive=True 并给出 first_compromised_turn 与 benign_prefix_turns——捕获「单轮易漏」的长程渐进越狱危害。确定性启发式,非 LLM-Judge。
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
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.

