HFuzzer: Testing Large Language Models for Package Hallucinations via Phrase-based Fuzzing
Not on the map. Why?
Abstract (arXiv)
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.60x 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.
Key facts. Cited by 1 paper in the map (data through 14 Oct 2026). Builds on 42 of its 77 references that are in the map. First posted on arXiv 28 Sep 2025.
Builds on
42 of 77 references.
References · 42
- 2023GPT-4 Technical Reportcited by 18,396
- 2024GPT-4o System Cardcited by 4,588
- 2023Mistral 7Bcited by 3,164
- 2023Retrieval-Augmented Generation for Large Language Models: A Surveycited by 2,212
- 2022Survey of Hallucination in Natural Language Generationcited by 2,075
- 2023Is Your Code Generated by ChatGPT Really Correct? Rigorous Evaluation of Large Language Models for Code Generationcited by 1,391
- 2024Qwen2.5-Coder Technical Reportcited by 1,203
- 2024DeepSeek-Coder: When the Large Language Model Meets Programming -- The Rise of Code Intelligencecited by 1,181
- 2024OpenHands: An Open Platform for AI Software Developers as Generalist Agentscited by 1,002
- 2023Siren's Song in the AI Ocean: A Survey on Hallucination in Large Language Modelscited by 698
- 2023GPTFUZZER: Red Teaming Large Language Models with Auto-Generated Jailbreak Promptscited by 560
- 2024INSIDE: LLMs' Internal States Retain the Power of Hallucination Detectioncited by 323
30 more
- 2024OR-Bench: An Over-Refusal Benchmark for Large Language Modelscited by 244
- 2023MasterKey: Automated Jailbreak Across Multiple Large Language Model Chatbotscited by 183
- 2023Keep the Conversation Going: Fixing 162 out of 337 bugs for 0.42 each using ChatGPTcited by 125
- 2023Enhancing Uncertainty-Based Hallucination Detection with Stronger Focuscited by 99
- 2023Fuzz4All: Universal Fuzzing with Large Language Modelscited by 88
- 2023Refining ChatGPT-Generated Code: Characterizing and Mitigating Code Quality Issuescited by 79
- 2022Automated Repair of Programs from Large Language Modelscited by 71
- 2024Defending LLMs against Jailbreaking Attacks via Backtranslationcited by 70
- 2024We Have a Package for You! A Comprehensive Analysis of Package Hallucinations by Code Generating LLMscited by 65
- 2025JBShield: Defending Large Language Models from Jailbreak Attacks through Activated Concept Analysis and Manipulationcited by 54
- 2023FuzzLLM: A Novel and Universal Fuzzing Framework for Proactively Discovering Jailbreak Vulnerabilities in Large Language Modelscited by 51
- 2023When ChatGPT Meets Smart Contract Vulnerability Detection: How Far Are We?cited by 42
- 2024Detecting Hallucinations in Large Language Model Generation: A Token Probability Approachcited by 42
- 2023SALLM: Security Assessment of Generated Codecited by 39
- 2025Repo2Run: Automated Building Executable Environment for Code Repository at Scalecited by 39
- 2024CodeHalu: Investigating Code Hallucinations in LLMs via Execution-based Verificationcited by 34
- 2023Teaching Language Models to Hallucinate Less with Synthetic Taskscited by 31
- 2025Hallucination Detection in Large Language Models with Metamorphic Relationscited by 24
- 2024On Mitigating Code LLM Hallucinations with API Documentationcited by 21
- 2024The Current Challenges of Software Engineering in the Era of Large Language Modelscited by 21
- 2023Fuzzing Automatic Differentiation in Deep-Learning Librariescited by 17
- 2025Importing Phantoms: Measuring LLM Package Hallucination Vulnerabilitiescited by 15
- 2024Drowzee: Metamorphic Testing for Fact-Conflicting Hallucination Detection in Large Language Modelscited by 14
- 2024Fight Fire with Fire: How Much Can We Trust ChatGPT on Source Code-Related Tasks?cited by 7
- 2024Is ChatGPT a Good Software Librarian? An Exploratory Study on the Use of ChatGPT for Software Library Recommendationscited by 7
- 2024MORTAR: Multi-turn Metamorphic Testing for LLM-based Dialogue Systemscited by 7
- 2024ChatGPT Incorrectness Detection in Software Reviewscited by 5
- 2024DistillSeq: A Framework for Safety Alignment Testing in Large Language Models using Knowledge Distillationcited by 5
- 2024CovRL: Fuzzing JavaScript Engines with Coverage-Guided Reinforcement Learning for LLM-based Mutationcited by 3
- 2025Assessing Reliability of Statistical Maximum Coverage Estimators in Fuzzingcited by 1
Built on by
Citing papers per year: 2026: 1.
1 paper.