Hacker Read top | best | new | newcomments | leaders | about | bookmarklet login

That's another aspect of it. Please see this answer of mine:

https://news.ycombinator.com/item?id=27642630

In short, memory unsafety makes programmer bugs exploitable, instead of generally just failing.



sort by: page size:

That's not memory-unsafety. Memory-safety means avoiding bugs like buffer overflow, ROP, etc.

> Memory unsafety is just one class of safety bugs, and a relatively unimportant one.

Wrong. Memory unsafety, in its various forms, is the primary source of exploits in software written in C.

> I'd be much more worried about concurrency bugs

Another thing which is hard to do in C, and so much easier in some more modern programming languages (particularly in Rust).


To add to that, there are some applications for which memory unsafety just doesn't cause that much harm.

I worked on a very large C++ codebase that compiled to webassembly, which runs sandboxed in people's browsers. It only talked to one (trusted) server.

Like any project, we had plenty of logic bugs every release. They would often result in odd artifacts on the screen and sometimes a crash.

Only 5% of our bugs were related to memory unsafety, and they also resulted in odd artifacts on the screen and sometimes a crash.

In other words, memory unsafety wasn't much of a concern in practice. It was as bad as any logic bug.

This was the main reason we stuck with C++, rather than spend SWE-years migrating to a more memory-safe language.

(I know this is ironic coming from me, who designs a memory-safe language full-time!)


Right, but a memory unsafety but is what takes a harmless logic bug in an image parser with no filesystem access to an RCE and sandbox escape.

Memory unsafety allows you to change the 'category' of the bug, you become free to do whatever whereas a logic bug forces to to work within the (flawed) logic of the original program.


> memory unsafety

Memory unsafety is just one class of safety bugs, and a relatively unimportant one.

As far as payment processors go, I'd be much more worried about concurrency bugs.


I don't have any data on exploitability, but 19 of the last 22 vulnerabilities (since 2018) have C-induced memory unsafety as a cause: https://curl.haxx.se/docs/security.html

I'm not saying that memory unsafety is useless or even undesirable, I think the "problem" is that it's the default in "current popular and actually used high-performance languages", which means that stuff that needs to be fast and secure (like web browsers) have a hard time.

Maybe my "most of the time" was too strong and I ignored big domains that I don't know. But for the part that I relatively know (web stuff mostly), safety and speed together matters a lot. The thing is, since unsafety tends to be viral (an unsafe part of your stack can compromise everything), people get very paranoid about "unsafe languages".


The vulnerable piece of code didn't need memory unsafety. Sure, __minimal_malloc does, but the bug was in mundane string handling.

You can still write memory safety bugs, you just need unsafe. I'm glad unsafe is used in so many libraries.

70% of high severity security bugs (including RCE) are due to memory unsafety. Not all, but most. It's been this way for~decades.

https://news.ycombinator.com/item?id=19138602

https://www.zdnet.com/article/chrome-70-of-all-security-bugs...


The point is not whether or not it is intentional, but to illustrate that many vulnerabilities exist that don't depend on memory unsafety.

Memory safety helps, but isn't the only source of exploitable bugs.

unsafe memory and unsafe types are not okay if you widely claim to be memory safe. Thousands of people actually believe these lies, and companies do makes decisions on these claims. It's much more memory unsafe than Java in fact. Java recently removed the unsafe tricks, whilst rust was once safe and went more and more unsafe since.

100% of exploited vulnerabilities leveraged memory unsafety. 70% of vulnerabilities discovered are from memory unsafety.

That's strange... if they'd written the code in a memory safe language, say, Java... there wouldn't be any vulnerability?

I don't know... I see plenty of vulnerabilities in the Java world, no memory unsafety needed.


Memory safety is valuable! I wouldn't want to implement anything in a memory-unsafe language if I could avoid it, and, thanks to Rust, I can virtually always avoid it now. There's ways to make bugs easier to chain and exploit, and memory unsafety is a big one.

But, while I know nothing is a panacea, memory safety is especially not a panacea. We have over a decade worth of experience with software built principally in memory-safe languages; it's hard to find a modern web application --- increasingly, it's even hard to find a modern mobile application --- built in a language as bad as C. And, as you know, all these memory-safe applications are riddled with vulnerabilities. They don't have memory corruption vulnerabilities, but I'm still game-over'ing app pentests, and very unhappy with myself when I can't.


Zero memory errors, not zero vulnerabilities.

In high-quality C and C++ projects, about 70% of vulnerabilities are caused by memory errors. (https://alexgaynor.net/2020/may/27/science-on-memory-unsafet...)


Not to go all 'Rust Evangelism Strike Force' but almost universally, these exploits leverage memory unsafety somewhere in the stack, usually in a parser of some kind (image, text, etc). The fact that this is still tolerated in our core systems is a pox on our industry. You don't have to use Rust, and it won't eliminate every bug (far from it), but memory safety is not optional.

We truly need to work more towards eliminating every memory unsafe language in use today, until then we're fighting a forest fire with a bucket of water.


Of course, but memory unsafety is one of the biggest enabler for security vulnerabilities. Attackers have shifted to other concerns when PHP became widespread enough for example, but PHP alone cannot be used to create a vulnerability common in C/C++ because of its memory safety (which is not even that good!), you need some other systems to combine multiple issues into a single coherent attack, and it's likely that C/C++'s memory unsafety has played a great role somewhere in between. He doesn't fully acknowledge this multiplicative aspect of memory (un)safety.
next

Legal | privacy