I believe this (focusing on memory safety more than on “other bugs”) is a rational thing to do!
The main issue here is that “other bugs” can, worst-case, reduce utility of a given program to zero, while memory safety issues lead to negative utility, via compromising security.
A longer explanation follows:
As an example, suppose I downloaded an application for browsing funny memes from the internet. If the application is just buggy (crashes, leaks memory, is unreasonably slow, etc), I just don’t run it, and I am not worse off compared to an alternative world where this meme viewing software doesn’t exist.
Now suppose that the application is implemented in C and has memory safety issues. This sometimes means that the application can be exploited. For example, a carefully crafted adversarial meme can cause the application to read the data it wasn’t supposed to read, and send it to the attacker. In this world, opening the meme software could lead to my credit card number being stolen, or some such. The utility is negative — I am actively worse off compared to the world where the software just doesn’t exist.
A real world example of this effect are the recent Linux kernel vulnerabilities. My understanding is that they boil to basically this: There’s this kernel module, which is old, crufty, unused, and nobody cares about it existing at all. It could be completely broken! However, this module has an index-out-of-bounds, which allows malicious program to modify memory of unrelated programs. Suddenly, this module becomes very valuable to attackers, who can use it to take over Linux machines.
This negative utility reasoning I think justifies emphasizing memory safety in particular, via primum non nocere.
There are two questionable inferences there:
First, Is negative utility real? Do users actually suffer material damage from exploitable programs? I don’t know. There’s a lot of direct evidence of people caring about this, with CVEs and such, and with every juicy vulnerability making it into the news. As for direct damage, my understanding that there are some high profile targeted attacks (a journalist finding spyware on their phone), which are traceable to security issues somewhere. There’s also an issue of botnets from residential IPs (your smart toaster getting pwned and the like). Though, my understanding is that these days botnets are “legit” — there are certain "SDK"s you can integrate into your mobile application, and receive money every time a user opens your app.
Second, There’s a certain equivalence in the above between memory unsafely and security vulnerability, is it justified? Well, if you write your app in a garbage collected language, you generally get memory safety for free. You can still have XSS, SQL injection, etc, of course, but you are protected from vulnerabilities due to memory unsafely. And given that most software is written in GC languages, I think it’s fair to say memory safety doesn’t matter much in the grand scheme of things.
But of course this doesn’t apply if you are using a memory unsafe language! Here, there’s very believable, very robust number: you should expect more than half of security issues in C/C++ code to be attributed to memory unsafely. There were reports from all of Apple, Google, Mozilla and Microsoft, saying “yup, XX% of CVEs in our C++ code is memory unsafety”. This doesn’t mean that you can’t write secure C, but it does mean that security isn’t default outcome.
But note that these are findings for C/C++ code, not “average across not memory-safe languages”. And these two languages are famous for being quite adversarial when it comes to UB. If all that code was written in Zig, what would be the number of security vulns due to memory safety?
This is the question I genuinely don’t know the answer to. My current hypothesis is that the outcome would be approximately the same for ReleaseFast mode, and significantly, significantly better in ReleaseSafe. My anecdotal understanding is that the vast majority of “memory safety exploits” are downstream of out of bounds indexing, and that’s something Zig solves pretty conclusively in safe modes.
Though, I am confused here. My understanding is that both ghostty and bun are/were distributed in ReleaseFast form. I would expect that to be exploitable in theory, and exploited in practice, given how widely they are used.