Skip to main content
QUICK REVIEW

[论文解读] The FormAI Dataset: Generative AI in Software Security Through the Lens of Formal Verification

Norbert Tihanyi, Tamás Bisztray|arXiv (Cornell University)|Jul 5, 2023
Software Engineering ResearchComputer Science参考文献 39被引用 3
一句话总结

本文介绍了FormAI数据集,该数据集包含112,000个由AI生成的、可编译的C程序,其安全漏洞通过ESBMC进行了形式化验证。结果表明,51.24%的GPT-3.5-turbo生成代码包含安全缺陷,主要为缓冲区溢出、数组边界违规、算术溢出和解引用失败,凸显了大型语言模型辅助软件开发中的关键风险。

ABSTRACT

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.

研究动机与目标

  • 评估在无任何人工干预的情况下,大型语言模型生成的代码中包含漏洞的可能性。
  • 识别GPT-3.5-turbo在生成C代码时引入的最常见漏洞模式。
  • 创建一个大规模、经形式化验证的数据集,用于训练软件安全领域的机器学习模型。
  • 提供一个可复现的、开源的基准,用于通过形式化验证评估AI生成代码的安全性。
  • 通过数据驱动的模糊测试,检测并报告ESBMC、CBMC和Clang中此前未知的错误。

提出的方法

  • 使用GPT-3.5-turbo通过动态零样本提示技术生成112,000个C程序,以覆盖多样化的编程任务。
  • 采用基于高效SMT的有界模型检测器(ESBMC)对安全与安全属性进行形式化验证。
  • 通过符号执行和满足模理论(SMT)技术检测漏洞,利用反例实现零误报。
  • 将ESBMC配置为30秒超时和1的展开边界,以在覆盖范围与计算可行性之间取得平衡。
  • 将检测到的漏洞映射到通用弱点枚举(CWE)标识符,实现标准化分类。
  • 排除gets()等函数的误导性行号报告,以提升数据质量,适用于机器学习应用。

实验结果

研究问题

  • RQ1RQ1:在仅使用简单零样本文本提示的情况下,纯大型语言模型生成的代码在首次输出时包含漏洞的可能性有多大?
  • RQ2RQ2:大型语言模型在生成代码时最常引入哪些典型漏洞?
  • RQ3RQ3:FormAI数据集能否用于发现形式化验证工具和编译器中的先前未知错误?

主要发现

  • 在112,000个由GPT-3.5-turbo生成的C程序中,有51.24%至少包含一个经验证的漏洞。
  • 在数据集中共检测到197,800个漏洞,部分程序包含多个不同的问题。
  • 最常见的漏洞类型为缓冲区溢出、数组边界违规、算术溢出和解引用失败。
  • 这些主要漏洞与MITRE的Top 25 CWE列表一致,表明其与现实世界安全风险高度相关。
  • 通过系统性模糊测试,该数据集成功发现了ESBMC、CBMC和Clang编译器中的多个新错误。
  • 该数据集已公开发布,包含源代码和以CSV格式提供的漏洞标签,涵盖文件名、漏洞类型、函数名、行号及CWE映射。

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。