arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2410.04249cs.SE
收藏

DiffSpec:利用自然语言规范与代码工件进行基于大语言模型的差分测试

DiffSpec: Differential Testing with LLMs using Natural Language Specifications and Code Artifacts

Nikitha Rao, Elizabeth Gilbert, Harrison Green, Tahina Ramananandro, Nikhil Swamy, Claire Le Goues, Sarah Fakhoury

AI总结:

DiffSpec框架利用自然语言规范与代码工件引导大语言模型生成差分测试,在eBPF运行时和Wasm验证器中发现多个已确认缺陷。

摘要:

差分测试是发现具有多个实现且遵循同一规范的软件系统中缺陷的有效方法,例如编译器、网络协议解析器或语言运行时。此类系统的规范通常以自然语言文档形式标准化,如指令集架构(ISA)规范或IETF RFC。大语言模型(LLMs)已在生成测试和处理大量自然语言文本方面展现出潜力,使其非常适合分析规范文档、缺陷报告和代码实现等工件。在本工作中,我们利用自然语言和代码工件引导LLMs生成有针对性的测试,以突出实现之间有意义的行为差异,包括与缺陷相对应的差异。我们引入DiffSpec,一个通过提示链(prompt chaining)使用LLMs生成差分测试的框架。我们在两个不同的(经过广泛测试的)系统上展示了DiffSpec的有效性:eBPF运行时和Wasm验证器。使用DiffSpec,我们生成了1901个差异化测试,在eBPF中发现了至少四个不同且已确认的缺陷,包括一个内核内存泄漏、跳转指令中的不一致行为、使用栈指针时的未定义行为,以及导致ebpf-for-windows中验证器挂起的无限循环测试。我们还在Wasm验证器中发现了299个差异化测试,指向两个已确认并修复的缺陷。

英文摘要:

Differential testing can be an effective way to find bugs in software systems with multiple implementations that conform to the same specification, like compilers, network protocol parsers, or language runtimes. Specifications for such systems are often standardized in natural language documents, like Instruction Set Architecture (ISA) specifications or IETF RFC's. Large Language Models (LLMs) have demonstrated potential in both generating tests and handling large volumes of natural language text, making them well-suited for analyzing artifacts like specification documents, bug reports, and code implementations. In this work, we leverage natural language and code artifacts to guide LLMs to generate targeted tests that highlight meaningful behavioral differences between implementations, including those corresponding to bugs. We introduce DiffSpec, a framework for generating differential tests with LLMs using prompt chaining. We demonstrate DiffSpec's efficacy on two different (extensively tested) systems, eBPF runtimes and Wasm validators. Using DiffSpec, we generated 1901 differentiating tests, uncovering at least four distinct and confirmed bugs in eBPF, including a kernel memory leak, inconsistent behavior in jump instructions, undefined behavior when using the stack pointer, and tests with infinite loops that hang the verifier in ebpf-for-windows. We also found 299 differentiating tests in Wasm validators pointing to two confirmed and fixed bugs.

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

↑