News for hackers. Stuff that matters.
Re:Welcome to Comprehensive Rust by kibwen on Thursday December 22, 2022 @06:05AM (#34092159)
Since the ultimate objective is to run a binary blob that you just downloaded off of the internet, piping a script to your shell over HTTPS adds no additional attack surface.
Re:Welcome to Comprehensive Rust by ohbtvz on Thursday December 22, 2022 @06:39AM (#34092364)
You can't check the hash of something you immediately piping to your shell, for example.
Re:Welcome to Comprehensive Rust by kibwen on Thursday December 22, 2022 @06:52AM (#34092452)
Checking the hash isn't relevant here. The content is served via HTTPS, you either trust the host or you don't. A host can easily serve you a malicious binary, as well as the valid hash of that malicious binary.
Re:Welcome to Comprehensive Rust by jeroenhd on Thursday December 22, 2022 @06:58AM (#34092495)
Which is why many people choose to only install software from their trusted distro maintainers who add a layer of vetting for random software packages, often built from source so messing with the package isn't possible without leaving some kind of trace that can be detected later.
Re:Welcome to Comprehensive Rust by kibwen on Thursday December 22, 2022 @07:05AM (#34092521)
Indeed, by all means, prefer to trust your distro if they package a version that's new enough. Alternatively, prefer to build from source if you like. But if you trust the Rust project to be competent enough and benign enough not to include malware in the compiler itself, then it's not a stretch to trust their official toolchain juggling tool downloaded from their official website. Focusing on the curl | bash aspect is a tired meme at this point.
Re:Welcome to Comprehensive Rust by pornel on Thursday December 22, 2022 @09:02AM (#34093291)
Your distro's overworked maintainer isn't reviewing 15+ million lines of code included in Rust.

Most likely they get the precompiled rustc binary just like rustup, and LGTM-YOLO the package. If they try to be diligent, they maybe take extra 150K lines of mrustc code they can't reasonably carefully review for backdoors either, and then use it to bootstrap the several sets of 15M lines of code they won't look at.

Re:Welcome to Comprehensive Rust by jeremyjh on Thursday December 22, 2022 @09:26AM (#34093544)
The one thing you may get in using your distribution is protection for the case that the rustup.sh website has been temporarily pwned. But I agree that focusing on curl | sh is nonsense.
Re:Welcome to Comprehensive Rust by posterboy on Thursday December 22, 2022 @09:04AM (#34093316)
Checking is the only reason that hashes are provided.
Re:Welcome to Comprehensive Rust by gpderetta on Thursday December 22, 2022 @09:52AM (#34093823)
you might have another known-good source of the hash.
Re:Welcome to Comprehensive Rust by mhoad on Thursday December 22, 2022 @06:23AM (#34092276)
I get what you are trying to say here but I could also make the argument that you actually doubled it because now you have to trust two things rather than one.

Depending on how you want to consider trust in a wider sense too it may even be worse than “double” because I do not have the same amount of trust for the package I am ultimately installing and the script I am using to install it.

Re:Welcome to Comprehensive Rust by kibwen on Thursday December 22, 2022 @06:55AM (#34092479)
> now you have to trust two things rather than one

No, you're still trusting one thing: the host itself. You're downloading both the script and the binary from the host. Both could be backdoored, and of the two, the binary is far easier to hide a backdoor in.

As for not trusting curl, you still need to fetch the resource somehow, so you're going to be trusting some tool to do it for you. That's not relevant to increasing the attack surface.

Re:Welcome to Comprehensive Rust by mhoad on Thursday December 22, 2022 @07:02AM (#34092507)
I’m not actually in the Rust ecosystem at all and only just discovered the domain belongs to the official Rust project.

That clearly changes the trust calculation in this scenario.

I had assumed it was some 3rd party project which would have put it in a different category of problems entirely.

But the entire conversation is kind of pointless then. “There is a secret backdoor in the official Rust binary” is not a useful part of any reasonable threat model.

Re:Welcome to Comprehensive Rust by Someone on Thursday December 22, 2022 @09:58AM (#34093903)
> You're downloading both the script and the binary from the host.

Technically, if you don’t read the script, you don’t know the binary is from the same host.

That doesn’t matter, though. The chain of trust is deep, including the tooling that produced the binary, your CPU, the internet, etc.

Downloading the first file basically says “I trust this site to give me this tool and nothing else”. Where it then gets that stuff from shouldn’t matter, even if it is from a shady site. You trusted them not to do that, just as you trusted them not to open up their own site so that hackers can replace files ont it.

Re:Welcome to Comprehensive Rust by jjgreen on Thursday December 22, 2022 @06:31AM (#34092322)
Actually no, one can detect curl-piping server-side and serve hostile blobs only to those foolish enough to do so: https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-b...
Re:Welcome to Comprehensive Rust by Arnavion on Thursday December 22, 2022 @06:35AM (#34092344)
And kibwen's point is that if you're in a situation where you're running potentially hostile binaries from a remote host, the fact that you used `curl | sh` to obtain said binary is not the pressing problem.
Re:Welcome to Comprehensive Rust by kibwen on Thursday December 22, 2022 @06:59AM (#34092500)
I'm well aware of that attack, it's quite cute, but if you don't trust the host not to serve you a backdoored binary then you've already lost.
Re:Welcome to Comprehensive Rust by jjgreen on Thursday December 22, 2022 @07:38AM (#34092701)
And where is this trust supposed to come from? I downloaded the thing manually, looked at the scripts, ran the binary in a sandbox, it seemed to be OK. Right, I'll recommend that everyone just curl | bash's it ...

I think the worst thing about this is that Rust is fashionable, so encouraging inexperienced devs think that these dangerous practices are just fine. Look around at how many n00b projects now suggest doing exactly the same thing. It's simply irresponsible of the Rust crowd to keep promoting it.

Re:Welcome to Comprehensive Rust by pornel on Thursday December 22, 2022 @08:52AM (#34093199)
The bash timing exploit makes everyone focus just on how cleverly evil it can be, and forget the big picture that it's about trusting the Rust org not to screw you.

(BTW, you can run `curl | sh` in a VM or with a modified bash to intercept the code and catch the bash script in the act, so it's not actually as sneaky as people believe).

If you think the Rust org is going to pwn you in a clever sneaky way, then you can't use Rust or any Rust-containing products.

In the end, you're pulling hundreds of MBs of binaries that you won't review, they're compiled from over 15 million lines of code that I don't believe you'd ever review either. Reviewing just the first 10 lines of code gives you nothing. A smoke test in a sandbox is also worthless, since a binary could detect being run that way, or delay the attack, or attack by specifically miscompiling your code (see Reflections on Trusting Trust).

In the end, you have to trust the Rust org, all of it.

Re:Welcome to Comprehensive Rust by fulafel on Thursday December 22, 2022 @10:15AM (#34094099)
"Trusting the Rust org not to screw you" is one part, another part is trusting the Rust server operators to defend against server compromise by any third party. So trusting the intentions is not sufficient.
Re:Welcome to Comprehensive Rust by haradion on Thursday December 22, 2022 @11:33AM (#34095170)
The same thing applies to any binaries downloaded from their site, so unless you you've got signed binaries (that use an independently obtained/verified chain of trust), trusting the server is your your only option. Even with signed binaries, you're still trusting the entity that holds the signing key.
Re:Welcome to Comprehensive Rust by fulafel on Thursday December 22, 2022 @12:11PM (#34095697)
In real world trust is not so binary. In a risk assessment I'd be interested evaluating the level of assurance there is in the supply chain of how you get your binaries and artifacts. Some of it can be done using crypto like you say, some of it could be eg published audit reports from a reputable evaluator or other credible information about the processes.
Re:Welcome to Comprehensive Rust by carapace on Thursday December 22, 2022 @10:19AM (#34094158)
I call this the "Lie back and think of England" stance.

You're not wrong, until the end, it should be: "you have to distrust the Rust org, all of it."

And not just Rust, Python and JS and all the others. There are languages and systems that take trust and security seriously, but these are not they.

Re:Welcome to Comprehensive Rust by Thiez on Friday December 23, 2022 @01:34PM (#34109135)
Pray tell us, which languages do take trust and security seriously, according to you?
Re:Welcome to Comprehensive Rust by carapace on Friday December 23, 2022 @02:26PM (#34109676)
(Is it that you don't know of any yourself? Or that you think I can't provide examples? In what world is what I said even slightly controversial? Type checking is just catching on now, decades after it was invented and implemented. C'mon.)

Anyway, off the top of my head, Ada.

https://en.wikipedia.org/wiki/Ada_(programming_language)

and E...

https://en.wikipedia.org/wiki/E_(programming_language) https://en.wikipedia.org/wiki/CapROS

Qubes and SEL4 are Operating systems. (OK Labs was acquired by General Dynamics. That seems like a pretty good recommendation to me.)

https://en.wikipedia.org/wiki/Qubes_OS

https://en.wikipedia.org/wiki/L4_microkernel_family#High_ass...

Re:Welcome to Comprehensive Rust by insanitybit on Thursday December 22, 2022 @10:09AM (#34094024)
Changing nothing about the relative security of using curl | sh.
Re:Welcome to Comprehensive Rust by slim on Thursday December 22, 2022 @03:20PM (#34098110)
also by doing that you don't keep a copy of the script for investigation if something smells fishy later
Re:Welcome to Comprehensive Rust by sofixa on Thursday December 22, 2022 @06:54AM (#34092469)
You meant a binary blob in your distro's repository, so one that was checked, tested, approved and verified with a hash. Which is wildly different than downloading and running random binaries or scripts for that matter off the internet.
Re:Welcome to Comprehensive Rust by kibwen on Thursday December 22, 2022 @07:07AM (#34092529)
No, it's hardly random, it's an official binary provided the Rust project from an official domain managed by the Rust project. If you don't trust it, then you shouldn't trust the Rust source code either.
Re:Welcome to Comprehensive Rust by yencabulator on Thursday December 22, 2022 @04:05PM (#34098671)
In this case, the Google internal course explicitly does not trust that random shell script, even if it came from rust-lang.org, while their internal apt repository is trusted. See https://news.ycombinator.com/item?id=34092187
Re:Welcome to Comprehensive Rust by vbezhenar on Thursday December 22, 2022 @10:35AM (#34094366)
When I'm installing package from the repository, it's signed with GPG. Hopefully in a more secure place than WWW server. May be even at offline server with HSM (one can hope!). When I'm running code downloaded from HTTPS, all it takes is compromising this WWW server (or AWS Cloufront for this particular sh.rustup.rs example). HTTPS adds additional attack surface.
Re:Welcome to Comprehensive Rust by gernb on Thursday December 22, 2022 @11:51AM (#34095427)
piping to the shell might be somewhere in the middle but node's npx is just asking for trouble. You type `npx cmd` and it downloads cmd. Which means any typo could be death