arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2411.11532cs.SEcs.CR
收藏

CKGFuzzer:基于代码知识图谱增强的LLM模糊测试驱动生成

CKGFuzzer: LLM-Based Fuzz Driver Generation Enhanced By Code Knowledge Graph

Hanxiang Xu, Wei Ma, Ting Zhou, Yanjie Zhao, Kai Chen, Qiang Hu, Yang Liu, Haoyu Wang

AI总结:

本文提出CKGFuzzer,一种基于代码知识图谱和LLM智能体的自动化模糊测试方法,通过在模糊测试循环中自动生成并优化测试驱动与输入种子,相比现有技术代码覆盖率平均提升8.73%,并成功检测出11个真实漏洞。

摘要:

近年来,大型语言模型(LLMs)的编程能力引起了广泛关注。模糊测试作为一种高效的技术,在增强软件可靠性和检测漏洞方面发挥着关键作用。然而,传统的模糊测试工具依赖于手工编写的模糊测试驱动,这限制了测试的效率和有效性。为了解决这一挑战,我们提出了一种由代码知识图谱驱动并基于LLM智能体系统支持的自动化模糊测试方法,称为CKGFuzzer。我们将模糊测试驱动创建视为代码生成任务,利用代码仓库的知识图谱在模糊测试循环中自动化生成过程,同时不断完善模糊测试驱动和输入种子。代码知识图谱通过过程间程序分析构建,图中的每个节点代表一个代码实体,如函数或文件。知识图谱增强的CKGFuzzer不仅有效解决了模糊测试驱动中的编译错误,并生成针对特定API使用场景定制的输入种子,还能分析模糊测试驱动崩溃报告,协助开发者提高代码质量。通过查询代码仓库的知识图谱并学习API使用场景,我们能更好地识别测试目标并理解每个模糊测试驱动的具体用途。我们使用八个开源软件项目评估了该方法。实验结果表明,与最先进的技术相比,CKGFuzzer在代码覆盖率上平均提高了8.73%。此外,CKGFuzzer将崩溃案例分析中的人工审查工作量减少了84.4%,并在测试库中成功检测出11个真实漏洞(包括9个此前未报告的漏洞)。

英文摘要:

In recent years, the programming capabilities of large language models (LLMs) have garnered significant attention. Fuzz testing, a highly effective technique, plays a key role in enhancing software reliability and detecting vulnerabilities. However, traditional fuzz testing tools rely on manually crafted fuzz drivers, which can limit both testing efficiency and effectiveness. To address this challenge, we propose an automated fuzz testing method driven by a code knowledge graph and powered by an LLM-based intelligent agent system, referred to as CKGFuzzer. We approach fuzz driver creation as a code generation task, leveraging the knowledge graph of the code repository to automate the generation process within the fuzzing loop, while continuously refining both the fuzz driver and input seeds. The code knowledge graph is constructed through interprocedural program analysis, where each node in the graph represents a code entity, such as a function or a file. The knowledge graph-enhanced CKGFuzzer not only effectively resolves compilation errors in fuzz drivers and generates input seeds tailored to specific API usage scenarios, but also analyzes fuzz driver crash reports, assisting developers in improving code quality. By querying the knowledge graph of the code repository and learning from API usage scenarios, we can better identify testing targets and understand the specific purpose of each fuzz driver. We evaluated our approach using eight open-source software projects. The experimental results indicate that CKGFuzzer achieved an average improvement of 8.73% in code coverage compared to state-of-the-art techniques. Additionally, CKGFuzzer reduced the manual review workload in crash case analysis by 84.4% and successfully detected 11 real bugs (including nine previously unreported bugs) across the tested libraries.

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

↑