post-patch-validation
它能做什么
在原始代码和修补后的代码上运行可重复的测试,检查安全修补,涵盖报告的利用、类似变体、回归和新风险。适用于决定修补是否可以接受的审查人员和团队。
适用场景
- ✓安全修补、修复提交或拉取请求准备好待审查的时候。
- ✓AI 生成的修补需要在人工审查或合并之前进行验证的时候。
- ✓修补可能修复了一条利用路径,却遗漏了同一原因的其他变体的时候。
技能链接
https://github.com/trailofbits/skills/blob/main/plugins/post-patch-validation/skills/post-patch-validation/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“请用原始利用来验证这个安全修补,并检查它可能遗漏的变体。”
每周 5 个新技能,1 分钟读完。
工作原理
该技能固定有漏洞的基线版本和修补后的版本,运行原始证明和相关变体,并检查应保留的行为是否仍然正常。它会报告失败的内容以及尚未测试的部分。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
Post-Patch Validation
Validate a security patch against the reported bug and the surrounding code it affects. Give the patch author reproducible failures to fix and identify what still needs testing. Apply the same checks to human and agent patches. The diff, author, upstream implementation, and original proof of concept alone cannot establish correctness.
When to Use
- A security fix, remediation commit, patch file, or pull request already exists.
- An AI-generated patch needs validation before human review or merge.
- A fix may cover one exploit path while missing variants of the same root cause.
- A security fix may alter legitimate behavior or introduce a new vulnerability.
- A patch author needs concrete failures and coverage gaps before another revision.
When NOT to Use
- No patch exists yet; use vulnerability discovery or fix implementation first.
- The task is to review an audit finding against a report without executing patch evidence.
- The task is only to convert a finding into a permanent project test.
- The target is remote or production. This skill executes local code and tests only.
- The user has not authorized execution of the repository's code or test suite.
Quick Start
Pin the vulnerable base and patched input. Prefer immutable commits. For uncommitted work, create a binary patch file first; do not validate in the user's working tree.
Scaffold a pinned plan:
uv run {baseDir}/scripts/post_patch_validation.py scaffold \ --repo . \ --base-ref <vulnerable-ref> \ --patched-ref <patched-ref> \ --finding-id <stable-id> \ --finding-summary "<root cause and impact>" \ --evidence-level runtime \ --output post-patch-validation/plan.jsonUse
--patch-file <path>instead of--patched-reffor a patch artifact. Choose the highest honest evidence level:sourcefor source/patch invariants only,buildwhen target code is compiled or analyzed but the reported behavior is not executed, orruntimewhen the checks execute the reported behavior and its safety assertions.Inspect the finding, diff, callers, sibling paths, cleanup/error paths, and existing tests. Populate
checksin the generated plan. Runprint-schemafor the structural schema:uv run {baseDir}/scripts/post_patch_validation.py print-schemaRun
validate-planfor the complete validation, including coverage, command restrictions, and pinned inputs, before executing code:uv run {baseDir}/scripts/post_patch_validation.py validate-plan \ --plan post-patch-validation/plan.jsonExecute the evidence plan:
uv run {baseDir}/scripts/post_patch_validation.py run \ --plan post-patch-validation/plan.json \ --output post-patch-validation/resultsReport
result.json,report.md, the evidence level, and the completeassessment. Return each finding to the patch author with its check ID, assertion, and saved logs. Identify each validation gap separately, including gaps that coexist with supported findings. After the author revises the patch, pin the new inputs and save a fresh validation run. Preserve the prior evidence. Passing supplied checks still requires human review before acceptance.
Evidence Contract
The runner rejects incomplete plans. Supply at least one check of every kind:
| Kind | Required observation |
|---|---|
control |
Benign harness succeeds on both base and patch |
exploit |
Original safety assertion fails on base and succeeds on patch |
variant |
A distinct root-cause variant fails on base and succeeds on patch |
behavior |
Unaffected behavior succeeds with byte-identical selected output |
regression |
Targeted non-security regression check succeeds on both revisions |
security |
Adjacent/new-vulnerability check succeeds on base and patch |
suite |
Existing project suite, sanitizer, or deterministic fuzz campaign succeeds on patch |
Commands are argv arrays, never shell strings. Put complex setup in a checked-in or plan artifact
script and invoke it with {plan_dir}. The runner fixes locale/timezone/hash-seed inputs, executes
checks in lexical ID order, records raw stdout/stderr, and never edits the original worktree.
Each check's timeout_seconds defaults to 300 and accepts integers from 1 through 3600.
Exceeding the timeout leaves a validation gap. A timeout alone does not establish a regres
常见问题
它能用于远程或正式环境的系统吗?
不能。它只在你授权的情况下执行本地代码和测试。
干净的差异就足以信任修补吗?
不够。该技能说明,仅凭差异、作者或原始证明都无法确定正确性。
它能帮助修补的作者吗?
能。它会为下一次修订提供具体的失败情况和覆盖空白。
详情
作者的原始描述
Validates security patches with reproducible baseline-versus-patched evidence, including original exploits, root-cause variants, behavior preservation, regressions, and newly introduced security failures. Use after a patch exists and before accepting, merging, or reporting it as fixed; also use when an AI-generated patch, remediation commit, pull request, or proposed upstream fix needs adversarial post-patch validation across any language.
repo: trailofbits/skills
热度
- GitHub 星标
- 8.0k
- 排名
- #12693
- 许可证
- CC-BY-SA-4.0
- 更新时间
- 2026/11/2
评论
- …
同一仓库的更多技能
audit-context-building
8.0k帮你的智能体在安全审查之前熟悉一个陌生的代码库,梳理每个函数的假设、保证和依赖关系。
algorand-vulnerability-scanner
8.0k帮你的智能体扫描 TEAL 或 PyTeal 编写的 Algorand 智能合约,检查 11 类常见安全问题,如重新密钥攻击和未校验费用。
audit-prep-assistant
8.0k帮你的智能体为外部安全审查做好代码准备,包括静态分析、测试覆盖、死代码清理和清晰的文档。
cairo-vulnerability-scanner
8.0k帮你的智能体扫描 StarkNet 上的 Cairo 智能合约,检查 6 类严重问题,包括算术溢出、有风险的跨层消息和签名重放。