skip to content
Decrypt LOL

Get Cyber-Smart in Just 5 Minutes a Week

Decrypt delivers quick and insightful updates on cybersecurity. No spam, no data sharing—just the info you need to stay secure.

Read the latest edition
Google Enhances Memory Safety with New Coding Practices

Google Enhances Memory Safety with New Coding Practices

/ 4 min read

Quick take - Google is implementing a comprehensive strategy to enhance memory safety by addressing spatial memory safety vulnerabilities through the adoption of Safe Coding practices, the introduction of hardened libc++, and collaboration with the C++ community, with the goal of improving security and reducing memory-related bugs in its applications.

Fast Facts

  • Google is addressing spatial memory safety vulnerabilities, which account for about 40% of memory safety exploits over the past decade, through a comprehensive strategy.
  • The strategy includes adopting Safe Coding practices, using memory-safe programming languages, and retrofitting secure-by-design principles into existing C++ codebases, such as Chrome.
  • A key initiative is the introduction of hardened libc++, which adds bounds checking to standard C++ data structures, significantly reducing spatial safety bugs.
  • Since its deployment in 2022, hardened libc++ has led to a 30% reduction in segmentation faults and uncovered over 1,000 bugs, with minimal performance impact of just 0.30%.
  • Google is expanding bounds checking initiatives to other libraries and aims to improve interoperability between C++ and memory-safe languages, while encouraging the wider C++ community to adopt these safety measures.

Google Takes Steps to Address Spatial Memory Safety Vulnerabilities

Google is taking significant steps to address spatial memory safety vulnerabilities. These vulnerabilities occur when code accesses memory outside its intended bounds, posing security risks to users. According to Google’s Project Zero, these vulnerabilities account for approximately 40% of memory safety exploits encountered in the wild over the past decade.

Comprehensive Strategy for Memory Safety

In response, Google has implemented a comprehensive strategy aimed at enhancing memory safety. This strategy involves the adoption of Safe Coding practices and the utilization of memory-safe programming languages in new code development. The transition to memory-safe practices is expected to be a multi-year process, requiring adaptations to both development practices and underlying infrastructure.

One of the key initiatives in this strategy is the retrofitting of secure-by-design principles into existing C++ codebases, including widely-used applications like Chrome and various other services. Central to this effort is the introduction of hardened libc++, which adds bounds checking to standard C++ data structures, addressing a significant class of spatial safety bugs. Specifically, hardened libc++ ensures that accesses to std::vector elements remain within allocated bounds and verifies the emptiness of std::optional before access.

Benefits and Performance Impact

Many modern programming languages incorporate bounds checking by default, including Java, Python, Go, and Rust. C++ is now adopting this practice through hardened libc++, which was first deployed in Chrome in 2022 and has since become the default for Google’s server-side production systems. The implementation of this new library has resulted in a minimal average performance impact of just 0.30% across various services, thanks to performance optimizations such as enhanced compiler capabilities and profile-guided optimizations.

Google is actively monitoring the performance implications of hardened libc++, making adjustments to reduce unnecessary overhead throughout the rollout process, which involved multiple stages, including testing and gradual production rollout. Since the adoption of hardened libc++, Google has reported numerous benefits, including the prevention of exploits, the uncovering of over 1,000 bugs, and a 30% reduction in the segmentation fault rate. The safety checks introduced by hardened libc++ have also transformed previously challenging memory issues into easily debuggable errors.

Future Initiatives and Community Collaboration

Furthermore, Google is expanding its bounds checking initiatives to other libraries and migrating code to Safe Buffers to further enhance spatial safety. A long-term goal of these efforts is to improve interoperability between C++ and memory-safe languages, potentially paving the way for automated translation in the future.

In a broader context, Google is encouraging organizations that utilize C++ to enable hardened modes in their standard libraries to bolster safety and reliability. The company is also committed to collaborating with the wider C++ community to foster a safer C++ ecosystem. Acknowledgments have been extended to individuals and the libc++ community for their contributions to the development of hardened libc++.

Original Source: Read the Full Article Here

Check out what's latest