Re:Show HN: "curl … | sh" is bad.
by mukyu on Friday April 08, 2011 @12:40PM
(#2424551)
I was looking for something in the shell script that was nefarious rather than the obvious "explicitly downloading and running things is a bad idea".
A good example of the fake downloads can be found with people running ads for VLC that link to their malware/adware invested versions (presumably, I've never actually bothered to investigate them).
Re:Show HN: "curl … | sh" is bad.
by rhymeswithcycle on Friday April 08, 2011 @12:49PM
(#2424593)
... if you're getting the checksum from a trusted source that is separate from the package distribution server, or if the checksum is cryptographically signed.
But I've never seen people get up in arms about someone publishing, say, a github link to some code that isn't accompanied by a checksum signed with a published PGP key you deem trustworthy.
Re:Show HN: "curl … | sh" is bad.
by tlrobinson on Friday April 08, 2011 @06:31PM
(#2425853)
And what's the first thing people do after cloning a project they want to try out? Some might read all of the code, most will just run "./configure" or "make" or "rake" or "script/server" or whatever. All of which can execute arbitrary code.
Piping a file to a shell isn't inherently less secure than downloading a zip or cloning a repo and blindly executing something from it.
I'm willing to bet the majority of people who are complaining about the "curl URL | sh" trick also regularly download and execute code without verifying it won't own them.
Re:Show HN: "curl … | sh" is bad.
by tlrobinson on Friday April 08, 2011 @12:21PM
(#2424470)
Do you inspect the source code of every program you download? Do you decompile and reverse engineer the closed source ones? At some point you have to trust the developer isn't doing anything nasty, and be careful about where you get your software from.
Re:Show HN: "curl … | sh" is bad.
by jcapote on Friday April 08, 2011 @12:35PM
(#2424526)
This argument is not about trusting or not trusting code. It's about piping web output blindly into a shell, which is an insecure technique, no matter how much you trust the author or web site.
Re:Show HN: "curl … | sh" is bad.
by jcapote on Friday April 08, 2011 @12:14PM
(#2424419)
The "hack" is when someone roots their server and makes it return "rm -rf ~". Even if it's the most secure server ever, it's still a bad technique, IMO.
Re:Show HN: "curl … | sh" is bad.
by michh on Friday April 08, 2011 @01:50PM
(#2424889)
If they're distributing .dmgs or .exes and their server gets rooted the result is exactly the same.
And if the download and webpage are hosted on the same machine (like, practically always) the checksum won't help you either.
If you want to run third-party stuff and not willing to look at every little assembly instruction at one point you're going to have to trust somebody.
Of course this can just be Apple (app store) or the Debian/insert-distro-here guys (only run code that's from apt packages from the official repositories).
Re:Show HN: "curl … | sh" is bad.
by astrodust on Friday April 08, 2011 @01:25PM
(#2424773)
This is not a counter-argument. You can't read every line of code that this will run every single time you go to run it. Unless you're very skilled and focused, you may miss a hack that's been cleverly disguised.
Executing a `rm -rf /` is not hard to do, and you wouldn't even see that text in a program. Basically you're depending on the statistical probability that if there is a hack, someone else will get hit before you and it can be identified and resolved before everyone is affected. Someone has to take one for the herd.
(edit: Oh. You're doing user-agent sniffing for curl. Fair enough, but this still isn't any less secure than downloading and executing a binary.)
A good example of the fake downloads can be found with people running ads for VLC that link to their malware/adware invested versions (presumably, I've never actually bothered to investigate them).
But I've never seen people get up in arms about someone publishing, say, a github link to some code that isn't accompanied by a checksum signed with a published PGP key you deem trustworthy.
Piping a file to a shell isn't inherently less secure than downloading a zip or cloning a repo and blindly executing something from it.
I'm willing to bet the majority of people who are complaining about the "curl URL | sh" trick also regularly download and execute code without verifying it won't own them.
if people catch on to that and start checking with curl first, you could even serve the friendly content the first time someone fetches it with curl.
It's not.
Yes, the user-agent sniffing is clever, but it's circumventing a security precaution that isn't even possible with a binary installer.
More discussion here: http://news.ycombinator.com/item?id=2420648
It's harmless to run.
And if the download and webpage are hosted on the same machine (like, practically always) the checksum won't help you either.
If you want to run third-party stuff and not willing to look at every little assembly instruction at one point you're going to have to trust somebody.
Of course this can just be Apple (app store) or the Debian/insert-distro-here guys (only run code that's from apt packages from the official repositories).
I'll just take the occasional risk.
Executing a `rm -rf /` is not hard to do, and you wouldn't even see that text in a program. Basically you're depending on the statistical probability that if there is a hack, someone else will get hit before you and it can be identified and resolved before everyone is affected. Someone has to take one for the herd.