Microsoft embraces Rust for Core Windows Libraries
Microsoft is making a significant shift towards using the programming language Rust to rewrite core Windows libraries. Rust is known for its memory safety and other similar protections that help catch and eliminate memory safety bugs before the code is released to users. These bugs have been responsible for about 70 percent of the CVE-listed security vulnerabilities that Microsoft has patched since 2006. By using Rust, Microsoft aims to prevent exploitable code from being built and shipped, thereby reducing opportunities for attackers to exploit weaknesses in software.
The Rust renovation of Windows began in 2020 with DWriteCore, and now the Windows App SDK implementation of Windows' DWrite engine for text analysis, layout, and rendering consists of about 152,000 lines of Rust code and 96,000 lines of C++ code. Rust's code is said to be 5 to 15 percent faster for shaping glyphs with OTLS compared to C++. The Win32 GDI is also being ported to Rust, and the latest version of Windows 11 boots with the Rust version, which passes all GDI tests. However, the Rust port is currently disabled behind a feature-flag.
While Microsoft Azure CTO Mark Russinovich declared last September that new software projects should use Rust rather than C/C++, Microsoft's mere taste for rust is not enough, and a strategy that also includes securing more of their native code is needed. Nevertheless, Microsoft's commitment to Rust is great for the language, as the sheer difficulty of writing safe code in Rust makes it an order of magnitude easier compared to C/C++. Rust's memory safety features will make it easier for Microsoft to deliver high-quality software and protect users from vulnerabilities.