C vs Rust: Manual vs Automatic Spatial and Temporal Memory Safety
DOI:
https://doi.org/10.33022/ijcs.v14i2.4640Keywords:
rust programming language, software security, memory safetyAbstract
The C programming language is commonly used for creating high-performance and low-level applications such as device drivers and operating systems due to its efficiency. However, despite its performance capabilities, C is known for its vulnerabilities and unsafe coding practices. Rust is presented as an alternative to C, with a focus on improved safety without compromising performance. Rust employs ownership and borrowing concepts to manage memory usage, ensuring that the memory cannot be manipulated freely without adhering to specific rules designed to prevent security attacks. The memory restrictions are implemented either at compile time or runtime without requiring the programmer's direct involvement; however, the programmer must adhere to a strict coding standard. In contrast, C programs can be secured by manually implementing similar restrictions on memory access and adding checks for unpredictable runtime behavior. While this approach offers some protection against attacks, it requires the developer to have detailed knowledge of memory management and programming best practices. This research focuses on evaluating memory safety issues in terms of spatial and temporal safety, comparing Rust's security mechanisms (or lack thereof) to C. Spatial safety involves securing vulnerable memory locations, while temporal safety ensures safe access to memory at different times. These concepts are frequently exploited by attackers to access data or inject attack payload. Our analysis demonstrates that Rust offers stronger guarantees for memory safety compared to manual security implementations in C. However, C remains a viable option for performance-critical applications, as it can still be secured through careful coding practices.
Downloads
Published
Issue
Section
License
Copyright (c) 2025 Amril Syalim, Dewangga Putra Sheradhien

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.