4 ms·
The story for C/C++ software is a bit different. It has an order of magnitude more security issues than (similarly well written) software in other languages. Mo
by nicoburns 6y ago
The story for C/C++ software is a bit different. It has an order of magnitude more security issues than (similarly well written) software in other languages. Mostly because of memory issues. Partly due to undefined behaviour.
There's a lot of this software. And until recently C and C++ were more or less the only viable options for writing it. Now there's Rust, and it has the potential to bring rates of security issues down to the levels of other memory safe languages (or even lower - Rust actually has protections against things like thread-safety issues that languages like Java don't).
If the language didn't matter, then we'd all be writing in assembly code. It can make a big difference.
- badsectoracula 6y ago> has an order of magnitude more security issues But then there is a LOT more C/C++ software as well, so it makes sense that when you have a lot more code you'll also have a lot more bugs. > than (similarly well written) software in other languages. Why isn't that similarly well written software being used instead of the C/C++ software when the latter ends up with more bugs? > And until recently C and C++ were more or less the only viable options for writing it. I do not think that this is the case, there have been alternatives for pretty much as long as C existed. For example Object Pascal existed for decades before Rust and while it doesn't have as many compile-time guarantees as Rust does, it still is safer than C and C++, provides a similar amount of functionality while not losing in terms of low level functionality. Yet outside of a few exceptions (mainly during Borland's heyday) people still went with C or C++ despite those languages not providing anything special compared to it. And there have been other languages too - i've seen Ada being brought up often as a much safer language (safer than Pascal too) with a strong type system, yet still being usable even on tiny devices. What makes people stick with C and C++ when other solutions existed for years and how would Rust change that when other languages apparently failed?
- swsieber 6y ago> But then there is a LOT more C/C++ software as well, so it makes sense that when you have a lot more code you'll also have a lot more bugs. 70% of C/C++ security bugs are memory management bugs. Those don't (for the most part) exist in GC'd or other non-manually managed memory languages. > Why isn't that similarly well written software being used instead of the C/C++ software when the latter ends up with more bugs? Performance and low level control. Familiarity. etc.
- steveklabnik 6y ago(The statistic you're citing did not separate by language, it was "70% of security bugs are memory safety bugs" only, no language break-out.)
- swsieber 6y agoThanks Steve. I'm going to have to do more research I see :)
- anKlamsno 6y agoThis correct viewpoint is always down-voted because it is uncomfortable to the clique of something like 20 HN members that fanatically control every Rust thread.
- ajross 6y ago> C/C++ software [...] has an order of magnitude more security issues than (similarly well written) software in other languages. I think that's very debatable. Certainly there are classes of bugs with C code that don't exist in other environments. And addressing that is worthwhile. But "security issues" is a VERY big bucket, and most of them (and frankly most of the most dangerous) aren't about memory protection or heap management at all. Java doesn't prevent you from exposing a database with a default password. Node apps can have XSS vulnerabilities. Access to a Rust app can always be phished. I know those all seem like specious examples, but the point is that you're using a very narrow definition of "security" (to mean The Stuff Rust Addresses) in one sense, while using a very different definition (Stuff That Is Really Important For Software To Do) in the premise to your argument. The space between "well-written C++ code" and "well-written Rust code" is a very different number in those two spaces. And in the one that actually matters... I just don't think it's nearly as big as people like to imagine.