paperbot · PL 论文追踪

全部论文 待读 收藏

P2 HFuzzer: Testing Large Language Models for Package Hallucinations via Phrase-based Fuzzing

HFuzzer:通过基于短语的模糊测试检测大语言模型的包幻觉
ASE 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE)2025匹配度 2/10 · 该论文的目标是测试 LLM 本身的包幻觉行为,属于以 LLM 为研究对象的工作,而非将静态分析/形式化方法应用于 LLM 系统,也未用 LLM 改进程序分析,与浮点、贝叶斯程序分析均无交集。虽然使用模糊测试技术,但与画像核心方向(PL↔AI 双向交叉、浮点/贝叶斯分析)基本不匹配。引用 0 inbox
Yukai Zhao, Menghan Wu, Xing Hu, Xin Xia
crossref: 2026-09-12

AI 速览

一句话:提出基于短语的模糊测试框架 HFuzzer,触发并检测 LLM 代码生成中的包幻觉。

大语言模型在代码生成中会推荐不存在的软件包(包幻觉),攻击者可借此注册恶意包发起软件供应链攻击,但现有幻觉测试工作仅针对自然语言生成中的事实冲突。本文提出 HFuzzer,一个基于短语的模糊测试框架:以短语为种子引导模型推断更广泛的合理信息,生成足够多样化的编程任务,并从包信息或任务中抽取短语以保证短语与代码的相关性。在多个 LLM 上评估,所有模型均被触发包幻觉;相比变异模糊测试,HFuzzer 发现的唯一幻觉包多 2.60 倍,任务多样性更高;在 GPT-4o 上发现 46 个唯一幻觉包,并表明模型在辅助环境配置时也会出现包幻觉。

问题
大语言模型在代码生成中会推荐不存在的软件包(包幻觉),可被攻击者用于软件供应链攻击,而已有幻觉测试研究缺乏针对包幻觉的测试方法。
方法
提出基于短语的模糊测试框架 HFuzzer,以短语为种子引导模型推断更广泛的合理信息,并从包信息或编程任务中抽取短语,从而生成大量多样化且与代码相关的编程任务来触发包幻觉。
评估
在多个 LLM 上与变异模糊测试框架对比,统计触发的唯一幻觉包数量与任务多样性,并对 GPT-4o 做进一步分析。
原文摘要(Abstract)

Large Language Models (LLMs) are widely used for code generation, but they face critical security risks when applied to practical production due to package hallucinations, in which LLMs recommend non-existent packages. These hallucinations can be exploited in software supply chain attacks, where malicious attackers exploit them to register harmful packages. It is critical to test LLMs for package hallucinations to mitigate package hallucinations and defend against potential attacks. Although researchers have proposed testing frameworks for fact-conflicting hallucinations in natural language generation, there is a lack of research on package hallucinations. To fill this gap, we propose HFuzzer, a novel phrase-based fuzzing framework to test LLMs for package hallucinations. HFuzzer adopts fuzzing technology and guides the model to infer a wider range of reasonable information based on phrases, thereby generating enough and diverse coding tasks. Furthermore, HFuzzer extracts phrases from package information or coding tasks to ensure the relevance of phrases and code, thereby improving the relevance of generated tasks and code. We evaluate HFuzzer on multiple LLMs and find that it triggers package hallucinations across all selected models. Compared to the mutational fuzzing framework, HFuzzer identifies 2.60× more unique hallucinated packages and generates more diverse tasks. Additionally, when testing the model GPT-4o, HFuzzer finds 46 unique hallucinated packages. Further analysis reveals that for GPT-4o, LLMs exhibit package hallucinations not only during code generation but also when assisting with environment configuration.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot9562,
  title = {HFuzzer: Testing Large Language Models for Package Hallucinations via Phrase-based Fuzzing},
  author = {Yukai Zhao and Menghan Wu and Xing Hu and Xin Xia},
  booktitle = {ASE},
  year = {2025},
  doi = {10.1109/ase63991.2025.00225}
}