arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2603.08520cs.CRcs.SE
收藏

SCAFFOLD-CEGIS: 防止由LLM驱动的迭代代码精炼中的潜在安全退化

SCAFFOLD-CEGIS: Preventing Latent Security Degradation in LLM-Driven Iterative Code Refinement

Chengdu Institute of Computer Application Chinese Academy of Sciences(中国科学院成都计算机应用研究所);University of Chinese Academy of Sciences(中国科学院大学)

Yi Chen, Yun Bian, Haiquan Wang, Shihao Li, Zhe Cui

AI总结:

SCAFFOLD-CEGIS通过多智能体协作架构,将安全约束显式化,有效降低LLM驱动迭代代码精炼中的潜在安全退化率至2.1%。

摘要:

大型语言模型应用于代码生成已从单次生成发展到迭代精炼,但迭代过程中安全性的演变仍不够理解。通过在三个主流LLM上进行比较实验,本文揭示了迭代精炼悖论:在多目标优化过程中,规范漂移导致安全性能在连续迭代中逐渐退化。以GPT-4o为例,经过十轮迭代后,43.7%的迭代链包含比基线更多的漏洞,跨模型实验显示这种现象普遍存在。进一步分析表明,单纯引入静态应用安全测试(SAST)门控无法有效抑制退化;相反,它会将潜在安全退化率从无保护基线下的12.5%提升到20.8%。根本原因是静态分析规则无法覆盖结构退化,如防御逻辑的移除或异常处理的削弱。为解决此问题,我们提出了SCAFFOLD-CEGIS框架。借鉴反例引导归纳合成(CEGIS)范式,该框架采用多智能体协作架构,将安全约束从隐含提示转化为显式可验证约束。它通过语义锚定自动识别并固化安全关键元素为硬约束,通过四层门控验证强制安全单调性,并持续吸收失败经验。与六种现有防御方法的比较实验表明,完整框架将潜在安全退化率降至2.1%,并实现了100%的安全单调性率。

英文摘要:

The application of large language models to code generation has evolved from one-shot generation to iterative refinement, yet the evolution of security throughout iteration remains insufficiently understood. Through comparative experiments on three mainstream LLMs, this paper reveals the iterative refinement paradox: specification drift during multi-objective optimization causes security to degrade gradually over successive iterations. Taking GPT-4o as an example, 43.7 % of iteration chains contain more vulnerabilities than the baseline after ten rounds, and cross-model experiments show that this phenomenon is prevalent. Further analysis shows that simply introducing static application security testing (SAST) gating cannot effectively suppress degradation; instead, it increases the latent security degradation rate from 12.5% under the unprotected baseline to 20.8 %. The root cause is that static-analysis rules cannot cover structural degradations such as the removal of defensive logic or the weakening of exception handling. To address this problem, we propose the SCAFFOLD-CEGIS framework. Drawing on the counterexample-guided inductive synthesis (CEGIS) paradigm, the framework adopts a multi-agent collaborative architecture that transforms security constraints from implicit prompts into explicit verifiable constraints. It automatically identifies and solidifies security-critical elements as hard constraints through semantic anchoring, enforces safety monotonicity through four-layer gated verification, and continuously assimilates experience from failures. Comparative experiments against six existing defense methods show that the full framework reduces the latent security degradation rate to 2.1% and achieves a safety monotonicity rate of 100%.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑