Breaking
SecurityDeveloping Story

A Rust Flaw That Hid for 11 Years

Microsoft's AI-assisted bug hunter surfaced a memory-safety bug in Rust's standard library that went undetected for nearly 11 years.

··2 weeks ago·6 min read
a computer screen with a bunch of code on it
Photo by Chris Ried on Unsplash

A memory-safety bug sat inside Rust's standard library for nearly 11 years before anyone caught it. The flaw, in the language's process::exit function, was surfaced by Microsoft's FORGE Lab using an AI-powered vulnerability scanner — a detail that matters as much as the bug itself, because the code it found had been shipped to every Rust user for more than a decade.

Microsoft reported the finding alongside other issues that, according to the researchers, can trigger undefined behavior even in applications written entirely in safe Rust. Two of the findings affect stable Rust.

Inside the process::exit flaw

The nearly 11-year-old bug lives in how process::exit interacts with a program's running threads. Microsoft's researchers found that calling the function from a child thread could cause the runtime to remove the main thread's alternate signal stack while that thread was still running.

If the main thread then hit a stack overflow, the operating system might be unable to deliver the signal correctly. The result would be a segmentation fault rather than the stack-overflow handling Rust intends to provide.

“The process::exit signal stack bug was in the standard library for nearly 11 years,”

— Microsoft's FORGE Lab researchers, in a blog post describing the findings

Microsoft said the researchers found no reliable exploitation path under the conditions they examined and assessed practical exploitation as unlikely.

What Hyenas actually did

The research relied on Hyenas, FORGE Lab's AI-powered vulnerability-scanning system, to investigate unsafe code inside Rust's standard library. Hyenas is the lab's research version of codename MDASH, Microsoft's agentic vulnerability-discovery system.

Microsoft said some of the bugs were found with help from Hyenas. From there, researchers examined the underlying code themselves, reproduced the issues, assessed their security impact, and reported them to Rust maintainers. The scanner did not act alone — it pointed at candidate code, and humans did the verification.

The link between the research tool and Microsoft's commercial security lineup is direct. Microsoft said the findings can feed into Microsoft Perception, its multi-agent security system, where specialized agents work across broader security workflows. That, in turn, helps the company improve MDASH, which brings agentic vulnerability discovery into Microsoft Defender.

In one described example, Microsoft's Web App Pen Test Agent can use MDASH findings to prioritize testing, assess exploitability against live applications, and provide information to support remediation.

The unsafe code underneath

Rust's ownership model and type system are built to prevent the memory-safety problems commonly associated with languages such as C and C++. But the standard library relies on unsafe code internally for operations the compiler cannot verify.

Components such as Vec and String use those operations and expose them through safe APIs. Microsoft said those APIs must meet a strict soundness requirement: “no matter how safe code uses it, it must be impossible to trigger undefined behavior.”

Microsoft sorted its findings into three categories: unsafe code that assumes operations will not panic, code that trusts user-provided implementations to behave correctly, and code that makes incorrect assumptions about the underlying system.

Panics, buffers, and MapWindows

The first category produced a panic-safety problem in Rust's MapWindows::clone implementation. The function created a buffer before fully initializing its contents, then called a user-provided clone operation to populate it.

If that operation triggered a panic, Rust's unwinding mechanism could invoke the buffer's destructor — which would then try to access memory that had never been initialized. Microsoft said the reported fix prevents the partially initialized buffer from being destroyed before initialization is complete.

This defect was not novel in kind. Microsoft said the standard library had addressed panic-safety problems as far back as 2015, yet similar weaknesses continue to appear in its implementations.

A pattern trait that breaks UTF-8

The second category involves code that trusts user-supplied implementations. Researchers found that str::replace could make an incorrect assumption about a custom implementation of the nightly Pattern trait.

A custom implementation could supply a non-ASCII byte where the code expected an ASCII character. The replacement operation would then produce invalid UTF-8 data, and subsequent string operations could trigger undefined behavior, according to Microsoft.

Microsoft noted that the first two categories of weakness had already been under study in 2021 through Rudra, a static analyzer developed by members of the research team — a sign these classes of bug were known territory even before the AI-assisted scan.

The CommandExt::exec problem

The third category concerns how Rust interacts with underlying operating systems and C libraries. Beyond the process::exit issue, researchers identified a problem in Rust's CommandExt::exec functionality involving the process-wide environment variable array.

Microsoft found the function could modify this shared state while holding a read lock, potentially allowing other threads to access inconsistent data. Under certain conditions, concurrent operations could leave the environment pointer referencing freed memory.

Both the process::exit and CommandExt::exec findings affect stable Rust. A proposed fix for the environment-variable issue — which avoids modifying the shared array by calling execve directly — was under review when the blog was published. Two issues reported by Microsoft's team remained open at publication. The blog also discussed related reports from other researchers and fixes still under review.

Why the practical risk stays low

Microsoft said the practical risk from these findings is limited. Each flaw requires unusual conditions to trigger.

A bug in a standard library becomes “a serious vulnerability only if a real program reaches the API in that way,” the researchers wrote. The distinction matters: a defect in library code is not the same as a defect an attacker can reach in a running application.

  • Nearly 11 years — how long the process::exit signal stack bug sat in the standard library
  • Two — the number of Microsoft-reported issues still open at publication
  • Three — the categories Microsoft used to group its findings
  • 2021 and 2015 — when Rudra began studying the first two weakness categories, and when the standard library had last addressed panic-safety problems

The Rust project had not responded to a request for comment from CSO at the time of writing.

What the scanner is meant to add

Microsoft framed the research around more than bug counts. “Our goal isn't to simply find more bugs,” the researchers wrote, describing instead an effort to identify meaningful issues and improve the safety of foundational software that developers and organizations depend on.

The company positioned the work as improving how MDASH is developed, with findings routed through Perception and into Defender. The Web App Pen Test Agent example shows the intended loop: scanner output feeds prioritization and exploitability assessment for live applications.

What this means for Rust users

The immediate takeaway for teams shipping Rust is narrow. The bugs described require unusual conditions to trigger, and Microsoft itself assessed practical exploitation as unlikely. The fix for the MapWindows issue was reported, and the environment-variable fix was under review at publication — two issues remained open.

What the research does suggest is that the boundary between safe and unsafe code in Rust is only as strong as the assumptions inside the standard library itself. Applications that never write a line of unsafe code still inherit whatever the library does beneath them, and a flaw there can surface in code that was, on its face, entirely safe.

That also explains why the disclosure path mattered here: the flaws were reported to Rust maintainers, fixes were proposed, and the process ran in the open. For organizations relying on Rust, the practical step is to follow those fixes as they land.

#rust#microsoft#memory-safety#vulnerability-research#ai-security#open-source

Sources

Iliyas

Founder & Editor, Xploitwire

This article was written and reviewed against the sources listed above before publication, under editorial policies set by Iliyas. Read our Editorial Policy →

← Back to all stories