Rust’s safety guarantees depend on the standard library getting its internal unsafe code right. Microsoft’s FORGE Lab has identified several flaws that show how subtle failures in that code can still expose safe Rust programs to undefined behavior, including two issues affecting stable Rust.
The oldest finding sat in Rust’s process::exit for nearly 11 years. If a child thread called the function, the runtime could remove the main thread’s alternate signal stack while that thread was still using it. A later stack overflow could then leave the operating system unable to deliver the signal correctly, causing a segmentation fault instead of Rust’s intended stack-overflow handling.
Microsoft said its researchers found no reliable way to exploit that issue under the conditions they examined, and considered practical exploitation unlikely. That qualification matters: a flaw in a foundational API can have broad reach, but its security impact still depends on whether a real application reaches the triggering conditions.
Where safe APIs meet unsafe internals
The investigation used Hyenas, an AI-assisted vulnerability scanner developed by FORGE Lab. Hyenas is the lab’s research version of Microsoft’s agentic vulnerability-discovery system, codename MDASH. Researchers used the tool to locate candidate issues, then inspected the code, reproduced the bugs, assessed their impact, and reported them to Rust maintainers.
Rust’s ownership model and type system prevent many memory errors common in C and C++. The standard library still needs unsafe code for operations the compiler cannot verify. Types such as Vec and String rely on that code internally while presenting safe interfaces to developers. Those interfaces must remain sound regardless of how safe code calls them; otherwise, ordinary use can reach undefined behavior.
Microsoft grouped the findings around three recurring hazards: unsafe code that doesn’t account for panics, code that trusts custom implementations to honor expected behavior, and code that makes faulty assumptions about operating system or C library behavior.
Panics and custom patterns expose assumptions
One flaw involved MapWindows::clone. The implementation allocated a buffer and began filling it by calling a user-defined clone operation before the buffer was fully initialized. If that operation panicked, Rust’s unwinding process could run the buffer’s destructor, which might read uninitialized memory. The reported fix prevents destruction of the buffer until initialization is complete.
A separate issue affected str::replace when used with a custom implementation of the nightly Pattern trait. The code expected an ASCII character, but a custom implementation could provide a non-ASCII byte. That could produce invalid UTF-8; later string operations could then trigger undefined behavior.
These classes of problems aren’t new to Rust researchers. Microsoft said its team was studying panic-safety and related issues with Rudra, a static analyzer, in 2021. The standard library had also addressed panic-safety bugs as early as 2015, yet similar implementation errors continue to surface.
Operating system interactions affect stable Rust
The system-level findings concern how Rust interacts with operating systems and C libraries. Alongside the process::exit bug, Microsoft found a problem in CommandExt::exec, which could modify the process-wide environment-variable array while holding a read lock. Concurrent activity could leave another operation with inconsistent data and, in certain conditions, a pointer to freed memory.
Both system-level findings affect stable Rust. At the time Microsoft published its findings, a proposed fix for the environment-variable issue was under review. It avoids changing the shared array and instead calls execve directly. Microsoft also said two issues reported by its team remained open at publication; related reports from other researchers and proposed fixes were under discussion as well.
From vulnerability discovery to remediation
Microsoft sees the Rust work as part of a broader security workflow. Findings from Hyenas can inform Microsoft Perception, the company’s multi-agent security system, and help improve MDASH, which brings agentic vulnerability discovery into Microsoft Defender.
Microsoft’s Web App Pen Test Agent, for example, can use MDASH findings to guide testing, assess exploitability against live applications, and give teams information for remediation. The practical value of the Rust research will hinge on that follow-through: finding flaws matters, but helping maintainers and developers understand which code paths are reachable is what turns a scanner result into a security improvement.