News for hackers. Stuff that matters.
Re:“Curl Bash piping” wall of shame by eridius on Friday October 21, 2016 @08:48PM (#12766260)
This page is completely wrong.

`curl | sh` is insecure if you're using an http url, although as has already been said here, it's not really any more insecure than "download this script and run it", unless you're expecting all of your users to actually read through the whole script first. But if you're using an https url then you should be ok since the page cannot be hijacked or modified en route (unless the attacker actually has a trusted certificate for the domain, which is an attack that's way out of scope of this discussion).

The biggest risk with this approach, which the page doesn't even mention, is the danger of the connection being terminated before the whole script is downloaded, as the shell will still evaluate what was sent. But this can be handled in the script by making sure that an early EOF means nothing is actually run (e.g. you can wrap the whole script in a bash function, and then the last line executes the function).

So if you're using an https url, and the script is written to be resilient against early termination, then this is a perfectly reasonable way to install things.

Re:“Curl Bash piping” wall of shame by btgeekboy on Friday October 21, 2016 @08:59PM (#12766312)
There's a few subtle differences you haven't mentioned:

1) If you attempt to read the script in your browser first, and everything's great, then go pipe to bash, the server can send alternate content based on your user agent.

2) You'd have a hard time proving the first point, or reviewing to see if a script acted poorly, if you didn't have a local copy, which piping to a shell like this normally prevents you from doing.

Re:“Curl Bash piping” wall of shame by chrismonsanto on Friday October 21, 2016 @09:10PM (#12766368)
> If you attempt to read the script in your browser first, and everything's great, then go pipe to bash, the server can send alternate content based on your user agent.

If you can't trust the site to give you a safe installer then you can't trust the rest of the sources it gives you either--you would need to audit the entire package. Virtually nobody is going to do that. Singling out the installer as uniquely dangerous is security theater.

Re:“Curl Bash piping” wall of shame by seanp2k2 on Saturday October 22, 2016 @02:21AM (#12767508)
Windows and OSX also do this and present pointless non-defeatable "omg but this is from the scary internet, are you SURE you want to run it????"
Re:“Curl Bash piping” wall of shame by thedudemabry on Saturday October 22, 2016 @04:22AM (#12767790)
To be fair, those have been very effective in keeping my non-techie family members from accidentally installing malware because they'll at least check with me when presented with a scary system dialog. And it hasn't impacted my own use other than the occasional extra clicks. In a locked-down corporate setting, I can see how that could be maddening, though.
Re:“Curl Bash piping” wall of shame by inimino on Saturday October 22, 2016 @05:10AM (#12767944)
That's for the benefit of people who don't really realize that installing software from the internet is dangerous (i.e. most users). This discussion is about safe methods once you have decided to install something from the internet, which is different.
Re:“Curl Bash piping” wall of shame by 0xcde4c3db on Friday October 21, 2016 @10:53PM (#12766849)
> 1) If you attempt to read the script in your browser first, and everything's great, then go pipe to bash, the server can send alternate content based on your user agent.

I'm having trouble finding a proper source, but I'm pretty sure someone came up with a way to do it even if curl spoofs the user agent. I think it worked by looking for the characteristic timing pattern of bash emptying the pipe in small bursts as it executes the individual script lines.

Re:“Curl Bash piping” wall of shame by samdg on Saturday October 22, 2016 @01:38AM (#12767384)
I think this is what you are looking for: https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-b...
Re:“Curl Bash piping” wall of shame by yeahbutbut on Friday October 21, 2016 @10:58PM (#12766870)
> If you attempt to read the script in your browser first, and everything's great, then go pipe to bash, the server can send alternate content based on your user agent.

curl | less

Or copy the request "as curl" from the network tab of any modern browser.

Re:“Curl Bash piping” wall of shame by matt4711 on Friday October 21, 2016 @08:57PM (#12766306)
There was a post on HN a while ago where somebody wrote a server side tool which can detect curl -> bash piping and delivered different content if that happens.
Re:“Curl Bash piping” wall of shame by arcticfox on Friday October 21, 2016 @09:04PM (#12766345)
Sure, but how is that any less secure than other installation alternatives? As the site owner, I could swap out a valid package for a troll package at any moment to any subset of users I wanted to if they're not validating the contents of it...
Re:“Curl Bash piping” wall of shame by dredmorbius on Saturday October 22, 2016 @01:41AM (#12767398)
You can't change the contents on a user's local storage that they've verified.

Curlbash lets you change out offerings at will, and leaves no auditable source for the user.

Re:“Curl Bash piping” wall of shame by fabrice_d on Friday October 21, 2016 @08:55PM (#12766297)
That is true, but that doesn't protect you from the server being hacked and the script replaced by a malicious one.

If you execute unsigned code from a 3rd party without sandboxing, transport encrytion doesn't help you much.

Re:“Curl Bash piping” wall of shame by laurentdc on Friday October 21, 2016 @08:58PM (#12766310)
The website could be compromised though, and you'd have no reliable checksum to compare against (unlike a proper repository).

Similarly to what happened to e.g. https://transmissionbt.com/keydnap_qa/ or http://www.classicshell.net/forum/viewtopic.php?t=6441

Re:“Curl Bash piping” wall of shame by eridius on Friday October 21, 2016 @09:00PM (#12766324)
This is not a risk inherent to `curl | sh`, it's a risk that you run any time you download software from anywhere that doesn't have a signature using a key that you've already previously verified as trustworthy.
Re:“Curl Bash piping” wall of shame by falcolas on Friday October 21, 2016 @11:01PM (#12766880)
Which is why most package managers for installling software use signatures. .msi, .deb, .app, .rpm... all provide methods for signing code, and can refuse to install code without signatures or improper signatures.
Re:“Curl Bash piping” wall of shame by eridius on Saturday October 22, 2016 @02:03AM (#12767461)
`curl | sh` isn't used as an alternative to package managers, it's used as an alternative to "download this script and run it".
Re:“Curl Bash piping” wall of shame by falcolas on Saturday October 22, 2016 @10:32AM (#12768811)
`curl | sh` is not an alternative; it is exactly download this script and run it. The problem is "to what end". Most of the time, the script being run is installing software. Be it Docker, Prometheus, homebrew, or otherwise, the entire purpose of most of these scripts is to install software.

So, why not just install using a package manager that takes some actual security precautions?

The answer is, most of the time, that software developers are either "moving too fast" (docker is guilty of this, but at least they are using the underlying package manager) or more often are just too lazy to provide packages through authenticated channels.

Re:“Curl Bash piping” wall of shame by jjnoakes on Saturday October 22, 2016 @09:12AM (#12768549)
Not sure why you are being downvoted, you are completely correct.
Re:“Curl Bash piping” wall of shame by nodesocket on Friday October 21, 2016 @08:52PM (#12766274)
Perfect answer. Wrapping the entire script in a function is a clever idea to protect against connection drops as well.
Re:“Curl Bash piping” wall of shame by falcolas on Saturday October 22, 2016 @10:56AM (#12768907)
> if you're using an https url then you should be ok

You're trusting the server in this case, not the contents being provided by the server. There's no way to verify that the contents attributed to eridius on github are the same contents that eridius actually put up there.

Github in particular has been shown to have problems with spoofed users.

Let's go one step further. I have a `curl | sh` script for you to execute to install Docker. Just run:

    curl -fsSL https://get.docker.com/ | sh
Oops. That was actually get.rekcod.com, with a RTL unicode character embedded. Or a unicode C which doesn't map to the ascii 'c'. Or I am able to mitm and strip the TLS. Or...

The vulnerabilities go on and on. Using only HTTPS, you have no way to prove that the code you got from get.docker.com is the code that the docker engineers intended for you to use.