logoalt Hacker News

Rust at Scale: An Added Layer of Security for WhatsApp

233 pointsby ubjtoday at 6:21 AM120 commentsview on HN

Comments

londons_exploretoday at 5:10 PM

> over 3 billion people to message securely each and every day.

Whatsapp is a chat application with 3 billion daily active users.

For those of you in the US (where Whatsapp is seldom used), this is a fact worth remembering.

If you want to build products for the rest of the world, you need to know how those users think and breathe - and for 3 billion of them, Whatsapp is how they talk.

show 6 replies
erithaxtoday at 4:19 PM

> We believe that this is the largest rollout globally of any library written in Rust.

I think that crown currently goes to https://github.com/googlefonts/fontations which is included in Chromium, not sure if it's on all platforms yet. Moreover, the translative dependencies of Fontations (click through https://crates.io/crates/fontations/0.3.0/dependencies) should have an even (slightly) larger install-base.

EDIT: from the quote you can also gather that they don't use https://github.com/signalapp/libsignal

show 2 replies
cong-ortoday at 2:26 PM

The 160k → 90k LOC reduction is nice, but the parallel rollout is the more interesting part. Running Rust alongside the C++ version and using differential fuzzing to check equivalence is a lot more realistic than “rewrite and pray.” You get incremental validation with the old system as a fallback. Curious how long they ran both before cutting over.

Binary size is a real concern on the client side. On servers the Rust stdlib overhead usually doesn’t matter, but when you’re shipping to billions of mobile devices, every KB counts. Good to see they invested in build tooling instead of just accepting the bloat.

show 1 reply
storystarlingtoday at 10:40 AM

The hardest part of a rewrite like this is usually maintaining bug-for-bug compatibility with the legacy parser rather than the actual Rust implementation. Most real-world media files are malformed in some way that the C++ code implicitly handled, so if you write a strict parser you end up breaking valid user data. Differential fuzzing seems like the only practical way to map that behavior without manually reviewing millions of edge cases.

show 1 reply
nevi-metoday at 9:34 AM

> We believe that this is the largest rollout globally of any library written in Rust.

I suppose this is true because there's more phones using WhatsApp than there are say Windows 11 PCs.

Given that WhatsApp uses libsignal, is it safe to assume that they haven't been using the Rust library directly?

show 2 replies
palatatoday at 12:05 PM

> Two major hurdles were the initial binary size increase due to bringing in the Rust standard library [...].

They don't say what they did about it, do they? Did they just accept it?

show 5 replies
kpcyrdtoday at 9:23 AM

Very cool! I'm wondering if Signal is doing something similar? libsignal is implemented in Rust, but I don't know about the other parts.

I_am_tiberiustoday at 2:59 PM

> "WhatsApp provides default end-to-end encryption for over 3 billion people".

Wasn't there news lately that they can still read your messages somehow?

show 2 replies
aloukissastoday at 7:45 PM

I love how Meta will do anything but prevent phishing and prepaid credit card scams in Whatsapp/Messenger

aero-glide2today at 11:57 AM

Quite impressive, I did not know so many bugs were due to memory access.

show 1 reply
blubtoday at 2:10 PM

Just like Google’s Rust-in-Android blogs this reads like a PR piece (and in the case of facebook also recruitment piece) with some technical words sprinkled in for effect. The overall communication quality is that of a random startup’s “look what we did” posts.

The interesting aspects, such as how they protect against supply-chain attacks from the dependency-happy rust toolchain or how they integrated the C++ code with the Rust code on so many platforms - a top challenge as they said - remain a mystery.

Would also be interesting to hear how much AI-driven development they used for this project. My hope’s that AI gets really good at Rust so one doesn’t have to directly interact with the unergonomic syntax.

show 2 replies
mentalgeartoday at 12:33 PM

Cool - now we only need to get selling-you-out-for-profit-Zuckerberg out of WhatsApp to make it really trustworthy.

wrtc_devtoday at 12:16 PM

[flagged]

show 2 replies
happyweaseltoday at 2:58 PM

Let's see how this unwrap()s in production scnr

show 1 reply
justinlordstoday at 4:37 PM

The differential fuzzing approach is clever — way safer than a big-bang rewrite. Running both versions in parallel to catch edge cases before switching over is how you actually ship rewrites without breaking production. The 160k to 90k LOC drop is impressive, but the real engineering win is the validation strategy.

On binary size, static linking with LTO should handle most of the bloat without needing custom stdlib builds.

show 1 reply