[Paper Review] The FormAI Dataset: Generative AI in Software Security Through the Lens of Formal Verification
This paper introduces the FormAI dataset, a collection of 112,000 AI-generated, compilable C programs with formally verified vulnerabilities using ESBMC. It demonstrates that 51.24% of GPT-3.5-turbo-generated code contains security flaws, primarily buffer overflows, array bounds violations, arithmetic overflows, and dereference failures, highlighting critical risks in LLM-assisted software development.
This paper presents the FormAI dataset, a large collection of 112, 000 AI-generated compilable and independent C programs with vulnerability classification. We introduce a dynamic zero-shot prompting technique constructed to spawn diverse programs utilizing Large Language Models (LLMs). The dataset is generated by GPT-3.5-turbo and comprises programs with varying levels of complexity. Some programs handle complicated tasks like network management, table games, or encryption, while others deal with simpler tasks like string manipulation. Every program is labeled with the vulnerabilities found within the source code, indicating the type, line number, and vulnerable function name. This is accomplished by employing a formal verification method using the Efficient SMT-based Bounded Model Checker (ESBMC), which uses model checking, abstract interpretation, constraint programming, and satisfiability modulo theories to reason over safety/security properties in programs. This approach definitively detects vulnerabilities and offers a formal model known as a counterexample, thus eliminating the possibility of generating false positive reports. We have associated the identified vulnerabilities with Common Weakness Enumeration (CWE) numbers. We make the source code available for the 112, 000 programs, accompanied by a separate file containing the vulnerabilities detected in each program, making the dataset ideal for training LLMs and machine learning algorithms. Our study unveiled that according to ESBMC, 51.24% of the programs generated by GPT-3.5 contained vulnerabilities, thereby presenting considerable risks to software safety and security.
Motivation & Objective
- To assess the likelihood of LLM-generated code containing vulnerabilities without human intervention.
- To identify the most frequent vulnerability patterns introduced by GPT-3.5-turbo in C code.
- To create a large-scale, formally verified dataset for training machine learning models in software security.
- To provide a reproducible, open-source benchmark for evaluating AI-generated code security using formal verification.
- To detect and report previously unknown bugs in ESBMC, CBMC, and Clang through dataset-driven fuzzing.
Proposed method
- Generated 112,000 C programs using a dynamic zero-shot prompting technique with GPT-3.5-turbo to cover diverse programming tasks.
- Employed the Efficient SMT-based Bounded Model Checker (ESBMC) for formal verification of safety and security properties.
- Used symbolic execution and satisfiability modulo theories (SMT) to detect vulnerabilities with zero false positives via counterexamples.
- Configured ESBMC with a 30-second timeout and unwind bound of 1 to balance coverage and computational feasibility.
- Mapped detected vulnerabilities to Common Weakness Enumeration (CWE) identifiers for standardized classification.
- Excluded misleading line number reports for functions like gets() to improve data quality for ML applications.
Experimental results
Research questions
- RQ1RQ1: How likely is purely LLM-generated code to contain vulnerabilities on the first output when using simple zero-shot text-based prompts?
- RQ2RQ2: What are the most typical vulnerabilities LLMs introduce when generating code?
- RQ3RQ3: Can the FormAI dataset be used to uncover previously unknown bugs in formal verification tools and compilers?
Key findings
- 51.24% of the 112,000 GPT-3.5-turbo-generated C programs contained at least one verified vulnerability.
- A total of 197,800 vulnerabilities were detected across the dataset, with some programs containing multiple distinct issues.
- The most frequent vulnerabilities were buffer overflow, array bounds violation, arithmetic overflow, and dereference failure.
- These top vulnerabilities align with MITRE’s Top 25 CWE list, indicating high relevance to real-world security risks.
- The dataset enabled the discovery of multiple new bugs in ESBMC, CBMC, and the Clang compiler through systematic fuzzing.
- The dataset is publicly released with source code and vulnerability labels in CSV format, including filename, vulnerability type, function name, line number, and CWE mapping.
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.