Library fuzzing is a powerful technique for vulnerability detection; however, harness generation remains a critical bottleneck because API-centric libraries lack a single entry point. Existing LLM-based harness generation approaches often compose APIs...
Library fuzzing is a powerful technique for vulnerability detection; however, harness generation remains a critical bottleneck because API-centric libraries lack a single entry point. Existing LLM-based harness generation approaches often compose APIs without access to library-specific documentation or code context, leading to hallucinations, API misuse, and incorrect initialization, which result in a large number of non-executable harnesses. To address these limitations, we propose a framework for harness generation based on RAG. Our framework retrieves library resources, including API documentation, header files, and example code. It injects them into the LLM input context, enabling grounded harness generation that respects library-specific initialization rules and API usage constraints. In addition, we employ a compile-time validation and an iterative repair loop to filter and retain only executable harnesses that fuzzers can use directly. Experimental results demonstrate that RAG-based context injection significantly improves harness compilability and executability, and contributes to expanding the set of reachable functions during fuzzing. This work presents a new paradigm for combining RAG and LLMs in harness generation. It serves as a foundational technique for improving the reliability and efficiency of LLM-driven library fuzzing automation.