A Study of Undefined Behavior Across Foreign Function Boundaries in Rust Libraries
Ian McCormack, Joshua Sunshine, Jonathan Aldrich
Abstract
Developers rely on the static safety guarantees of the Rust programming language 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 evolving aliasing models. Miri is currently the only dynamic analysis tool that can validate applications against these models, but it does not support finding bugs in foreign functions, indicating that there may be a critical correctness gap across 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 46 instances of undefined or undesired behavior in 37 libraries. Three bugs were found in libraries that had more than 10,000 daily downloads on average during our observation period, and one was found in a library maintained by the Rust Project. Many of these bugs were violations of Rust's aliasing models, but the latest Tree Borrows 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.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
5 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- Miri: Practical Undefined Behavior Detection for Rust cites Tree Borrows
- Miri: Practical Undefined Behavior Detection for Rust cites Stacked borrows: an aliasing model for Rust
- MirChecker: Detecting Bugs in Rust Programs via Static Analysis cites Understanding memory and thread safety practices and issues in real-world Rust programs
- Rudra: Finding Memory Safety Bugs in Rust at the Ecosystem Scale cites Understanding memory and thread safety practices and issues in real-world Rust programs
- Rudra: Finding Memory Safety Bugs in Rust at the Ecosystem Scale cites How do programmers use unsafe rust?
- Rudra: Finding Memory Safety Bugs in Rust at the Ecosystem Scale cites Stacked borrows: an aliasing model for Rust
- Understanding memory and thread safety practices and issues in real-world Rust programs cites Stacked borrows: an aliasing model for Rust
- How do programmers use unsafe rust? cites Understanding memory and thread safety practices and issues in real-world Rust programs
- Tree Borrows cites Stacked borrows: an aliasing model for Rust
- RustGo: Fairly Directed Greybox Fuzzing for Enforcing Rust Memory Safety cites MirChecker: Detecting Bugs in Rust Programs via Static Analysis
- RustGo: Fairly Directed Greybox Fuzzing for Enforcing Rust Memory Safety cites Rudra: Finding Memory Safety Bugs in Rust at the Ecosystem Scale
- RustGo: Fairly Directed Greybox Fuzzing for Enforcing Rust Memory Safety cites How do programmers use unsafe rust?
- Securing Mixed Rust with Hardware Capabilities cites How do programmers use unsafe rust?
- Securing Mixed Rust with Hardware Capabilities cites Stacked borrows: an aliasing model for Rust
Cited by top-tier papers5
- Miri: Practical Undefined Behavior Detection for RustRalf Jung, Benjamin Kimock, Christian Poveda, Eduardo Sánchez Muñoz et al.POPL 2026 · 8 citations
- Tree BorrowsNeven Villani, Johannes Hostert, Derek Dreyer, Ralf JungPLDI 2025 · 8 citations
- Securing Mixed Rust with Hardware CapabilitiesJason Zhijingcheng Yu, Fangqi Han, Kaustab Choudhury, Trevor E. Carlson et al.CCS 2025 · 1 citation
- Building Bridges: Safe Interactions with Foreign Languages through OmniglotLeon Schuermann, Jack Toubes, Tyler Potyondy, Pat Pannuto et al.OSDI 2025
- RustGo: Fairly Directed Greybox Fuzzing for Enforcing Rust Memory SafetyDongyeon Yu, Jiun Min, Yewan Na, Mijung Kim et al.CCS 2026
Builds on10
- Understanding memory and thread safety practices and issues in real-world Rust programsBoqin Qin, Yilun Chen, Zeming Yu, Linhai Song et al.PLDI 2020 · 112 citations
- How do programmers use unsafe rust?Vytautas Astrauskas, Christoph Matheja, Federico Poli, Peter Müller et al.OOPSLA 2020 · 78 citations
- Stacked borrows: an aliasing model for RustRalf Jung, Hoang-Hai Dang, Jeehoon Kang, Derek DreyerPOPL 2020 · 67 citations
- MirChecker: Detecting Bugs in Rust Programs via Static AnalysisZhuohua Li, Jincheng Wang, Mingshen Sun, John C. S. LuiCCS 2021 · 63 citations
- Rudra: Finding Memory Safety Bugs in Rust at the Ecosystem ScaleYechan Bae, Youngsuk Kim, Ammar Askar, Jungwon Lim et al.SOSP 2021 · 61 citations
Related papers
- FRIES: Fuzzing Rust Library Interactions via Efficient Ecosystem-Guided Target GenerationXizhe Yin, Yang Feng, Qingkai Shi, Zixi Liu et al.ISSTA 2024 · 6 citations
- Rusted Types: Static Detection of Rust Type Confusion BugsZeyang Zhuang, Wei Meng, Michael R. LyuICSE 2026
- RPG: Rust Library Fuzzing with Pool-based Fuzz Target Generation and Generic SupportZhiwu Xu, Bohao Wu, Cheng Wen, Bin Zhang et al.ICSE 2024 · 9 citations
- An Empirical Study of Bugs in the rustc CompilerZixi Liu, Yang Feng, Yunbo Ni, Shaohua Li et al.OOPSLA 2025 · 5 citations
- Place Capability Graphs: A General-Purpose Model of Rust's Ownership and Borrowing GuaranteesZachary Grannan, Aurel Bílý, Jonás Fiala, Jasper Geer et al.OOPSLA 2025 · 1 citation
