Most serious security bugs in C and C++ software are memory-safety bugs: use-after-free, buffer overflows and similar. Memory-safe languages such as Rust rule out most of them, but few teams can stop and rewrite a large product. Calif’s Rust in Peace shows a more practical path: replace the riskiest components one at a time.
The example: a real bug in ICU
ICU is the library that handles languages, dates and text sorting in a huge range of software. Older versions of its C++ edition, ICU4C, contain CVE-2021-30535, a use-after-free: when a locale’s keywords change, one internal pointer is moved to new memory but another is left pointing at the freed block, which is then read later.
Instead of patching around it, the authors replaced that part of ICU4C with ICU4X 2.3.1, the Rust implementation of the same features, and kept the rest of the C++ program as it was.
How the swap works
- Crubit (from Google) generates the C++ bindings, so C++ code can call the Rust library much as it called the old one.
- Corrosion builds the Rust code inside the existing CMake build.
- Other options covered: cxx, bindgen and Diplomat, plus a hand-written C bridge, which the authors warn is easy to get wrong.
What it costs
Calling Rust through the generated bindings measured roughly 1.0–2.4% slower than calling Rust directly, around half a nanosecond to a nanosecond per comparison. For most products that is a small price to remove a whole class of bugs from a sensitive component.
The caveats
- Interop tools are young. The authors found bugs in Crubit’s C++ handling of Rust vectors that could themselves cause out-of-bounds writes or use-after-free.
- Generated bindings and bridge code still need a security review. The boundary between C++ and Rust is where new mistakes appear.
What this means for your product
If your product includes C or C++ that handles untrusted input (file parsers, image and font handling, network protocols), list those parts and rank them by risk. Replacing the top two or three with memory-safe libraries usually removes more risk than a full rewrite you never finish. The authors’ demo project is public on GitHub as a starting point.
Not sure if this affects you? Talk to us and we will check which parts of your product to move first and plan the update with you.
Source
This article summarises Rust in Peace, published by Calif on 29 October 2026 (research by Ha Pham and Vinh Tran). Read the original for the full technical details.
