News for hackers. Stuff that matters.
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by albntomat0 on Tuesday September 26, 2023 @09:48AM (#37659263)
Additional timeline info, as I was curious myself. WebP is old enough that a memory safe language was not a feasible option when the project started.

Android 12 was the first version to support Rust code, and came out in 2021 [0, link talks about the first year of integration].

On the iOS side (which also was affected by this), Swift 1.0 came out in ~2014.

As far as I can tell, Chrome doesn't yet support a memory safe language, but do have a bunch of other safety things built in (see MiraclePtr, sandboxing, etc). Since both WebP and Chrome are from Google, this would stop a possible transition.

WebP was announced in 2010, and had its first stable release in 2018 [1].

[0]: https://security.googleblog.com/2022/12/memory-safe-language...

[1]: https://en.wikipedia.org/wiki/WebP

Re:Google assigns a CVE for libwebp and gives it a 10.0 score by matthewdgreen on Tuesday September 26, 2023 @10:33AM (#37659971)
Is Rust in practice a memory safe language when you're doing tricks like decoding huffman-decoding huffman tables into buffers? It seems like once you optimize for performance this much, you're liable to turn off bounds checking here or there.
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by albntomat0 on Tuesday September 26, 2023 @11:01AM (#37660395)
I agree it's definitely possible, and I'm certain we'll see a vuln due to some crazy Rust optimizations in the future.

That said, not switching over to a memory safe language, in my opinion, is letting perfect be the enemy of the good. Folks will still be able to write footguns, but better language choices will prevent bugs in the all the non-crazy optimized parts.

Re:Google assigns a CVE for libwebp and gives it a 10.0 score by antiframe on Tuesday September 26, 2023 @11:03AM (#37660428)
Rusts bounds checking is done at compile time, so you don't need to turn it off.
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by flooow on Tuesday September 26, 2023 @11:25AM (#37660733)
Incorrect. Semantically, Rust always inserts runtime bounds-checks, regardless of optimization level. The compiler _may_ then remove them as part of an optimization pass, iff it can prove the check is redundant.

Do bounds checks even matter, even for very tight loops? This article [1] seems to suggest that removing the checks can give up to 10-15% speed increase under some circumstances. Worth it? I'd say no.

[1] https://dropbox.tech/infrastructure/lossless-compression-wit...

Re:Google assigns a CVE for libwebp and gives it a 10.0 score by pjmlp on Tuesday September 26, 2023 @11:27AM (#37660779)
And runtime as well, like in any memory safe language.
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by pjmlp on Tuesday September 26, 2023 @11:28AM (#37660789)
First profile, then optimize.

Many anti-bounds checker advocates, usually miss the first part.

Re:Google assigns a CVE for libwebp and gives it a 10.0 score by vacuity on Tuesday September 26, 2023 @02:26PM (#37663699)
The point of `unsafe` in Rust is that you can generally limit `unsafe` code to a few short functions and encapsulate them in a safe interface. This means less code to review and maintaining strong guarantees in the rest of the safe Rust code.
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by Lockal on Wednesday September 27, 2023 @02:19AM (#37670867)
There are already huffman-decoding and some parts of webp algorithms in https://github.com/google/wuffs (language that finds missing bounds checks during compilations). In contrary, according to readme, this language allows to write more optimized code (compared to C). WEBP decoding is stated as a midterm target in the roadmap.
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by MatthiasPortzel on Tuesday September 26, 2023 @10:36AM (#37660024)
[delayed]
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by albntomat0 on Tuesday September 26, 2023 @10:52AM (#37660265)
Ahh cool! I was unaware of Wuffs. Thanks for sharing!
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by postalrat on Tuesday September 26, 2023 @09:52AM (#37659309)
Is JavaScript a memory safe language?
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by albntomat0 on Tuesday September 26, 2023 @10:00AM (#37659424)
Yes, and so are Python, Lisp, Haskell, and a million other languages that were available in 2010.

None of those are suitable options for an image decoding library on the range of WebP supported platforms.

Re:Google assigns a CVE for libwebp and gives it a 10.0 score by mrtksn on Tuesday September 26, 2023 @10:13AM (#37659645)
>None of those are suitable options for an image decoding library on the range of WebP supported platforms.

What makes these unusable for this task?

Re:Google assigns a CVE for libwebp and gives it a 10.0 score by sp332 on Tuesday September 26, 2023 @10:17AM (#37659712)
They need a large runtime and are slow to start up.
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by mrtksn on Tuesday September 26, 2023 @11:38AM (#37660946)
Is that true for all memory safe languages? Why?
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by marcosdumay on Tuesday September 26, 2023 @12:29PM (#37661734)
> Is that true for all memory safe languages?

No. That is true for the list upthread (well, if you consider runtimes measuring a couple of MB "large", it's reasonable but quite arguable). It doesn't have much correlation with any feature.

Re:Google assigns a CVE for libwebp and gives it a 10.0 score by pjmlp on Tuesday September 26, 2023 @11:31AM (#37660840)
Modula-2, Ada, Object Pascal, D would be.

What makes them unsuitabe is lack of widespread compiler support across those platforms, if we ignore how long Ada has been available in GCC.

And Modula-2 is now in GCC as well.

Re:Google assigns a CVE for libwebp and gives it a 10.0 score by assassinator42 on Tuesday September 26, 2023 @12:46PM (#37662036)
Ada has the bounds checking, but doesn't (AFAIK) have a safe way to deallocate dynamic memory. At least as of now, there is a proposal to add something like Rust in the future. It also has memory unsafe concepts like specifying an address for a variable.
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by pjmlp on Tuesday September 26, 2023 @04:13PM (#37665218)
Yes it does, this isn't Ada83 we are talking about.

Well Rust also has unsafe, better not use it.

Re:Google assigns a CVE for libwebp and gives it a 10.0 score by unilynx on Tuesday September 26, 2023 @09:55AM (#37659369)
It is. and so is WASM, but both probably aren't fast enough
Re:Google assigns a CVE for libwebp and gives it a 10.0 score by Thews on Tuesday September 26, 2023 @10:14AM (#37659660)
I think there is a ~35% hit with emscripten