August 19th, 2024

Safer C++

Alex Gaynor advocates transitioning from C/C++ to memory-safe languages in security-critical contexts, proposing improvements in C++ safety while acknowledging challenges and recommending a dual strategy for enhancement and migration.

Read original articleLink Icon
Safer C++

Alex Gaynor advocates for transitioning from memory-unsafe languages like C and C++ to memory-safe alternatives in security-critical contexts. He acknowledges the challenges of migrating extensive C++ codebases but emphasizes the importance of improving C++ safety in the interim. Gaynor outlines potential enhancements, focusing on spatial safety, which could be significantly improved by implementing bounds checking on standard template library (STL) containers and adopting features like Apple's proposed -fbounds-safety for raw pointers. He also discusses addressing vulnerabilities related to uninitialized memory and temporal safety, particularly use-after-free issues, through better ownership models and smart pointers. However, he notes that while some improvements are feasible, achieving the same level of safety as languages like Rust or Swift remains elusive. Additionally, he highlights the lack of proposals for addressing data races in C++. Gaynor concludes that while substantial safety improvements are possible, a balance must be struck between the effort required to adopt new proposals and the safety benefits they provide. He suggests that engineering and security teams should consider a dual approach: investing in making C++ safer while also planning for migration to safer languages.

- Advocates for migrating from C/C++ to memory-safe languages in security contexts.

- Proposes improvements in C++ safety, particularly through bounds checking and ownership models.

- Highlights challenges in achieving safety levels comparable to Rust or Swift.

- Notes the absence of proposals addressing data races in C++.

- Recommends a dual strategy of enhancing C++ safety and planning for migration to safer languages.

Link Icon 1 comments