Herb Sutter has an interesting article on his blog about approaches to improve security in C++ and modifying the language to assist with stopping programming errors that lead to exploits.
https://herbsutter.com/2024/03/11/safety-in-context/ [herbsutter.com]
There are two interesting insights. Firstly. most CVEs come from issues that could be dealt with with small changes to C++ that are being proposed.
The second is that even coding in languages with automatic memory allocation can still have massive vulnerabilties. Even code written in Rust has vulnerabilities so the language alone is not the whole problem.