C-to-Rust Fallacy: Automatic Refactoring != Memory Security
Study finds most automatic C-to-Rust translations fail to compile or still carry memory bugs.
Researchers evaluated C2Rust-analyze, CROWN, C2SaferRust, and FLOURINE on 116 NIST Juliet C programs that contain memory-security bugs, generating 464 Rust programs. They report that 342 failed to compile, 177 inherited the original memory bugs, and 77 new Rust bugs were introduced. The paper argues current automatic refactoring meets the tools' own safety definitions but does not deliver broader memory security.
- 116 Juliet C programs yielded 464 Rust translations.
- 342 programs failed to compile and 177 kept original memory bugs.
- The tools introduced 77 new Rust bugs.
- Authors say defined safety is not broader memory security.
Full article257 words · extracted from arxiv.org · click to collapse
Rust has emerged as the leading system programming language, offering strong memory and type safety guarantees without compromising performance. This positions it as a compelling alternative to traditional languages like C and C++, which are susceptible to memory security bugs. However, manually transforming C to Rust requires in-depth domain knowledge of the Rust language features, which requires significant effort for developers. To address this, tools for automatic C-to-Rust refactoring aim to generate safe Rust code leveraging static analysis and Large Language Models (LLMs). While these tools claim to achieve safety by reducing the unsafe Rust, the correlation with improving security is not clear. In this paper, we conduct a comprehensive empirical study on the reliability, safety, and correctness of various C-to-Rust refactoring methods. Specifically, we evaluate C2Rust-analyze, CROWN, C2SaferRust, and FLOURINE using a dataset of 116 C programs with memory security bugs from the NIST Juliet Test Suite. Based on 464 Rust programs generated by these tools, our evaluation focuses on three key aspects: the compilation correctness of the refactored programs, the effectiveness in mitigating original C bugs, and the tendency to introduce additional Rust bugs. The results indicate that 342 Rust programs fail to compile, 177 Rust programs inherit memory security bugs from the original C programs, and 77 new Rust bugs are introduced. We examine the rationale behind tool design and analyze the root cause of errors across various refactoring methods. Our findings indicate that current automated refactoring tools deliver memory safety as they define it, but not the broader memory security when adopting them.
Text extracted automatically; images, tables and formatting may be missing. Original: https://arxiv.org/abs/2609.25682