Google has analyzed the effectiveness of using the type MiraclePtr (raw_ptr<T>) in C++ code instead of regular pointers to guard against vulnerabilities caused by accessing already freed memory areas (use-after-free). MiraclePtr provides a wrapper over pointers that performs additional checks and aborts the operation if accessing freed memory areas is detected. Support for MiraclePtr was enabled by default on Windows and Android platforms in May 2022 (in Chrome 102), and on ChromeOS, Linux, and macOS platforms in June 2023. MiraclePtr-based protection in Chrome applies to all processes except the renderer process.
After studying the dynamics of vulnerability reports and crashes, as well as analyzing security-related incidents and fuzz testing results, it was concluded that the implementation of MiraclePtr provided protection against 57% of use-after-free class vulnerabilities, thanks to the transition to MiraclePtr for class fields and callback parameters. Additionally, it is mentioned that 5 out of 6 critical vulnerabilities identified last year in the stable branch of Chrome were discovered through the analysis of crash reports related to the use of MiraclePtr.
The cost of using MiraclePtr is an increase in memory consumption, as additional 4 bytes are required for pointer storage with a reference counter. The memory consumption of the main browser process when using MiraclePtr increases by 5.5-8% in desktop builds and by 2% in the Android version. The average increase in consumption for all processes is estimated at 1-3%. Furthermore, using MiraclePtr has led to certain regressions that reduce performance, though not related to key metrics such as page load and rendering times. Among the identified regressions, a 1.5% delay in first input on Chrome OS and a 1.5% slowdown in tab opening on the Android platform have been noted, as well as an increased likelihood of input delay due to contention in the main thread (10% increase in the 99th percentile).
Source: opennet.ru
