A Study of Undefined Behavior Across Foreign Function Boundaries in Rust Libraries
<|reference_start|>A Study of Undefined Behavior Across Foreign Function Boundaries in Rust Libraries: Developers rely on the Rust programming language's static safety guarantees to write secure and performant applications. However, Rust is frequently used to interoperate with other languages which allow design patterns that conflict with Rust's aliasing models. Miri is the only dynamic analysis tool capable of validating applications against these models, but it does not support foreign functions, indicating that there may be a critical correctness gap at the heart of the Rust ecosystem. We conducted a large-scale evaluation of Rust libraries that call foreign functions to determine whether Miri's dynamic analyses remain useful in this context. We used Miri and an LLVM interpreter to jointly execute applications that call foreign functions, where we found 48 instances of undefined or undesired behavior. These include three bugs from libraries that had over 10,000 daily downloads on average during our observation period and one from a library maintained by the Rust Project. Many of the errors we found involved incompatible aliasing patterns, but Rust's latest Tree Borrows aliasing model was significantly more permissive than the earlier Stacked Borrows model. The Rust community must invest in new, production-ready tooling for multi-language applications to ensure that developers can detect these errors.<|reference_end|>
@article{mccormack2024a,
    title={A Study of Undefined Behavior Across Foreign Function Boundaries in Rust
  Libraries},
    author={Ian McCormack, Joshua Sunshine, Jonathan Aldrich},
    journal={arXiv preprint arXiv:2404.11671},
    year={2024},
    archivePrefix={arXiv},
    eprint={2404.11671},
    primaryClass={cs.SE}
}