[Paper Review] A New Era in Software Security: Towards Self-Healing Software via Large Language Models and Formal Verification
The paper combines bounded model checking with a GPT-like LLM to detect, explain, and repair C code vulnerabilities, achieving up to 80% repair success on a 1000-sample dataset. It introduces ESBMC-AI to iteratively verify and fix code through counterexamples.
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.
Motivation & Objective
- Motivate combining formal verification with LLMs to repair software vulnerabilities.
- Demonstrate a counterexample-guided repair loop that uses BMC outputs to steer LLMs.
- Evaluate the approach on a large, synthetic C-code dataset focusing on memory safety issues.
- Show feasibility of integrating the approach into CI/CD pipelines.
Proposed method
- Use Bounded Model Checking to locate vulnerabilities and generate counterexamples in C programs.
- Provide counterexamples and source code to an LLM with a specialized prompt language for debugging and patch generation.
- Have the LLM generate corrected code which is then re-verified by BMC for safety/security properties.
- Implement ESBMC-AI by integrating ESBMC with GPT-3.5-turbo and a GPT-based software verifier plugin.
- Evaluate on a dataset of 1000 C programs containing 20–50 lines each.
- Report a success rate of up to 80% in repairing vulnerabilities such as buffer overflows and pointer dereferences.
Experimental results
Research questions
- RQ1Can BMC-generated counterexamples effectively guide LLM-based program repair?
- RQ2To what extent can the combination of ESBMC and GPT-3.5-turbo repair memory-safety vulnerabilities in C code?
- RQ3What is the impact of verification feedback on the quality of patches produced by LLMs?
- RQ4How well can the proposed ESBMC-AI framework integrate into CI/CD workflows?
Key findings
- The integrated approach repaired up to 80% of tested vulnerable C samples.
- The dataset consisted of 1000 code samples with 20–50 lines each.
- Counterexamples from BMC were used to steer LLMs toward correct fixes.
- The corrected code was re-verified by BMC to confirm safety properties.
- An ESBMC-AI prototype combined ESBMC with GPT-3.5-turbo and demonstrated iterative repair and verification.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.