A stylized coding lab illustrates Rust’s safe and unsafe slice functions amid glowing circuitry and security symbols.
Microsoft's FORGE Lab has published research on soundness bugs in Rust's core and std libraries. Some of them can be triggered from safe code, and Rust 1.100, which stabilizes the Allocator API that plays into one of the findings, is due on November 12, 2026. The post is worth reading for developers, security teams and anyone who ships Rust on Windows or elsewhere. It's less a "Rust is broken" story than a study of where the language's safety promise strains.

A stylized coding lab illustrates Rust’s safe and unsafe slice functions amid glowing circuitry and security symbols. What Microsoft reported​

FORGE Lab says it found several memory-safety issues in Rust's standard libraries, including cases where code written entirely in safe Rust can trigger undefined behavior. The work used Hyenas, which FORGE describes as its frontier research version of the codename MDASH vulnerability-scanning system.

Microsoft credits humans with the hard parts. Its researchers investigated the code, reproduced the bugs, assessed security impact and worked with Rust maintainers on reports and fixes. The AI tooling helped find candidates. It did not replace that work.

The post covers only soundness bugs in the standard library's unsafe code. It leaves out compiler miscompilations and type-system holes.

Soundness means that safe code must never be able to cause undefined behavior through a safe API. Much of the standard library, including Vec and String, is built from small unsafe pieces wrapped in safe APIs. If one of those pieces breaks its contract, safe code can hit behavior Rust is meant to prevent.

Pattern 1: trusting code not to panic​

Unsafe code often breaks an invariant briefly and restores it afterward. A panic in the middle unwinds the stack and runs destructors, and those destructors can see the broken state.

MapWindows::clone (issue #156501). This is a nightly iterator adapter, Iterator::map_windows.

  • Its internal buffer was built first and filled afterward, but its destructor was already armed.
  • The fill step called the user's T::clone. If that panicked, unwinding ran the destructor over uninitialized slots.
  • Microsoft's proof of concept is safe code with an element type whose clone always panics.
  • The fix keeps the buffer in ManuallyDrop until it is fully written. A panic then leaks the half-built buffer instead of dropping it.

The general rule is to treat every call into code you don't control as a possible early exit. That includes clone, drop, comparisons, closures and iterator methods. Either finish the risky work before breaking the invariant, or use ManuallyDrop or a guard that restores the invariant on drop.

Allocators must not unwind. Microsoft reported a BTreeMap::insert case that is unsound when a custom allocator unwinds, and others reported more (#159334, #159368, #159370). Rather than audit every allocating path, the stabilization requires implementors never to unwind from the trait's methods or from drop. Independent project notes on the stabilization agree on that rule: implementors must not unwind.

On timing, the draft release notes list Rust 1.100.0 for 2026-11-12 and include stabilizing custom allocators. As of today, November 9, that is scheduled and not yet shipped.

Pattern 2: trusting caller-supplied implementations​

A safe trait implementation can be wrong or inconsistent. Unsafe library code can't rely on it being correct unless the trait is explicitly unsafe.

Microsoft contrasts this with C++, where a comparator that breaks std::sort's ordering rules is undefined behavior and the caller is at fault. In Rust, the same comparator passed to sort_by is only a logic error. The sort may panic or leave the slice in unspecified order, but it must stay memory-safe.

str::replace with a custom Pattern (#156491). This involves the nightly Pattern trait.

  • str::replace has a fast path for swapping one ASCII byte for another.
  • The check assumed that any one-byte string pattern was ASCII. That held for &str, but StringPattern stored &[u8], and as_utf8_pattern is a safe method any pattern can implement.
  • A custom pattern reporting the byte 0x80 is enough. That byte appears only as a continuation byte inside multibyte UTF-8 sequences.
  • replace then rewrites it and returns a String that isn't valid UTF-8. Later UTF-8-dependent operations reach undefined behavior.
  • The fix changed StringPattern to hold &str, so the type itself guarantees valid UTF-8.

Microsoft's advice for unsafe code that depends on a user-supplied property:

  1. Call the implementation once and keep the result.
  2. Validate what it returns.
  3. Encode the property in a type that safe code can't forge.
  4. If none of those work, make the trait unsafe.

join, again. Microsoft reported in 2020 that join trusted Borrow::borrow to return the same string on every call (CVE-2020-36323). The fix handled strings that shrink between calls. In April 2026 the function needed another fix. join borrows the first element twice, and if it grows on the second call, the remaining-length calculation underflows into a heap overflow. The earlier fix never covered that path.

Other people reported similar problems in the Pattern API this year (#158265 and #165076, following a discussion in #164904). Microsoft says both were still open at publication.

Pattern 3: trusting the underlying system​

The third pattern sits at the boundary with the operating system and the C library. Unsafe code there trusts process-wide state, such as signal stacks, memory mappings and the environment, that other threads, C libraries or the kernel can change at any time. Microsoft argues static analysis has struggled here because it would have to model all of that surrounding behavior. It says AI agents make this area practical to search. That is Microsoft's own assessment of its approach, not an independent measurement.

process::exit and the main thread's signal stack (#161018).

  • Rust gives each thread an alternate signal stack so its stack-overflow handler can run after the normal stack is exhausted.
  • When a child thread calls process::exit, runtime cleanup disables the calling thread's alternate stack but unmaps the main thread's.
  • The main thread keeps running until libc's exit finishes. If it overflows its stack in that window, the kernel can't deliver the signal. The process dies with a plain segmentation fault instead of Rust's diagnostic.
  • Microsoft says the bug dates to 2015. The fix stops cleaning up the main thread's alternate stack. Microsoft says the issue affects stable Rust.
  • On exploitability, Microsoft assessed practical exploitation as unlikely. It would need a narrow timing window, a new writable mapping at exactly the same address and size, and a second race to overwrite the handler's frame. Microsoft says this assessment applies to this issue only.

CommandExt::exec and the global environment (#156951).

  • On Unix, when a command has its own environment variables, exec temporarily points the process-global environ at a new array and restores it if execvp fails.
  • Command::exec takes only the read side of the environment lock, but do_exec writes environ.
  • Other threads can then see variables meant only for the new program. Two failed exec calls racing each other can leave environ pointing at freed memory that a later env::vars_os() reads.
  • Both proofs of concept use only safe Rust.
  • Microsoft traces the mismatch to 2021, when the environment lock became a read-write lock. A 2018 fix had held an exclusive lock.
  • A fix that calls execve directly was under review at publication. Microsoft says this one also affects stable Rust.

Related, not a FORGE discovery. Microsoft also mentions #164243, reported by someone else. A thread-local destructor that calls process::exit while a thread local is being replaced can make libc drop that value twice, causing a double free. A proposed fix switches to POSIX _exit.

How worried should you be?​

Microsoft is explicit that a soundness bug isn't automatically a vulnerability in programs that use the library. Each case needs an unusual setup:

  • a panic at exactly the wrong moment,
  • a deliberately misbehaving trait implementation,
  • or process::exit called from a child thread.

It becomes serious only if a real program reaches the API that way.

Several of the examples are nightly-only (map_windows, Pattern), and Microsoft says many reports were caught before stabilization. Some were fixed by changing the design, such as StringPattern holding &str and the no-unwind rule for allocators. The signal-stack and exec bugs are the ones touching stable Rust. They are also the ones that went unnoticed longest, which supports Microsoft's argument that system-boundary bugs are the hard category.

Treat the research as vendor-authored. Microsoft has a business interest in showing that AI-assisted vulnerability discovery works, and the post ties the work to MDASH in Microsoft Defender and to its Microsoft Perception multi-agent security system. The post gives no hit rate, false-positive rate or comparison with traditional tools. The concrete Rust findings stand on their own, but the AI claims are assertions.

The "billions of people" figure for Rust exposure is Microsoft's estimate, and the post gives no methodology for it. Don't cite it as established fact.

Practical takeaways​

For Rust developers

  • Audit unsafe blocks for any call that could panic or run caller-supplied code while an invariant is broken.
  • Don't call a user-provided trait method twice and assume the same answer. Cache it or validate it.
  • Be careful with process::exit in multithreaded programs on Unix. Microsoft's report notes a related double-free issue.
  • Watch the Rust issue tracker for the open items. Microsoft asks commenters to add only genuinely new information or real-world affected use cases.

For security and IT teams

  • Track Rust toolchain updates for the fixes as they ship.
  • Don't treat these as drop-in emergency patches. Microsoft's own impact analysis calls for case-by-case judgment.
  • Don't read memory-safe language adoption as meaning "no memory bugs." It means the bugs are concentrated in unsafe code that can be fixed once, in the library, instead of in every program.

The bottom line​

Rust's promise is strict. Safe code must never cause undefined behavior, even with hostile or buggy callers. That is a higher bar than C or C++ sets, so these reports count as bugs in Rust when comparable behavior in C++ would count as the caller's fault. The research shows that bar is still hard to meet in the standard library's unsafe core, and that hunting for bugs at the OS boundary may be where AI-assisted tools prove most useful. At publication, two of Microsoft's own reports were still open.

 

References

  1. FORGE Lab uses agentic tools to identify memory safety issues in Rust - Microsoft Microsoft 2026-11-09T20:17:31+00:00
  2. Allocators are stable on nightly Rust · Issue #662 · smallvec/smallvec · GitHub github.com
  3. Rust 1.100.0 custom allocator optimizations? · Issue #139 · KonradHoeffner/hdt · GitHub github.com