HarnessLLM: Rust Verification Harness Generation with Large Language Models
Abstract
Rust's ownership model and type system offer strong memory safety guarantees, but unsafe code and runtime panics still present significant risks. Formal verification is essential to ensure memory safety, but developing verification harnesses remains a challenging and manual task. Although large language models (LLMs) have shown strong performance in various code analysis tasks, directly applying them to harness generation often results in inaccurate API invocations, inefficient nondeterministic data generation, and fabricated fixes. In this paper, we present HarnessLLM, an automated workflow that leverages LLMs to generate verification harnesses for Rust code directly from existing test suites. HarnessLLM automatically extracts calling scenarios from test cases, generates nondeterministic arguments based on dependency analysis, and incrementally synthesizes harnesses. It then iteratively refines the harnesses, preserving critical code regions and reporting fabricated types or functions to LLMs for correction. In our evaluation on 9 real-world Rust codebases, HarnessLLM extracted 294 calling scenarios from 494 test cases with 94.66% precision and generated harnesses for all scenarios in an average of 145 seconds each. It outperformed the existing approach, Autoharness, which succeeded on only 41% of those scenarios. Finally, 6 real-world memory safety bugs were detected using the generated harnesses, demonstrating the practical utility of our approach in verification. To our knowledge, this is the first work to use LLMs for generating harnesses aimed at memory safety verification in real-world Rust projects.
Create a lesson
Metadata
- Categories
- cs.SE, cs.CR
Related papers
From Industrial Product Documentation to Automated Digital Product Passport Generation: An Experimental Study of Large Language Models
Shared title terminologycs.SEMarco Buecheler, Grant Richards, Nathan Hartman
KaPilot: LLM-Assisted Generation of Kani Specifications for Unsafe Rust Verification
Shared title terminologycs.SEMinghua Wang, Yuxi Ling, Mingzhi Gao et al.
Automated Smoke Testing for Multi-ending Game Quests via Large Language Models
Shared title terminologycs.SEJinyu Cai, Mingyue Zhang, Nianyu Li et al.
How Far Can LLMs Go in Generating Android Lint Checks from Natural Language?
Shared title terminologycs.SEMoshood A. Fakorede, A. B. Siddique, Manu Sridharan et al.
Reliability is a user-specific property of large language models
Shared title terminologycs.SEXingyu Zhao
Trace2ST: Recovering PLC Structured Text from I/O Traces with LLM Generation and Verification
Shared title terminologycs.SEHsi Chang, Irfan Khan