FORGE Lab also identified memory-safety flaws in stable Rust, including an issue that could cause applications to access freed memory.

Microsoft’s elite security research division, the FORGE Lab, has released a comprehensive report detailing the discovery of critical memory-safety vulnerabilities within the Rust programming language’s standard library. Among the findings is a particularly significant bug that has persisted in the codebase for nearly 11 years, highlighting the complex challenges inherent in maintaining memory safety even in languages specifically designed to prevent the vulnerabilities that plague C and C++. While Rust is widely lauded for its strict ownership model and compile-time safety guarantees, these latest findings underscore that the "unsafe" blocks required to interact with low-level system resources remain a primary vector for potential security regressions.
The Anatomy of an 11-Year-Old Vulnerability
The most notable discovery involves the process::exit function, a core component of the Rust standard library. Researchers determined that when this function is invoked from a child thread, it can inadvertently trigger the removal of the main thread’s alternate signal stack while the process is still executing. This creates a dangerous race condition: if the main thread subsequently experiences a stack overflow, the operating system is unable to deliver the signal correctly. Instead of the intended, controlled stack-overflow handling mechanism that Rust developers rely on, the application encounters a segmentation fault.
The longevity of this bug—dating back over a decade—is a testament to the difficulty of auditing system-level code that interacts with complex operating system primitives. Microsoft researchers, however, have tempered the severity of this finding, noting that the conditions required to trigger the exploit are highly specific. In their assessment, there is no reliable, practical path to weaponize this bug in real-world scenarios, though the potential for denial-of-service in specific edge cases remains a point of concern for library maintainers.
Leveraging AI for Vulnerability Discovery
This research was conducted using "Hyenas," an advanced AI-powered vulnerability-scanning system developed by the FORGE Lab. Hyenas serves as the research-focused iteration of Microsoft’s internal codename MDASH, an agentic system designed to automate the discovery of security flaws across large-scale codebases. By utilizing autonomous agents capable of navigating complex software dependency trees, the researchers were able to perform deep-dive analyses into the Rust standard library, a task that has historically required immense manual effort from domain experts.
The methodology involved using Hyenas to map "unsafe" code paths—the segments of the Rust ecosystem where the compiler’s safety checks are bypassed. Once the AI flagged potential vulnerabilities, human researchers at the FORGE Lab conducted rigorous reproduction tests to confirm the flaws and assess their security impact. This human-in-the-loop approach proved vital in filtering out false positives and focusing on legitimate architectural weaknesses that could lead to undefined behavior.
Unsafe Code: The Achilles’ Heel of Memory Safety
While Rust’s design philosophy centers on the elimination of memory-safety errors, the standard library is not immune to these issues because it must occasionally step outside the boundaries of "safe" Rust to interface with the underlying operating system. These "unsafe" blocks are intended to be wrapped in safe APIs, ensuring that the consumer of the code never has to worry about memory corruption. However, the Microsoft team identified three distinct categories where these abstractions fail:
- Panic-Safety Failures: Situations where the unwinding mechanism (triggered by a panic) causes code to interact with uninitialized or partially initialized memory.
- Trust-Based Assumptions: Code that expects user-provided implementations to adhere to specific contracts (such as the
Patterntrait) but does not adequately validate those implementations. - System-Level Interaction Errors: Complex bugs arising from how Rust interacts with shared operating system state, including signal handlers and environment variable arrays.
One specific example of a panic-safety failure identified by the team occurred in the MapWindows::clone implementation. The function attempted to populate a buffer before it was fully initialized. If a panic occurred during this process, the destructor for the buffer would be called, leading to an attempt to access uninitialized memory. The team successfully collaborated with Rust maintainers to implement a fix that ensures the buffer cannot be destroyed until initialization is complete.
Systemic Risks and Stable Rust
The investigation further identified a critical flaw in CommandExt::exec, which manages process-wide environment variables. Researchers discovered that the function could modify a shared state while holding a read lock, creating a window where other threads might access inconsistent or invalid data. In extreme cases, this concurrency issue could leave the environment pointer referencing freed memory, a classic memory-safety error.
Because both the process::exit and the CommandExt::exec vulnerabilities exist in the stable version of Rust, they carry a more immediate impact than experimental features. The existence of these bugs in the stable branch necessitates a shift in how the community approaches the testing of standard library components. Microsoft has recommended that the Rust project adopt more rigorous automated testing for edge-case interactions with OS primitives, a process they are already assisting with through their ongoing reports.
Chronology of Research and Remediation
The findings from the FORGE Lab represent the culmination of years of study into memory safety. The team noted that some of the classes of bugs identified in this latest project were being analyzed as far back as 2021 through "Rudra," a static analysis tool that served as a precursor to the current AI-driven efforts.
- 2015–2021: The Rust project actively works to mitigate panic-safety issues, but complex bugs continue to slip through due to the intricacies of the standard library.
- 2021: Researchers develop the Rudra static analyzer to specifically target unsafe code in Rust crates.
- 2024 (Current Project): The FORGE Lab utilizes the Hyenas agentic system to perform an exhaustive audit of the standard library, uncovering the 11-year-old
process::exitbug. - Late 2024: Microsoft reports the findings to the Rust maintainers, with several fixes entering the peer-review process.
Broader Implications for Software Security
The impact of this research extends beyond the Rust ecosystem. Microsoft plans to integrate the insights gained from this project into its "Microsoft Perception" security architecture. By training agents to recognize the patterns that led to these vulnerabilities, Microsoft aims to enhance its Defender product line, specifically by enabling automated vulnerability discovery for other programming languages and platforms.
The "Web App Pen Test Agent" is one such beneficiary. By using findings from MDASH (the parent system of Hyenas), the agent can prioritize its testing efforts, focusing on code paths that are most likely to contain high-impact vulnerabilities. This creates a feedback loop: as researchers find new ways to break fundamental libraries, the AI tools become more adept at identifying similar patterns in the proprietary and open-source software that powers the global digital infrastructure.
The Path Forward
The researchers are clear that their objective is not merely to amass a count of vulnerabilities, but to strengthen the foundational software upon which the modern economy depends. As of the latest report, several issues identified by the team remain under review by the Rust community. The process of patching these, however, is delicate. Because the standard library is so deeply embedded in the Rust ecosystem, changes must be carefully vetted to avoid breaking backward compatibility or introducing performance regressions.
The Rust project has not yet issued a comprehensive formal response to the full scope of the Microsoft report. However, the open-source community is historically proactive regarding security disclosures. The collaborative nature of the ecosystem suggests that the identified bugs will likely be resolved in upcoming point releases of the compiler and standard library.
For developers, the primary takeaway is a reinforced focus on the "unsafe" boundary. While the language provides world-class protections, the standard library is a human-written component subject to the same pressures of complexity as any other. Developers should continue to rely on Rust’s safety guarantees for the vast majority of their code, but they should remain vigilant regarding the potential, however rare, for low-level system interactions to introduce unexpected behaviors.
Ultimately, the Microsoft FORGE Lab’s findings serve as a healthy reminder of the "defense in depth" principle. Even with the strongest programming languages, security is an ongoing process of discovery, analysis, and remediation. As AI agents like Hyenas become more sophisticated, the speed at which these hidden flaws are uncovered will likely increase, necessitating a more rapid and robust response mechanism from the maintainers of foundational software components. The work performed by the researchers at Microsoft is a significant contribution to this effort, ensuring that the next decade of Rust development remains as secure and reliable as the community expects.







