arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2510.03879cs.SEcs.AI
收藏

对抗性代理协作提升C到安全Rust翻译的正确性

Adversarial Agent Collaboration for Correctness Improvements of C to Safe Rust Translation

National University of Singapore(新加坡国立大学);Amazon Web Services(亚马逊网络服务)

Tianyu Li, Ruishi Li, Bo Wang, Brandon Paulsen, Umang Mathur, Prateek Saxena

AI总结:

本文提出ACToR框架,通过对抗性搜索发现翻译与C源码分歧的输入,利用这些输入驱动后续优化,提升C到Rust翻译的正确性,实验表明其在多个真实世界工具中达到90%以上的测试通过率。

摘要:

将C语言翻译成内存安全语言如Rust可以防止遗留C软件中普遍存在的关键内存安全漏洞。即使使用了最近的基于大语言模型(LLM)和工具增强的翻译器,生成的Rust代码在未测试的输入上仍经常与C源码产生分歧,这种正确性差距是自动C到Rust翻译可靠性的主要障碍。本文提出ACToR(对抗性C到Rust),一种简单的LLM代理循环,通过对抗性搜索发现翻译与C源码分歧的输入,并利用这些输入驱动后续优化。受生成对抗网络(GANs)启发,ACToR让翻译代理与鉴别代理协作,迭代优化Rust翻译。在每次迭代中,翻译代理生成并优化Rust翻译以通过现有测试套件,然后鉴别代理通过构造并优化C和Rust二进制文件的差分模糊器来发现新的失败测试。在63个真实世界命令行C工具上,平均代码行数为473行,最长可达数千行,ACToR在零人工干预下实现了超过90%的测试通过率。改进在七个代理-LLM配置上的微基准测试中保持稳定,表明该循环在底层翻译器和LLM选择上基本独立。与非对抗性、基于覆盖率的测试生成基线相比,ACToR将正确性提高了最高36.7%。当应用于最近的翻译器C2SaferRust时,ACToR进一步将验证通过率提高了16.6%。

英文摘要:

Translating C to memory-safe languages, like Rust, prevents critical memory safety vulnerabilities that are prevalent in legacy C software. Even with recent LLM-based and tool-augmented translators, the resulting Rust code frequently diverges from the C source on inputs absent from the test suite used during translation; this correctness gap on unseen inputs remains a dominant obstacle to reliable, automatic C-to-Rust translation. In this work, we present ACToR (Adversarial C To Rust), a simple LLM-agent loop that closes this gap by adversarially searching for inputs on which the translation diverges from the C source, and using them to drive subsequent refinements. Inspired by GANs, ACToR pits a translator agent against a discriminator agent that collaborate to iteratively refine the Rust translation. On each iteration, the translator agent synthesizes and refines a Rust translation to pass an existing suite of tests, and then the discriminator agent finds new failing tests by constructing and refining a differential fuzzer over the C and Rust binaries. Across 63 real-world command-line C utilities, with an average size of 473 lines of code and the longest reaching thousands of lines in size, ACToR achieves over 90% test pass rate with zero human intervention. The improvement holds across seven agent-LLM configurations on our micro-benchmark, indicating that the loop is largely independent of the choice of underlying translator and LLM. Compared to a non-adversarial, coverage-driven test-generation baseline, ACToR improves correctness by up to 36.7%. When applied on top of one recent translator, C2SaferRust, ACToR further improves the validation pass rate by 16.6%.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑