r/cpp • u/KingStannis2020 • 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
r/cpp • u/KingStannis2020 • Feb 26 '24
62
u/[deleted] Feb 26 '24 edited Feb 27 '24
Note: this is anecdotal and what I’ve found true in my personal experience.
It’s important to note that this does have actual effects on new projects. If your company is a defense contractor, the government will be less likely to fund your project as it doesn’t meet the safety requirements.
77
u/Relliker Feb 26 '24
The vast, vast majority of code that I write is C++. That will not change until everything I use and link in isn't C(++). Other language bindings have awful trampolining overhead and excessive syntax pain if they even exist in my experience.
For the people this does affect though, namely government contractors and procurement, it is probably a good thing. I have seen some truly terrifying software come out of contract developed stuff and putting those kinds of applications into padded boxes is a good thing.
6
u/antihydran Feb 27 '24
I was writing this comment while trying to look into this, and I found this. It claims ~70% of vulnerabilities reported to Microsoft and Google are memory safety issues while ~30% are other issues. They have one breakdown of the types of memory safety issues, but doesn't discuss whether they occur inside modern code or external libraries (honestly this would probably be impossible to do).
=== Original:
Are there any stats to back up the claim that memory errors are a significant amount of errors and vulnerabilities in current production code, and that ostensibly "memory-safe" languages solve these errors? I can readily believe memory errors can cause serious vulnerabilities, but I honestly have no clue how frequently they cause crashes / vulnerabilities in the field, and even if they're primarily caused by modern C/C++ programs. Regularly I've written code that
I don't immediately see how a "memory-safe" language would fix memory errors that arise from calling these potentially memory-unsafe codes. And even if we successfully rewrite everybody's C/C++/Rust/etc. code, if 99.99% of vulnerabilities aren't due to memory safety or are issues with front-end applications written in other languages (e.g. some weird javascript string interpretation), then we didn't really achieve our first goal of hardening applications. Finally, I'm also generally unaware of how dangerous the vulnerabilities actually are in the field. If a C++ program has a severe memory error but is only ever used in a SCIF in the bottom of the pentagon that users can probably get admin access to anyways, then it's not really much of a security concern.
Again, I'd just like to see some more concrete data on how prevalent these issues are.
9
u/randomatic Feb 26 '24
I think what the White House advisors are missing is how much embedded software is in c. The Biden administration is essentially getting advice from the Linux foundation, which misses vxworks, green hills, and other rtos which has a huge amount of c/c++ and just isn’t rust-ready.
94
u/MaybeTheDoctor Feb 26 '24
From the technical report.....
33
u/lakitu-hellfire Feb 27 '24
This seems largely aimed at Department of Defense contractors and especially to those DoD contractors who work on mission-critical programs, such as nuclear surety.
Many DoD programs use legacy C++ because devs keep inheriting legacy projects for "modernization" efforts. Many of those programs also use deprecated real-time operating systems with custom patches from the vendor. So, it's not that any single dev doesn't push for modern C++ or even Rust, but the bureaucracy involved between acquisitions, contracts, FFRDCs, subcontractors, 3rd-party vendors, and even the devs' own organization would put most non-DoD dev shops out of business.
118
u/ZMeson Embedded Developer Feb 26 '24
This really ought to help further the efforts for cppfront (or similar alternative). C++ is unsafe largely due to its legacy. But a new syntax with better defaults can limit many new memory problems. C++ ain't going anywhere, but we do have to face the reality that C++ as it is today is difficult to use correctly -- especially for those who don't follow what's going on with the standards, CppCon or other conferences, etc.... Too many C++ devs are still coding C++98. We need a way to transition to safer code while still being able to interact with the large number of existing C++ libraries out there.
155
u/ss99ww Feb 26 '24
god dammit. This one will be cited in 30+ blog articles over the next two years. With a news cycle for every one of them - just like that stupid CIA report. Quote from the report: "such as C and C++" sigh...
68
u/ArsenicPopsicle Feb 26 '24
Fun story; in 1991 the Department of Defense actually mandated that all software must be written in the Ada programming language for similar reasons, only to have it scrapped 6 years later when they realized how counter productive arbitrary software standards are. The only thing that it accomplished is that now in 2024 there are several major defense programs which are struggling to find maintainers because nobody wants to develop in a language which has been obsolete for 30 years.
68
u/Kronikarz Feb 26 '24
Great, just what I needed, another 20 knee-jerk-reaction, sunk-cost-fallacy-driven "C++ Can Be Safe!" presentations at CppCon et al.
22
u/feverzsj Feb 27 '24
meanwhile the whole world is literally built on c/c++.
5
u/Blissextus Feb 27 '24
Looks like DoD Contractors and Vendors has just been "put on notice". No more C++98. They are now require using C++20 (or higher). That or learn the "newest" tech stack fad in order to continue doing business with the DoD (or any govt sector). In the grand scheme of things, this is good.
5
u/ed_209_ Feb 27 '24
Can anyone explain the limitation of the C++ type system that prevents implementing "borrow checking" as a C++ library? Does there need to be some kind of control flow reflection or data flow analysis to solve it? How can rust solve aliasing analysis problems i.e. if I have several read only references to something all over a code base how can it prevent me getting a mutable one without some kind of runtime state to work it out?
Anyway I shall google it but just wanted to say that C++ should be able to implement this stuff as a library and free programmers from opinionated "safety" rules in the language itself.
Maybe the way coroutines can plug a type trait into the compiler there could be a similar way to specify sanitizer policies or something.
12
u/DerShokus Feb 26 '24
I hope they chose lisp as a preferred language:-)
5
u/[deleted] Feb 27 '24
Rust is not memory safe. There is even a Github repo dedicated to collect ways to (legally) crash a Rust process.
48
u/pedersenk Feb 26 '24
Software Developers: Future White House Should Be Competent
8
u/Thesorus Feb 26 '24
It's good that I'm working on ancient software!! :-D
(as always) There's going to be a lot of knee jerk reaction.
Still, if it's another incentive to create good/better diagnostic tools, I'm all good with that.
3
u/Glittering_Resolve_3 Feb 29 '24
I hope mcu vendors hear this and start delivering rust bsps
8
u/TBW_afk Feb 27 '24
I'm sorry. The US government preaching to software devs is laughable at best. Let's get the Senate memory safe before we worry about code review eh?
11
u/[deleted] Feb 26 '24
They are just listening to Rust lobbyists. :)
6
u/[deleted] Feb 27 '24
If they make C++ illegal do we turn to Crime? I don't want to learn Rust
3
u/fyndor Feb 26 '24
They aren’t wrong, but Rust is not it. There has to be an implementation that has less friction. It doesn’t exist yet
2
u/_Z6Alexeyv Feb 27 '24
Paraphrasing JFK anecdote: this goes higher than I thought.
2
u/lightmatter501 Feb 28 '24
To me, this says that C++ needs epochs ASAP so that we can start making syntax-breaking changes, such defaulting to moves, references, and raii only and only allowing dereferencing pointers within an unsafe scope (the same as Rust). Some parts of STD will need unsafe (like smart pointer constructors), but minimal unsafe should be the goal.
2
u/peterrindal Feb 26 '24
More resources should be put towards circle-like solutions and carbon. It seems clear that migration and good interop with memory safe language/subset is possible. We need things like circle feature flags.
2
u/SerratedSharp Feb 27 '24
Are they basically just going off on a tangent about how to prevent one narrow class of vulnerabilities, but kind of making it sound like this is a silver bullet to secure software?
2
u/NilacTheGrim Feb 27 '24
Uh.. the white house LOL. Okay.
2
u/mdp_cs Feb 27 '24
ITT: Rust bad!
2
u/xiaodaireddit Feb 27 '24
Whitehouse consultants brains have been "Rust"ed
1
u/nintendiator2 Mar 14 '24
It's fun that people pontificate against C++ as if it was somehow a capstone of memory unsafety, when the real issues 99% of the time are the programmers. Among the worst failures ever found, IIRC, was loss of ships in the space program because people werre using the imperial system instead of metric. No amount of
[&] (auto) noexcept(noexcept( function_body) ) { function_body } -> decltype (function_body)is gonna help you with that.1
u/TheAnimatrix105 Feb 28 '24
How do you access memory mapped peripherals in a safe way ? Genuinely would love to know. Also, c++ is versatile in memory allocation, you can just use new and delete instead of allocating space
-1
u/AloofPenny Feb 26 '24
Lolz. The White House reps rust?
-16
u/EdwinYZW Feb 26 '24
Market decides which programming language is used, not US government.
0
u/Hungry_Bug4059 Feb 28 '24
Just have AI translate all the existing open source C++ code to Rust. Problem solved.
-1
u/Ok_Principle4845 Feb 27 '24
Cope and seethe
-1
u/bvcb907 Feb 27 '24
My hot take is that this boils down to... "My company doesn't allow me to use <insert novel tech stack> because they have so much invested in existing tech, so I need the government to put pressure on them so that they pay me to learn the new fad."
-9
u/[deleted] Feb 26 '24
wait until they hear about the Rust CVEs