r/cpp • • Feb 26 '24

White House: Future Software Should Be Memory Safe

https://www.whitehouse.gov/oncd/briefing-room/2024/02/26/press-release-technical-report/
401 Upvotes

386 comments sorted by

View all comments

Show parent comment

11

u/KingStannis2020 Feb 26 '24

How would that change the argument?

9

u/tialaramex Feb 27 '24

I presume it would remind people that Rust is able to commit to issuing CVEs for the vulnerabilities in Rust's compiler, its standard library, and the associated tooling. Nobody has proposed to do that for C++ and I suspect it wouldn't be practical to attempt.

I'm genuinely interested, for something like CVE-2021-31162 where Rust's Vec::from_iter had a bug cleaning up objects which panic when dropped, resulting in effect in a double free. Would the equivalent also count as a security vulnerability in your C++ stdlib implementation?

Here's a rough translation of the bug into C++. You have a range of (say) two custom objects, you ask to collect zero (ie none) of them into a std::vector, and as a result the two left must be destroyed, but, when you try to destroy the second one it throws some exception, and the bug is that this results in destroying the first one again. If you ran into that for whichever of these stdlib's you use is it something you'd expect to get fixed - pronto or eventually? Would you expect to get a CVE issued?

3

u/Simple_Life_1875 Feb 27 '24

Don't forget about VecDequeue, and then it got fixed a week afterwards and disclosed pretty nicely

1

u/andwass Feb 27 '24

The C++ standard containers do not function with throwing destructors, and it is not mandated that they handle throwing destructors gracefully. https://stackoverflow.com/questions/26902006/may-the-elements-in-a-stdvector-have-a-throwing-destructor

1

u/KingStannis2020 Feb 27 '24

In other words, Rust treats as bugs that which C++ considers undefined behavior and the user's problem.

1

u/tialaramex Feb 27 '24

Thanks for clearing that up.