[论文解读] Large Language Models are Edge-Case Fuzzers: Testing Deep Learning Libraries via FuzzGPT
FuzzGPT 通过利用上下文学习与微调,促使大型语言模型生成不寻常的、边缘情况的 Python 代码片段来模糊测试深度学习库,从而超越 TitanFuzz,利用历史 bug 数据。
Deep Learning (DL) library bugs affect downstream DL applications, emphasizing the need for reliable systems. Generating valid input programs for fuzzing DL libraries is challenging due to the need for satisfying both language syntax/semantics and constraints for constructing valid computational graphs. Recently, the TitanFuzz work demonstrates that modern Large Language Models (LLMs) can be directly leveraged to implicitly learn all the constraints to generate valid DL programs for fuzzing. However, LLMs tend to generate ordinary programs following similar patterns seen in their massive training corpora, while fuzzing favors unusual inputs that cover edge cases or are unlikely to be manually produced. To fill this gap, this paper proposes FuzzGPT, the first technique to prime LLMs to synthesize unusual programs for fuzzing. FuzzGPT is built on the well-known hypothesis that historical bug-triggering programs may include rare/valuable code ingredients important for bug finding. Traditional techniques leveraging such historical information require intensive human efforts to design dedicated generators and ensure the validity of generated programs. FuzzGPT demonstrates that this process can be fully automated via the intrinsic capabilities of LLMs (including fine-tuning and in-context learning), while being generalizable and applicable to challenging domains. While FuzzGPT can be applied with different LLMs, this paper focuses on the powerful GPT-style models: Codex and CodeGen. Moreover, FuzzGPT also shows the potential of directly leveraging the instruct-following capability of the recent ChatGPT for effective fuzzing. Evaluation on two popular DL libraries (PyTorch and TensorFlow) shows that FuzzGPT can substantially outperform TitanFuzz, detecting 76 bugs, with 49 already confirmed as previously unknown bugs, including 11 high-priority bugs or security vulnerabilities.
研究动机与目标
- 推动对 DL 库进行健壮性测试,因为错误的下游影响广泛。
- 提出通过利用历史的触发错误代码搭配 LLM 来生成不寻常的输入程序的 FuzzGPT。
- 通过上下文学习和微调自动化生成触发错误的代码。
- 在 PyTorch 和 TensorFlow 上评估 FuzzGPT 并与 TitanFuzz 进行比较。
- 通过自动化模糊测试展示发现新错误与潜在漏洞。
提出的方法
- 从目标 DL 库的 GitHub issue 和 PR 中挖掘触发错误的代码片段。
- 使用自我训练的 LLM 方法对每个代码片段中的错误 API 进行标注,手工标签很少。
- 应用三种学习策略来生成边缘情况的模糊测试代码:少样本上下文学习、零样本完成/编辑,以及针对触发错误代码的微调。
- 用崩溃、CPU/GPU 一致性以及自动微分 (AD) 预言来检测错误,执行生成的程序。
- 在 PyTorch 和 TensorFlow 库上使用 Codex 与 CodeGen LLM,以及零-shot 的 ChatGPT 变体进行评估。

实验结果
研究问题
- RQ1研究问题1:不同的 FuzzGPT 学习范式(少样本、零样本、微调)在效果上有何差异?
- RQ2研究问题2:FuzzGPT 相对于现有模糊测试工具(如 TitanFuzz)的表现如何?
- RQ3研究问题3:FuzzGPT 的关键组件如何推动其效果?
- RQ4研究问题4:FuzzGPT 能否在真实世界的 DL 库中发现新 bug?
主要发现
- FuzzGPT 的变体在 PyTorch/TensorFlow 上的覆盖率分别比 TitanFuzz 高出 60.70%/36.03%。
- FuzzGPT 在最新的 PyTorch 和 TensorFlow 版本中发现了 76 个 bug。
- 其中 49 个为新识别的,11 个被归为高优先级或与安全相关。
- 研究从 GitHub 矿取了 1,750 条 PyTorch 和 633 条 TensorFlow 触发错误的代码片段。
- FuzzGPT 在 Codex、CodeGen 以及基于 ChatGPT 的零-shot 变体上均表现出成效。
- 该方法实现了全自动化,并且可推广到除了 DL 库以外的其他领域。

更好的研究,从现在开始
从阅读论文到最终审阅,大幅缩短您的研究时间。
无需绑定信用卡
本解读由 AI 生成,并经人工编辑审核。