arXiv:2605.17450cs.SEcs.AI2026-05

通过对比运行时状态定位漏洞修复边界,提升自动化修复的准确性与可解释性。

ContraFix: Skill-Enhanced Contrastive Runtime Analysis for Vulnerability Repair

论文配图:ContraFix: Skill-Enhanced Contrastive Runtime Analysis for Vulnerability Repair
图 1 · 摘自论文原文
  • 构建失败与非失败变体,对比运行时状态以定位修复边界。
  • 在SEC-Bench上达到91.8%平均修复率,语义正确率达58.2%。
  • 支持技能复用,适合需高语义正确性的漏洞修复场景。

随着软件系统日益复杂,自动化漏洞修复(AVR)仍面临挑战,因修复系统通常只能获取故障结果而非修复指导。传统分析方法虽能提供可疑位置或约束,但配置成本高且难直接用于补丁生成。近期基于LLM的代理可编辑和验证仓库级补丁,经验系统可复用过往修复记录,但仍需当前实例证据,将泛化的故障报告转化为具体修复决策。本文提出ContraFix,一种通过对比运行时分析构建此类证据的智能修复框架。从失败样本出发,ContraFix生成邻近的失败与非失败变体,在对齐探测点执行并比较其运行时状态,推断修复边界以指导源码级修补。每个候选补丁仅在通过编译与验证后才被接受。此外,ContraFix将已验证的修复过程存入双轨技能库,复用变异技能构造有效变体,修正技能优化失败补丁。在SEC-Bench上,使用GPT-5-mini的ContraFix在三次重复实验中实现92.0%的解决率,平均解决率为91.8% ± 0.8;在PatchEval上,成功修复225个Go、Python和JavaScript实例中的73.8%。对基准验证的SEC-Bench补丁进行语义审计显示,ContraFix有58.2%的补丁语义正确,显著高于最强基线的31.3%,表明该框架在语义正确性方面超越基准验证。

原文摘要 · Abstract (English)

As software systems grow increasingly complex, automated vulnerability repair (AVR) remains difficult because the materials available to a repair system are usually failure artifacts rather than repair guidance. Traditional analysis techniques can provide suspicious locations, reduced triggers, or constraints, but they are costly to configure across repositories and seldom directly actionable for patch generation. Recent LLM-based agents can edit and validate repository-level patches, and experience-based systems can reuse prior repair traces or demonstrations, but they still need current-instance evidence that turns a broad, symptom-level failure report into a concrete repair decision. We present ContraFix, an agentic AVR framework that constructs such evidence through contrastive runtime analysis. Starting from a failing witness, ContraFix generates nearby failing and non-failing variants, executes them through aligned probe sites, and compares their runtime states to infer the repair boundary and guide source-level patching. Each candidate patch is accepted only after build and validation. ContraFix also stores validated repair episodes in a dual-track skill base, reusing mutation skills to construct useful variants and correction skills to refine failed patches. On SEC-Bench, ContraFix with GPT-5-mini achieves resolution rate of 92.0% over three repeated runs and an average resolution rate of 91.8% +/- 0.8. On PatchEval, it resolves 73.8% of 225 Go, Python, and JavaScript instances. A semantic audit of benchmark-validated SEC-Bench patches shows that 58.2% of ContraFix's patches are semantically correct, compared with 31.3% for the strongest baseline, indicating that the proposed framework improves semantic correctness beyond benchmark validation.

漏洞修复对比分析LLM运行时分析

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。