Live data from Hacker News

Rust’s standard library was vulnerable for years and nobody noticed

medium.com

21–30 of 58 posts

Re: Rust’s standard library was vulnerable for years and nobody noticed

#21

Earlier quoted context omitted.

Here's an example of a quite high profile Rust project discovered to have been (ab)using unsafe: https://www.reddit.com/r/rust/comments/8s7gei/unsafe_rust_in...

... and, due to said awareness, the issues were all fixed. The presence of the unsafe keyword made the audit much easier. Everything is working as intended!

https://github.com/actix/actix-web/search?utf8=%E2%9C%93&q=u...

Re: Rust’s standard library was vulnerable for years and nobody noticed

#22
post #14

> For example, Erlang — that funky language that people use to program systems with 99,9999999% uptime (no, that’s not an exaggeration) — has repeatedly shipped with a broken implementation of Map data structure in its standard library. …during the period ‘maps’ was a experimental/beta-feature.

Unless you have to type “Please enable maps even though it will break all of my code” every time you run it, that's a distinction most people will ignore. If something is useful enough to ship, people will want to use it — helping test it is even the point — and only the most prominent “This is terribly unsafe” warnings will be heeded.

Re: Rust’s standard library was vulnerable for years and nobody noticed

#23
post #9

In Go you can write unsafe code in libraries. You can even write raw assembly if you want. We had an encoding library written in a very c-ish style for maximum performance, and sure enough, it had an off-by-one error on the last byte that could've been exploited. It's funny that in severely limiting the area we could use unsafe we still somehow managed to write it improperly. If anything it serves as a reminder of wh…

Here's an example of a quite high profile Rust project discovered to have been (ab)using unsafe: https://www.reddit.com/r/rust/comments/8s7gei/unsafe_rust_in...

From that link:

>> Folks who are considering using actix-web might want to follow this thread about its heavy use of unsafe Rust.

It's one thing to make heavy use of a small bit of unsafe Rust. It's another to use unsafe heavily - like someone who just refuses to use the language properly and therefore just keeps writing unsafe code. It's not clear from the wording which case this was but they do say it was fixed, rather than declaring it an unmitigated disaster ;-)

Re: Rust’s standard library was vulnerable for years and nobody noticed

#24
This article casually throws around definitions of 'memory safety' that are massively different.

Rust's 'memory safety' guarantee is different from Go's 'memory safety'. Rust includes protection from things like modifying memory from 2 different spots at the same time, among other things.

AFAIK that's perfectly fine to do in Go, you can pass around pointers between threads as much as you like. This sort of behaviour wouldn't be allowed in safe Rust.

edit: I just really don't understand the criticism against Rust here for having 'unsafe' given much of what is covered in those unsafe blocks is allowed in many other languages, including a language mentioned in the article as being 'safe'

Re: Rust’s standard library was vulnerable for years and nobody noticed

#26

Earlier quoted context omitted.

... and, due to said awareness, the issues were all fixed. The presence of the unsafe keyword made the audit much easier. Everything is working as intended!

https://github.com/actix/actix-web/search?utf8=%E2%9C%93&q=u...

Good rust code doesn't have to be free of unsafe blocks. In some cases you can't avoid them, e.g. when doing memory mapping. Instead, the unsafe blocks semantically designate areas you should keep an eye on. I rather have 20 unsafe one-liners surrounded by safe wrappers in a project with several thousand LOC, than a 1k LOC C project where I have to take extra care with every step.

Re: Rust’s standard library was vulnerable for years and nobody noticed

#27

Earlier quoted context omitted.

... and, due to said awareness, the issues were all fixed. The presence of the unsafe keyword made the audit much easier. Everything is working as intended!

https://github.com/actix/actix-web/search?utf8=%E2%9C%93&q=u...

Sure. I haven’t looked at these exact blocks, but the point is that they were using tons of unsafe that they didn’t need to. Unsafe exists to be used, when it’s neccesary.

11 now? Iirc it was on the order of 100 before.

Re: Rust’s standard library was vulnerable for years and nobody noticed

#28
post #24

This article casually throws around definitions of 'memory safety' that are massively different. Rust's 'memory safety' guarantee is different from Go's 'memory safety'. Rust includes protection from things like modifying memory from 2 different spots at the same time, among other things. AFAIK that's perfectly fine to do in Go, you can pass around pointers between threads as much as you like. This sort of behaviour…

> I just really don't understand the criticism against Rust here

I think you are confusing two different narratives in the article: software development in general, and Rust the language/ecosystem/community.

The article raises many points about how the former as a whole does not care enough about security. How we do not have the right incentives to fix memory safety bugs (the bug bounty thing) nor treat them as the security risks that they are (the pushback from developers when you explain that something is a security issue).

That is the software industry in general though, not Rust.

There is also constructive criticism about how Rust handles these things and how it could do better. But it is clear that the author loves Rust for trying to find ways to fix this and how it aims to be a more secure and safe language. Note how the article is full of praise for how the Rust community responded to his feedback, and for the ambitions of the language.

EDIT: as I wrote in another comment, the main point regarding Rust is that "unsafe" by definition throws safety guarantees out the window, so to minimize the risks it brings, solutions outside of the language are needed (aside from hypothetical language improvements that reduce the need for unsafe, of course). This is easily forgotten in the hype about Rust's safety guarantees. Saying "but all languages screw this up in some way" is not really an excuse.

Re: Rust’s standard library was vulnerable for years and nobody noticed

#29
post #24

This article casually throws around definitions of 'memory safety' that are massively different. Rust's 'memory safety' guarantee is different from Go's 'memory safety'. Rust includes protection from things like modifying memory from 2 different spots at the same time, among other things. AFAIK that's perfectly fine to do in Go, you can pass around pointers between threads as much as you like. This sort of behaviour…

[deleted]

Re: Rust’s standard library was vulnerable for years and nobody noticed

#30
post #8

TLDR: presumably 2 y/o (10 Jul '15) segfault bug in stdlib was discovered, fixed and merged into master on the same day on 27 Sept '17. Next release was 12 Okt '17, 15 days later. OP argues the bug should have been filed into the CVE [0] so that people who run old versions of Rust know about it and can act accordingly. [0]: https://en.m.wikipedia.org/wiki/Common_Vulnerabilities_and_E... Personally I'd say running old…

The opposite is true: new vulnerabilities can be introduced in new feature releases, while older releases can receive backported security fixes.

That means that the level of security of a well maintained stable release train can only increase over time.

This is why Debian puts so much effort in freezing and baking the distribution and backporting security fixes.

Post reply on HN