Live data from Hacker News

Memory Safe Languages in Android 13

security.googleblog.com

331–340 of 606 posts

Re: Memory Safe Languages in Android 13

#331

Earlier quoted context omitted.

Except, you've failed to check for an error, and you need another line to do that. Suppose the user ended their input or the input is a pipe that's been closed - what does your C++ program do? Here's another example. C++ lets you do this: long input; std::cin >> input; process(input); and this is very convenient! It's much shorter than the Rust code for doing the same. It's also wrong! If the input cannot be read, or…

> Some people will say, I just want to get stuff done and not worry about all this safety junk. As someone who works in security and have exploited bugs in C/C++ programs, this is pretty much why we wound up with so many CVEs. Are constructions like these really the root cause of CVEs? As long as you do a correct check, then you're all good. If Rust can do the same thing in fewer lines, then that may or may not be a…

Oh absolutely! Here’s an example from 2019: https://www.cve.org/CVERecord?id=CVE-2019-15900

“An issue was discovered in slicer69 doas before 6.2 on certain platforms other than OpenBSD. On platforms without strtonum(3), sscanf was used without checking for error cases. Instead, the uninitialized variable errstr was checked and in some cases returned success even if sscanf failed. The result was that, instead of reporting that the supplied username or group name did not exist, it would execute the command as root.”

Fail to check that your input parsed correctly, wind up with privilege escalation to root.

Re: Memory Safe Languages in Android 13

#333
post #284

Earlier quoted context omitted.

> I didn’t say it’s not an improvement. You… almost literally did? > I am happy that we are moving towards a future where there are less memory bugs, but… are we really?

> You… almost literally did? I don't understand this comment, to be honest. What does it add to the conversation?

Why shouldn’t this kind of inconsistency be pointed out?

I’m happy to believe GP didn’t say exactly what they intended to or simply misremembered what exactly they said previously. It’s certainly something I’ve done before in an online conversation. And when it’s happened to me I’ve appreciated having it pointed out explicitly so I could clarify what my thoughts actually were. Often it’s because I misstated my opinion without realizing.

Either that’s the case here (what I’m choosing to believe) and it gives GP an opportunity to explain further or GP is engaging in this discussion in bad faith. In either case, I don’t see the downside.

Re: Memory Safe Languages in Android 13

#334

I wonder if their efforts to leverage modern chip capabilities to address memory safety (e.g: ARM memory tagging) contributed to that drop of memory safety vulnerabilities

It helps along with the other (software) tooling that exists to improve the safety story for existing C and C++ code. However, it does not eliminate these issues.

Lowers the severity of these issues tho.

Re: Memory Safe Languages in Android 13

#336
post #248

No such luck in having some technical discussion or at least a link to the sources. If the Rust community can be insufferable when trying to sell Rust at any and every opportunity, Lord have mercy when they see any kind of success because the preening and puffing will have no end. This blog post will live forever in the annals of Rust. On the other hand I’m not surprised to see that it’s written by the security team…

It's almost like us security professionals are just better developers too :O

Re: Memory Safe Languages in Android 13

#337

Their notes about vulnerability severity are particularly interesting. Defenders of C/C++ frequently note that memory safety bugs aren't a significant percentage of the total bug count, and argue that this means it's not worth the hassle of switching to a new language. Google's data suggests that while this is true, almost all severe vulnerabilities are related to memory safety. Their switch to memory-safe languages…

Members of the C++ community are working on fixing that. The Herb Sutter CPP2 idea:

https://www.youtube.com/watch?v=ELeZAKCN4tY

Re: Memory Safe Languages in Android 13

#338
post #294

Earlier quoted context omitted.

Google is one of the biggest C++ shops out there, and also authors and maintains many of the static analysis tools and safety features you mention. If they’re saying that C++ can’t be saved, maybe they’re worth listening to.

Programming languages are tools for a job. As the saying goes, a bad workman blames his tools. It's not worth taking anyone who blames defects on a programming language too seriously, whether it's Google or not. Modern C++ has many memory safety features. If a company has learned that its people fail to use them, then bad for them. Of course, there are languages that abstract memory safety to the point that they elim…

> We should not bury C++ prematurely before answering the question - "what else is as fast and efficient as to replace it for OOP?"

We have an answer: Rust. It's no longer premature, bury it.

Re: Memory Safe Languages in Android 13

#339

Another failure for Kotlin Native, what a sad shitshow.. They were warned many years ago about ownership/concurrency/compile speed, they didn't listen at all A vision alone doesn't matter, you need skilled engineers and a dedicated team who understand what "taste" for great things is What could have been the Swift for android will end up just being the "java" alternative, i suspect they'll get rid of the JVM, or what…

Kotlin is generally recommended for application development on Android.

I talk about Kotlin Native, not Kotlin

Re: Memory Safe Languages in Android 13

#340
post #228

Earlier quoted context omitted.

...but still, even with Android's importance and Google's resources, they're not planning to "rewrite it in Rust", at least not for now - only new code will use Rust.

The overwhelming majority of bugs of any sort live in new code. The longer a piece of code has been around, the safer it generally is (with occasional high-profile exceptions). This means two things: 1) The most cost-effective way to eliminate the majority of memory bugs is to just start writing all new code in a memory-safe language. If you were going to write new code anyway, you may as well do it safely. 2) Going…

Part of that safety is users working around known bugs, leading to inefficient solutions to whatever the code is supposed to do.

People tend to forget that they don't have to live with those problems, but they still have a cost

Post reply on HN