[论文解读] A New Era in Software Security: Towards Self-Healing Software via Large Language Models and Formal Verification
本文将有界模型检验与 GPT 类大型语言模型相结合,以检测、解释并修复 C 代码漏洞,在 1000 个样本的数据集上实现高达 80% 的修复成功率。它引入 ESBMC-AI,通过对照案例迭代验证和修复代码。
This paper introduces an innovative approach that combines Large Language Models (LLMs) with Formal Verification strategies for automatic software vulnerability repair. Initially, we employ Bounded Model Checking (BMC) to identify vulnerabilities and extract counterexamples. These counterexamples are supported by mathematical proofs and the stack trace of the vulnerabilities. Using a specially designed prompt, we combine the original source code with the identified vulnerability, including its stack trace and counterexample that specifies the line number and error type. This combined information is then fed into an LLM, which is instructed to attempt to fix the code. The new code is subsequently verified again using BMC to ensure the fix succeeded. We present the ESBMC-AI framework as a proof of concept, leveraging the well-recognized and industry-adopted Efficient SMT-based Context-Bounded Model Checker (ESBMC) and a pre-trained transformer model to detect and fix errors in C programs, particularly in critical software components. We evaluated our approach on 50,000 C programs randomly selected from the FormAI dataset with their respective vulnerability classifications. Our results demonstrate ESBMC-AI's capability to automate the detection and repair of issues such as buffer overflow, arithmetic overflow, and pointer dereference failures with high accuracy. ESBMC-AI is a pioneering initiative, integrating LLMs with BMC techniques, offering potential integration into the continuous integration and deployment (CI/CD) process within the software development lifecycle.
研究动机与目标
- 将形式化验证与大语言模型相结合以修复软件漏洞作为动力。
- 演示一个以对照案例为引导的修复循环,使用 BMC 输出引导 LLM。
- 在大规模、合成的 C 代码数据集上评估该方法,聚焦内存安全问题。
- 展示将该方法集成到 CI/CD 流程中的可行性。
提出的方法
- 使用有界模型检验来定位 C 程序中的漏洞并生成反例。
- 向 LLM 提供反例和源代码,配备用于调试和补丁生成的专用提示语言。
- 让 LLM 生成纠正后的代码,然后由 BMC 重新验证其安全性属性。
- 通过将 ESBMC 与 GPT-3.5-turbo 以及基于 GPT 的软件验证插件集成,实现 ESBMC-AI。
- 在包含每个 20–50 行的 1000 个 C 程序的数据集上进行评估。
- 报告在修复诸如缓冲区溢出和指针解引用等漏洞方面的成功率高达 80%。
实验结果
研究问题
- RQ1由 BMC 生成的对立案例是否能有效引导基于 LLM 的程序修复?
- RQ2将 ESBMC 与 GPT-3.5-turbo 的结合在多大程度上能够修复 C 代码中的内存安全漏洞?
- RQ3验证反馈对 LLM 产生的补丁质量有何影响?
- RQ4所提出的 ESBMC-AI 框架能够在 CI/CD 流程中整合得有多好?
主要发现
- 集成方法在测试的易受攻击的 C 样本中修复率高达 80%。
- 数据集包含 1000 个代码样本,每个 20–50 行。
- 来自 BMC 的对立案例被用来引导 LLM 朝向正确的修复。
- 纠正后的代码经由 BMC 重新验证以确认安全属性。
- 一个 ESBMC-AI 原型将 ESBMC 与 GPT-3.5-turbo 结合起来,并演示了迭代修复与验证。
阅读本论文
在 Nubint 阅读器中打开原文,边读边就任意段落提问。
在 Nubint 中阅读本论文本解读由 AI 根据论文原文生成,引用前请核对原文。