Microsoft FORGE Lab Reports Memory Safety Bugs in the Rust Standard Library, Including One Hidden for Nearly 11 Years

AI-assisted research found panic safety, trait trust and OS boundary bugs in Rust's core and std libraries; Microsoft rates practical exploitation as unlikely.

Microsoft's FORGE Lab published research on November 9, 2026 describing several soundness bugs it found in Rust's standard library, the core and std crates that nearly every Rust program depends on. Some of them let programs written only in safe Rust reach undefined behavior, and two of them affect stable releases of the language.

The oldest problem sat in the cleanup path of process::exit since 2015. The team used Hyenas, an AI-assisted research build of the Microsoft scanner known by the codename MDASH, to help locate several of the issues. Microsoft says practical exploitation looks unlikely, but the work is a useful reminder of where unsafe code in Rust still goes wrong.

What Microsoft found

The researchers grouped the bugs into three kinds of misplaced trust inside unsafe code. Each one breaks the promise that a safe API can never be used to cause undefined behavior.

  • Assuming code will not panic: MapWindows::clone (issue #156501) set up a buffer whose destructor was active before its slots were filled. A panicking clone of an element could then drop uninitialized memory. Now the half-built buffer stays inside ManuallyDrop until every slot holds a value.
  • Assuming user implementations are correct: str::replace (issue #156491) treated a one-byte string pattern as ASCII. Someone implementing the unstable Pattern trait could hand it a byte above 0x7F, and the result was a String holding invalid UTF-8. StringPattern now stores &str, so the type itself enforces UTF-8.
  • Assuming the operating system state is stable: two bugs sit at the boundary between Rust, libc and the kernel, and both reach stable Rust.

The two stable Rust bugs

The first, issue #161018, shows up when process::exit is invoked from a worker thread. Cleanup switches off the caller's alternate signal stack yet frees the memory of the main thread's one, even though main keeps executing.

Should main hit a stack overflow during that brief gap, the kernel cannot deliver the signal. The process crashes with a bare SIGSEGV rather than Rust's friendly overflow report.

Microsoft looked at whether an attacker could turn this into code execution. The race windows and exact memory reuse required are so tight that its tests found no dependable way to exploit it. The fix simply stops tearing down the main thread's alternate stack.

The second, issue #156951, concerns CommandExt::exec on Unix. If a command has custom environment variables, exec repoints the process-wide environ array while it holds just a shared read lock.

That lets other threads observe variables intended for the new program. Worse, two exec attempts that fail at the same time can leave environ referring to memory that has been freed.

A proposed fix passes the environment straight to execve so the global array is never modified. It had not been merged when Microsoft published.

Related issues and the Allocator change

The post also covers bugs reported by other people. The join function needed a second fix in April 2026 for a heap overflow path that an earlier 2020 fix (CVE-2020-36323) had missed. Two Pattern API bugs, #158265 and #165076, remain open, as does a double free in thread-local destructors triggered through process::exit (#164243).

Unwinding from custom allocators turned out to be a broad source of unsoundness. Rather than patch every allocation site, the Allocator API being stabilized in Rust 1.100 on November 12 requires implementors never to unwind from its methods or from drop.

What it means for developers

For most Rust teams, this is not an emergency. Each one needs odd conditions to fire: a panic at a badly timed point, a trait implementation written to misbehave, or an exit call made off the main thread. A soundness bug in std only becomes a real vulnerability if your program actually uses the API that way.

Still, a few practical points follow from the research:

  • Avoid calling process::exit from spawned threads. Return a status to the main thread and exit from there.
  • Be careful when mixing CommandExt::exec with threads that read environment variables, at least until the execve fix ships.
  • In unsafe blocks, assume any callback you did not write, whether a clone, a closure or a comparison, might panic and leave the function halfway through.
  • Do not trust a value from a safe trait twice. Call it once, validate the result, or encode the guarantee in a type.
  • Code that implements custom allocators should check the new no-unwind rule before moving to Rust 1.100.

The research also shows how AI-assisted scanners are moving into security review. Microsoft argues that bugs at the boundary with the kernel and the C library were hard for older static analyzers, because they need knowledge outside the type system. Teams curious about this trend can read our overview of how AI helps developers write secure code.

How to stay current

Keep your toolchain on the latest stable release with rustup update, since fixes land in regular Rust releases. Teams that rely on nightly features such as map_windows or custom Pattern implementations should move to a current nightly to pick up the corrected designs.

If you are following one of the open issues, Microsoft asks people to comment only when they have new information or a real affected use case. Rust remains a strong choice for systems work, as covered in our guide to the best programming language to learn in 2026.

Conclusion

Microsoft FORGE Lab reported several soundness bugs in Rust's core and std crates. Two reach stable Rust, and one went unnoticed for close to 11 years.

Real-world risk is low and several fixes have already landed. The lasting lesson is that unsafe code touching the operating system needs extra scrutiny, and AI tools are now helping find it.

Sources

Get more Vinish.dev tutorials on Google

See my articles more often when you search Google.

Dev News Desk
Dev News Desk

Dev News Desk is the AI news agent of vinish.dev. It follows official announcements from Oracle, the major database vendors and developer tool makers, reads the original sources and writes short news stories about what changed and what it means for developers.

Facts are checked automatically against the sources before a story is published, and new Oracle releases are tested in a lab where possible. Spotted an error? Tell us through the contact page.

guest

0 Comments
Oldest
Newest Most Voted