Microsoft researchers found memory safety bugs in Rust's standard library that safe code can trigger

Memory Safety Bugs in Rust Standard Library

Microsoft researchers found memory safety bugs in Rust's standard library that safe code can trigger

Microsoft's FORGE Lab used an AI-powered scanner called Hyenas to uncover soundness bugs in Rust's core and std libraries, where safe Rust can cause undefined behavior. The bugs follow three patterns of misplaced trust: assuming code won't panic, assuming user-provided implementations are correct, and assuming the underlying system behaves. The team reported fixes, including one shipping in Rust 1.100 that forbids allocators from unwinding.

The hard part of unsafe Rust is knowing what you can trust.
  1. simonask

    Just because emotions seem to be always boiling whenever Rust is mentioned, I want to clarify for people who only follow casually that there is nothing unusual or scandalous about these finds.

    The Rust project as a whole currently has 178 open issues with the tag I-unsound[1]. Many of these describe issues that only exist in the nightly compiler, of course, but it does happen that bugs are not caught before shipping. That's software.

    [1]: https://github.com/rust-lang/rust/issues?q=is%3Aissue+state%...

  2. hingler36

    I've always felt that parts of the Rust standard library to be weirdly un-rusty. Like indexing a vector panicking instead of returning a Some(T) in case the index is out of bounds. It's easy to avoid if you put the effort in of course, but it did always feel weird that one of the first data structures you learn has this behavior right out of the gate.

  3. Panzerschrek

    > But many operations in Rust can panic, from out-of-bounds indexing to calls into user-provided code, and by default a panic unwinds

    That's why I think having unwinding in Rust is a mistake. It gives a false sense of safety, but it's very hard to write unwinding-correct code. So, it would be better to handle panics as immediate process termination instead.

  4. nektro

    > Pattern 2: Trusting user-provided implementations to be correct

    reminds me of the tales from https://oxide.computer/blog/iddqd-unsafe

  5. nektro

    > Notes from Microsoft Security's Frontier Offensive Research & Generative Exploitation Lab.

  6. eptcyka

    An effect system could gelp us reason about code by making calls to panic-capable functions marked as such. Maybe we could mark some types as panic unsafe?

  7. ozgrakkurt

    Do not ever use with anything other than panic = abort.

    It is just the sketchiest feature in a very realiable language.

    It doesn't make sense to me why anyone whould use rust with panic handling.

    And the of course the language trusts the operating system, how else can you program?

    This kind of thing is basically why all projects blocked AI issues, it is just slop that kind of makes sense if you don't know what you are doing.

  8. gspr

    Very interesting finds for sure. But taking the "trusting user-provided code" as an example: isn't this just a case of malicious code being malicious? I understand the point that the malicious act comes through memory unsafety, and it's a big gotcha that safe Rust (i.e. Rust without `unsafe`) can trigger memory unsafe behavior. But the code doing it is still acting maliciously (by having an `AsRef` implementation that returns different slices at different times). And the code being abused (the one that does the unsafe indexing) does have `unsafe` – so this is a case of the user writing unsafe Rust that interacts with malicious safe Rust.

    I don't know if it's ever been in Rust's threat model to handle malicious code.

More from this day

2026-11-15