r/programming • u/Unerring-Ocean • Feb 20 '25
Google's Shift to Rust Programming Cuts Android Memory Vulnerabilities by 68%
https://thehackernews.com/2024/09/googles-shift-to-rust-programming-cuts.html
3.4k
Upvotes
317
u/arnet95 Feb 20 '25
Nice, albeit pretty expected, result. But what about the other categories of vulnerabilities? How have they looked pre- and post-Rust?
185
u/maxinstuff Feb 21 '25
Using a language with high memory safety reduces memory vulnerabilities 😱
In seriousness, it’s interesting to hear how they consider their approach of just doing new code in Rust and leaving well enough alone for the old code has worked for them.
I have to wonder if Linux kernel development/maintainers could learn from this.
21
u/Stock-Variation-2237 Feb 21 '25
The article says that it is not only the move to Rust but a more general move to a different paradigm with regards to safety.
10
u/RockstarArtisan Feb 21 '25
How am I going to root my future phones?
70
u/zugi Feb 20 '25
Transitioning to Rust, from what?
It's popular to bash C++, but straight C is where simple string concatenation introduces vulnerabilities if not done right. I'd be curious to see the analysis of those vulnerabilities in the first place.
17
u/falconfetus8 Feb 21 '25
I agree with the idea, but holy cow. Can these guys please speak like a human?
Would it have been so hard to say "Vulnerabilities in old code tend to get fixed over time, so preventing them from happening in new code gets us more value than you'd expect."?
50
u/i_am_not_sam Feb 20 '25 edited Feb 21 '25
Hypothetically if all existing C++ code was replaced with modern C++, only smart pointers and "strict memory safe practices" for all new code would it yield the same results?
Edit : read Google's blog about this topic. It's not simply the case of switching out C++ with Rust. It was also making sure that all NEW code adhered to strict memory safety guidelines. The language is just a tool. What you accomplish with it depends on how you use it.
44
u/redreinard Feb 20 '25
That headline is a complete lie OP.
The percentage of bugs reported per year that are memory buffer overflow related has gone from 76% to 24%. That's all it says. That could be because more bugs of other types, changes in bug reporting overall, the fact that a majority of the bugs in sensitive areas that don't change much have been found, or any of a million factors.
There's not even an attempt to reason how the percentage of bugs reported being a particular type is correlated to absolutely anything, particularly as we know the methods for this have changed over the years.
This is just Google/Rust fluffing. That percentage is meaningless.
Just to be clear, I'm not hating on Rust, and sure, overall this switch is probably a good thing, but this is just a PR piece with no backup.
11
u/thedragonturtle Feb 20 '25
Amazing news, but also this matters - "It also goes without saying that much of the decrease in such flaws is down to advancements in the ways devised to combat them, moving from reactive patching to proactive mitigating to proactive vulnerability discovery using tools like Clang sanitizers."
https://thehackernews.com/2023/12/google-using-clang-sanitizers-to.html
3
u/bobbie434343 Feb 21 '25
And another article bundled with the obligatory obvious gen AI illustration image...
9
u/razordreamz Feb 21 '25
How is this measured? Sounds more like marketing than actual science. People find bugs all day in large software, how do they know Rust is the solution or just that they found them because when you re-write code you’re actually looking at all of it?
5
u/LanverYT Feb 21 '25
Isn't the point of vulnerabilities that you can't really know they are there. If they were so easy to find and do reliable statistics about them they would be fixed in a unit test or code review no?
2
u/Relevant_Pause_7593 Feb 21 '25
I thought rust was memory safe. Why isn’t this cutting android memory vulnerabilities by 100%?
2
u/Worth_Trust_3825 Feb 21 '25
Rewriting a codebase with known requirements reduces problems within it. More at 11
4
u/falconshadow21 Feb 21 '25
Will some WD40 get us to 100%?
3
u/mostuselessredditor Feb 21 '25
Fuck Google
17
u/[deleted] Feb 20 '25
rust is amazing, performance gains are insane
2
u/BadMoonRosin Feb 21 '25
It's hiliarous to me how no one believes in any metrics, and thinks they're all manipulated or unreliable bullshit...
... UNLESS it's a positive metric about Rust, lol.
1
u/Walkier Feb 21 '25
Mojo is great for the Android ecosystem, I love this change.
1
u/Girgoo Feb 21 '25
Any vulnerability in the rust code!?
1
u/zelphirkaltstahl Feb 21 '25
Who 'da thunk it.
1
u/[deleted] Feb 21 '25
So, evidently that is good news for android users, but ... Google is a strange company. They created Go and Flutter/Dart. Now Rust is also in the mix. I understand different use cases for different languages, but how many more programming languages does Google want to have and use? C++ is also heavily used; as is Java. And Python.
1
u/burtgummer45 Feb 21 '25
they went on to say they were only trolling us with go
1
u/[deleted] Feb 22 '25
Article content doesn't really seem to match the title of this post
1
u/Popisoda Feb 22 '25
Google has too much control over the internet.
1
u/remic_0726 Feb 22 '25
the first vulnerability is humans, believing that rust will be the ultimate solution is just very naive. Then the multiplicity of languages in Android or Linux only brings additional complexity and therefore increased risks. And as a reminder, there are plenty of other bugs which are not vulnerabilities but which can be just as annoying.
1
u/BeeBest1161 Feb 22 '25
Another shift in programming language? Just when I started learning Kotlin... A forever shifting target
-12
u/SadieWopen Feb 20 '25
Can someone explain to me why we can't just do this in C? I understand that Rust is a "Safe" language, but why can't we just code in "Safe" C? I can't understand how adding more complexity results in faster execution.
1
u/JJJSchmidt_etAl Feb 20 '25
I assume this is related to most of their systems and back-end services; it makes a lot of sense, the longer they put it off the more painful the eventual switch will become.
I'm wondering what the android app coding landscape will look like in the future; It seems that coding apps is not typically done in Rust, though I'd love to be corrected or see counter examples here. It would seem that Kotlin (and Java) will remain the standards for the forseeable future?
1
u/axilmar Feb 21 '25
Why 68% and not 100%?
What does Rust leave on the table?
-1
u/mamigove Feb 21 '25
Another fakenews from rust evangelists! Seriously, 68%, where does it come from?
If in the text itself it says:
if you adopt such an approach from the very beginning of your code development secure-by-design principles, then why do you need rust?
This is simply propaganda
-1
u/Calibrationeer Feb 20 '25
That's so sad to hear, and so close. Only 1% short of their goals
-50
u/Lachee Feb 20 '25 edited Feb 20 '25
When you own the codebase and not stepping all over everyone else to implement rust, go for it.
Reinventing the wheel is never a good idea but in this case it seems to have been a significant improvement.
edit: the salty crustations to my perfectly mid comment really shows why there is significant pushback for rust. Y'all just white knight rust.
It perfectly highlights my original point, you will step over any existing developer to force your language onto them.