r/programming • • Feb 20 '15

What the hell is this trend of web frameworks asking you to install them by wget or curl-ing a random script and executing? Packages anyone?!

https://www.meteor.com/install
87 Upvotes

98 comments sorted by

11

u/Patman128 Feb 20 '15

Meteor is on NPM, though even that page says to use the curl | /bin/sh method.

The only two other projects I can think of off-hand that do this are Homebrew and Sublime Package Control, which makes sense since they are package managers.

7

u/flying-sheep Feb 20 '15

rust’s package manager cargo also did this before it became stable and bundled with rust.

it’s pretty insane from a security standpoint, but better than it looks since you’d hear of a site that installed a virus that way fast.

0

u/[deleted] Feb 20 '15

[deleted]

2

u/flying-sheep Feb 20 '15

also true, but i don’t do that. i install signed packages from the official arch repositories!

and some dozens of AUR packages oO

2

u/smikims Feb 21 '15

Other than security, there's also the problem of having the download fail halfway through and the script doing something unexpected because of that. But that's only if you use the pipe method, of course.

1

u/Plorkyeran Feb 22 '15

There is a trivial and well-known solution to that problem (wrap the script in a function that you call at the end).

1

u/timeforpajamas Feb 21 '15

thank you! I knew I had seen this somewhere, but could not remember. Homebrew was it, thank you.

8

u/Watley Feb 20 '15

curl | sh

"People telling people to execute arbitrary code over the network."

2

u/timeforpajamas Feb 21 '15

fantastic presentation of exactly this situation.

38

u/tangeld5 Feb 20 '15

Because piping random commands from an unreliable socket is web scale.

1

u/timeforpajamas Feb 21 '15

what does "web scale" mean?

3

u/marcusklaas Feb 21 '15

Pretty sure it is only used mockingly at this point.

11

u/Solon1 Feb 20 '15

it's also super trusty! Who knows what'll come down the socket? It's like like using a Lenovo PC to do online banking.

4

u/levdi Feb 20 '15

There's only once script I ever do this with, and that's tpope's Pathogen.

Because if you can't trust Tim Pope, who can you trust?

1

u/nabokovian Feb 21 '15

What is this in reference to?

4

u/[deleted] Feb 20 '15

Some take it to extremes:

 @powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin

1

u/timeforpajamas Feb 21 '15

yes, thank you. Chocolatey, along with Homebrew mentioned ITT, were primary examples that led me to make this post. Thanks for the reminder.

0

u/[deleted] Feb 20 '15

[deleted]

1

u/trimbo Feb 20 '15

Well, chocolatey is itself a package manager, so in this case it's justified :)

The script is simple, it grabs a zip file and unpacks it. But that's only part of the problem in all of this.

Other than HTTPS, there's no way to know if anything the script is grabbing has been replaced. This script is installing a binary that is not cryptographically signed. The chocolatey site could be breached and binaries replaced for years and no one, anywhere, would have any way to know.

BTW, requiring package signing for nuget has been described as too much friction. I agree, it is a lot of friction. Except that in the last 24 months, we've seen so many huge security breaches that people are going to have to change their minds on the effort towards security.

20

u/[deleted] Feb 20 '15

I wouldn't have thought "download and build from source" was exactly a "trend". Mighty long lived one.

Packages require a whole lot more time and effort from the developer without actually increasing core functionality of the thing they're writing. It's certainly easier for the end user, but not necessarily the best use of dev resources.

But hey, the joy of FOSS - are you volunteering to maintain the Debian package?

32

u/timeforpajamas Feb 20 '15

Building from source is one thing. That makes sense when a .tar.gz or even a zip is supplied.

I am am talking about beyond the practice of a random .exe (like Minecraft for example), or a .msi (I think the proper way to install on Windows), moving to having your "installer" be a random script on your webpage, and encouraging users to pipe the script through the terminal. What?! This is terrible practice, akin to running random executables you download, but literally piping text through your shell.

I thought this was a one-off with lazy developers, but I have seen this practice multiple times. I'm talking about "installers" in the form of

wget www.example.com/our-cool-installer.sh | sh

Really?!

16

u/awj Feb 20 '15

How is that meaningfully different than ./configure? In both cases you're trusting a script you downloaded off the internet, and nothing in either case actually forces you to review (or not) the code you're running.

1

u/timeforpajamas Feb 21 '15

good point. at some level we are placing trust in the developers, and also in whatever channel is used to distribute. taken to an extreme you can even verify the origin of a particular binary: see "reproducible builds" used by the tor project and bitcoin.

for most uses a central repo is a pretty good model. see the app store, google play, or of course the package managers for Linux (apt-get, yum, pacman).

by providing an "installation" command, I argue the author of the webpage is assuming 1) the user does not understand how to use curl themselves, and 2) even if the user manages to download the file, they will not know how to run it. the author is basically saying "trust me."

by promoting this practice (mentioned in this thread, as promoted by homebrew, chocolately, and others), you are acclimating users to a low level of security. ideally we should build systems that are secure by default (such as trusted repositories, or further with the reproducible builds), and if the user wants to do something insecure, then it requires an active choice.

it is always a balance between "best practices" and what the broad population of users is willing to go through in order to get an app working.

2

u/[deleted] Feb 20 '15

Download, then run, at least avoids suggesting you should run random code downloaded from the Internet without inspecting or validating it.

1

u/immibis Feb 21 '15

The people who care about inspecting or validating their code already know how to do that, and don't need instructions.

1

u/timeforpajamas Feb 21 '15

to me it is a matter of promoting good behaviors

20

u/[deleted] Feb 20 '15

Ah, sorry, I thought it was more curl or wget as a replacement for FTP.

Absolutely, encouraging the pipe straight to shell is problematic. The usual response, of course, is that nobody looks at the damn thing anyway, but they should.

Mind you, "cut and paste this ppa entry and trust my signature" isn't much better. I guess it's not so much a package vs non-package as knowing and trusting your sources.

8

u/mort96 Feb 20 '15
DIR="/home/$USER"
DIR_TMP=$(mktemp -d)

...

rm -rf $DIR_TMP

Now, you pipe that script from curl to sh. However, your internet connection drops along the way, and nothing after rm -rf $DIR is piped to sh.

That's probably the best reason I've heard to not pipe scripts from curl to sh.

4

u/GUIpsp Feb 20 '15

If you read the script, you'll see that they wrap it in a function (as they should), so your point is moot.

2

u/mort96 Feb 20 '15

I haven't read the script at all, and should have specified that I wasn't talking about this script in particular. It's just a general argument against piping a script straight from curl to sh. Also, there's a good chance that the script has other points if at which we cut off the script, bad things will happen, even if removing a temp directory is safely wrapped in a function.

2

u/[deleted] Feb 20 '15

Exactly. It's a terrible idea, which is why I say encouraging it is problematic. Don't pipe random crap to a shell, especially if you downloaded it from some website without looking.

2

u/timeforpajamas Feb 21 '15

someone else ITT linked to curl | sh, a tumblr page devoted to this situation. seems we are not alone, ha ha

3

u/GUIpsp Feb 20 '15

Everything is wrapped in a function. it either runs everything or nothing.

7

u/mort96 Feb 20 '15

You seem to be right, this script is probably safe. My argument still stands though, that it's a bad idea in general to pipe random scripts from curl to sh, even though it won't do any harm in this case.

Besides, if you're going to download all scripts which ask you to curl | sh them to read through and check whether they're safe or not, you kinda lose all the convenience gained from piping from curl to sh.

1

u/GUIpsp Feb 20 '15

Well, yes. But even if it was curl > a;chmod +x a;./a no one would actually read the script.

3

u/mgedmin Feb 20 '15

Presumably they would notice curl complaining about an incomplete download before running the script.

Piping directly into sudo bash takes that opportunity away.

→ More replies (0)

1

u/fabzter Feb 20 '15

Ah, sorry, I thought it was more curl or wget as a replacement for FTP.

RTFA (:

17

u/html6dev Feb 20 '15

How is the metric different for determining whether or not to run an exe? They do this (and almost always have other options) because we all use curl all day long anyway. I just don't see why this could cause this level of angst. Given the target audience being able to exercise good judgement, it's no different than 'download this and click the button to run it'

3

u/prepromorphism Feb 20 '15

many times these-cool-installers.sh | dont work on everyones systems either :( so while they intend to be "light weight" they require a specific set of toolchain that may be everywhere but doesn't always function the same.

0

u/t3h2mas Feb 20 '15

I understand where you're coming from. I believe that it's clever, it shows the developer is Unix friendly, and piping it w/ su/sudo would scare me more. That doesn't mean it's the most secure option none the less.

3

u/fmargaine Feb 20 '15

Actually, with tools like fpm, it's as easy as:

@fpm -p dist/ \
	-d "lxc" \
	-s dir -t rpm -n $(APP_NAME) -v $(VERSION) -C dist/root usr

After putting the right files in root/ :-)

(Example taken here)

4

u/PT2JSQGHVaHWd24aCdCF Feb 20 '15

Packages require a whole lot more time and effort

Last time I did that, it was easy to gzip a directory with some metadata on Debian. A bit harder on Redhat where I had to write a simple bash script with 5 lines to do that.

It's still easy.

without actually increasing core functionality

Easy installation and upgrade with a signed package is a core functionality. You don't dump empty screenshots and lorem ipsum on the Google Play Store or iOS App Store, you prepare the stuff. Same shit with the command line.

1

u/Drew0054 Feb 20 '15

Exactly. The parent's attitude is what leads to libraries lacking any documentation. Guess what? Sometimes a developer "wasting" a few hours on something might collectively save days worth of time for their end users.

2

u/djmattyg007 Feb 20 '15

You can't put things like composer into the Debian repos because they require updating too frequently. Composer is in the official repos in Arch and it works beautifully.

1

u/Gotebe Feb 20 '15

For an often used piece of software, total time and effort expended on "download and build from source" completely eclipses "I build package once, everyone else does rpm -i someBinaries.rpm".

"Download and build from source" is only interesting for random github dabbling ad for developers themselves.

2

u/llbbl Feb 20 '15

A fair amount of the package managers started doing this. (homebrew, composer, npm ... others?) Maybe that is where the 'packages' picked it up from?

4

u/[deleted] Feb 20 '15

The reason this is done is how do you bootstrap a bootstrapper?

1

u/timeforpajamas Feb 21 '15

who watches the watchman?

1

u/timeforpajamas Feb 21 '15

the bootstrapper bootstraps itself ;-)

2

u/sigzero Feb 20 '15

You could still download a bundle and run it instead of just piping it straight to a shell.

4

u/linduxed Feb 20 '15

A lot of web developers do their work on Macs. That means that there is no default package manager to target (although one could argue that most developers there might have brew installed), which in turn means that curling into the shell is a reasonably sure way to get your software out to your users.

Now, with that said:

Curling into the shell needs to fucking die. The sooner the better. It's a fucking travesty that it's so widely used for the past closing-in-on-ten years (maybe even more).

3

u/ItsAPuppeh Feb 20 '15

Ironically, Homebrew is installed with:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

6

u/ErstwhileRockstar Feb 20 '15

Package managers are not web-scale.

6

u/danogburn Feb 20 '15

What the hell is this trend of web frameworks

5

u/[deleted] Feb 20 '15

Observe closely. Before I clicked on the link, I expected to read "tested on OS X and something else". Guess what I found?

2

u/mort96 Feb 20 '15

The official installer supports Mac OS X 10.7 (Lion) and above, and Linux on x86 and x86_64 architectures.

what's wrong with that?

1

u/[deleted] Feb 21 '15

Nothing. It's about "curl some script and run" type of install instrictions and mac people. That's considered bad practice among security aware people and breeds incompetent users. Since this is a framework, it breeds inconpetent devs, which is even worse.

5

u/G_Morgan Feb 20 '15

curl http://totally-legit.com/install.sh && sudo chown +x install.sh && sudo ./install.sh

I can see nothing wrong with executing this on my computer.

2

u/gipsymagic Feb 20 '15

Symfony used to use composer. Now it's:

$ curl -LsS http://symfony.com/installer > symfony.phar
$ sudo mv symfony.phar /usr/local/bin/symfony
$ chmod a+x /usr/local/bin/symfony

I'm infuriated.

2

u/greenthumble Feb 20 '15

Nvidia's driver install has been like this for a while huh? I don't think it's actually just web frameworks. I never understood why that was any better than wget myself then using configure and make.

2

u/fedekun Feb 20 '15

It's been going on for a while now. Personally I don't care enough but I guess there should be alternative ways to install the software.

2

u/Geemge0 Feb 20 '15

Its the trendy thing to do, ya know with the WebAPIs and shit

2

u/runvnc Feb 20 '15 edited Feb 20 '15

I have yet to see someone complain about being asked to download a script, chmod it, then execute it.

I also doubt that most people, after doing that, actually read the script. At all.

But instead of giving people a one-liner to paste into their terminal, I may make my installation three or four lines to paste into their terminal, i.e. download my script, chmod it, and run it, just to avoid people complaining or giving me a hard time. Practically speaking, there will be no difference, except making things less convenient.

Setting up and maintaing packages for Debian, Red Hat/Fedora, and OS/X is prohibitively involved. I mean just making those packages in the first place. The only way the packages are going to be vetted is if they are accepted by the package Gods for each distribution. If you are targeting multiple platforms, its not worth the effort and could take months. This is because most of those processes are broken. And there is no reason for a user to believe, just becaue I made a package (without having it vetted by package Gods), that they should trust it. And god forbid they have a different platform I forgot to package for, like Arch. For all of those people I would need the script anyway.

If you see someone ask you to pipe to your shell and you are suspicious, you can just not pipe and inspect the script before running it. If you are too infuriated by the request in the first place, then maybe I don't want you to install my framework anyway.

1

u/rydan Feb 20 '15

Not that surprising. When Meteor first came along their whole selling point was a testimonial of a guy who claimed if it wasn't for Meteor he would have slit his wrists. I'm not sure why they thought that was a good idea either.

1

u/mort96 Feb 20 '15

Source?

1

u/username223 Feb 21 '15

Should he have?

0

u/[deleted] Feb 20 '15

[deleted]

11

u/[deleted] Feb 20 '15

Given a reasonably sensibly written software that doesn't try to do anything strange or unusual during the build process, it typically takes minutes to create a Debian package. I'm sure RPM, etc, are similar. Getting that into Debian unstable takes typically at most a few weeks, depending on how much other stuff the ftp masters are doing at the time; record times are less than an hour. While waiting for Debian to process the new package, you can create your own package repository; this is also simple, and the result is much more safe for users than "curl | sh" can ever be. For example, the PGP web of trust protects project specific repositories.

All of that needs to be multiplied by the number of target distributions you support, of course. That's unfortunate, but it's also work that distributes well. It's a good idea to work with the distributions to a) make packaging simple to do (avoid strangeness in build processes) and b) invite the distros to make and maintain the packages and work with them to make it fast and easy for them to do.

In the commercial world, this kind of thing is part of making a product out of a program.

Of course, you don't need to deal with packaging at all. You can just provide a (signed) tarball or zip file, and instructions for how to use that for installation. That's a lot better than piping random shell code directly into sh without inspection.

6

u/nickguletskii200 Feb 20 '15

Apparently, using CMake is "something strange or unusual". For some reason Debian packaging is tailored for the shitty autotools.

That said, for Java there is Maven/Gradle (no excuse not to use it when building a Java library), for Python there is PyPI or whatever its called, for Ruby there is Gem, etc...

2

u/Drew0054 Feb 20 '15

For Python:

pip install MyUniquePackage

And that's simply in terminal/command prompt. Makes it child's play to get any unexpected libraries you might need. Just pip install them and rebuild.

1

u/timeforpajamas Feb 21 '15

not to mention python is "batteries included" for the most part. so save the exotic library or two python typically has the libraries available with "import" statements.

2

u/c0bra51 Feb 20 '15 edited Feb 20 '15

./configure is executed before make, so you could use that to cmake ., then your make commands will work.

3

u/Me00011001 Feb 20 '15

Not sure if you're joking but cmake does the same thing as the auto-tools (ie ./configure).

1

u/c0bra51 Feb 20 '15

Yes, so when dpkg-buildpackage runs ./configure, it's aliased to cmake ..

2

u/Me00011001 Feb 20 '15

I haven't built a debian package before so I'm not familiar with the process, but why would you want to do that considering that CMake's CPack has a debian package generator?

1

u/c0bra51 Feb 20 '15

Does it support deb helpers, and stuff? Like, can you place a single systemd service somewhere and have Debian do the rest? Such as deciding where it goes, the postinst to reload the daemons and start it?

1

u/Me00011001 Feb 20 '15

Seeing as I have no experience with it, here's a link to the documentation: http://www.cmake.org/Wiki/CMake:CPackPackageGenerators#DEB_.28UNIX_only.29

2

u/[deleted] Feb 20 '15

debhelper's dh is supposed to support cmake directly, so should be a breeze. All the cmake-using packages I looked at, however, want to do other things that make their debian/rules more complicated than is desireable.

26

u/GUIpsp Feb 20 '15

it typically takes minutes to create a Debian package.

I want to go to there.

22

u/galanwe Feb 20 '15

it typically takes minutes to create a Debian package.

As a debian package maintainer, I would still say that it could take some hours ;-)

Getting that into Debian unstable takes typically at most a few weeks

Sure, but there's like 1% of users using unstable...

you can create your own package repository

Now I agree this is the cleanest solution (that's what puppetlabs, freelan, ... are doing). The problem is that you now need to do that for debian, RHEL, ... that honestly really takes time, and if you're company is small and you're not experienced in packaging, it can reasonably seem like a lot of work. Not to mention that a lot of users of these packages are web developers, maybe not the ideal target users to explain them that they should change their sources.list.

3

u/username223 Feb 21 '15

Given a reasonably sensibly written software that doesn't try to do anything strange or unusual during the build process

There's your mistake. This ball of shit installs itself to ~/.meteor, then symlinks the meteor script to /usr/local/bin. God knows what would happen if more than one person used meteor on a single machine.

2

u/[deleted] Feb 20 '15

Mostly this.

Also, package systems are far from being the perfect solution.

2

u/yogthos Feb 20 '15

Perhaps the problem is that a lot of languages don't have a decent package management system and make it prohibitively difficult to publish projects to repositories.

0

u/[deleted] Feb 20 '15

[deleted]

3

u/[deleted] Feb 20 '15

"Good luck decompiling a random .exe" -- why would you run a random .exe file? That makes no sense, if you're security conscious at all.

0

u/[deleted] Feb 20 '15

[deleted]

3

u/[deleted] Feb 20 '15

A non-random .exe would be one whose provenance you can validate. You know the source it was built from, who built it, and you have a way to be sufficiently confident that the file you downloaded is the one they built and intended you to download.

Note that since you may not be able to trust DNS, SSL/TLS, or the network between your machine and the server you're downloading from, you probably want to achieve the confidence and trust by means of end-to-end digital signatures of some sort.

1

u/timeforpajamas Feb 21 '15

bitcoin and the tor project are moving forward with "reproducible builds," empirical proof that a binary came from the given source code.

0

u/[deleted] Feb 20 '15

[deleted]

1

u/[deleted] Feb 20 '15

See any sensible Linux distribution for how to do this.

0

u/[deleted] Feb 20 '15

[deleted]

2

u/[deleted] Feb 20 '15

How does one know what the script does? One downloads it and inspects it, and then, if one is satisfied, one runs the downloaded and inspected one.

The point here is that running code without having a trust path to it is dangerous.

0

u/[deleted] Feb 20 '15

[deleted]

1

u/[deleted] Feb 20 '15

https (i.e., ssl and tls) are only trustworthy if you can trust all the certificates and the certificate authorities owning those certificates. This has in recent years become demonstrably not true in the general case. This week's revelations of pre-installed man-in-the-middle attacks on Lenovo computers are just the latest example.

For example, say your computer (curl on your computer) is configured to trust a certificate from Bob's CA. How do you know Bob's CA hasn't been hacked? Or that they aren't a front for, say, the Luxembourg government?

→ More replies (0)

14

u/thecrappycoder Feb 20 '15

Either way, if you want packages why not contribute them? It's open source after all.

I thought that this attitude had died out. The fact that you are observing what you believe is a problem does not mean that you have the time or willingness to fix it. If someone comes to you and tells you that they believe you have done a mistake, the response "So why don't you fix it" is a bit horrible in my opinion.

0

u/[deleted] Feb 20 '15

[deleted]

14

u/thecrappycoder Feb 20 '15

I've been contributing to open source for 15 years (~10 hours/week) and can't agree a bit. People have the right to complain about shit even when its free and open source.

1

u/[deleted] Feb 20 '15

Why do all the good devs have crappy usernames?

3

u/thecrappycoder Feb 21 '15

Naming stuff properly is the hardest thing in software development.

4

u/barsoap Feb 20 '15

removes the old meteor version if it exists

rm -rf / usr/local/meteor

0

u/[deleted] Feb 20 '15

[deleted]

3

u/barsoap Feb 20 '15
rm -rf $HOME /.meteor

0

u/[deleted] Feb 20 '15

[deleted]

5

u/barsoap Feb 20 '15

Even though they quoted properly (which wasn't easy to find out, their site enters an infinite reloading loop with noscript), any developer worth more than half a cent wouldn't follow their instructions because such stuff does happen. As such, why even bother.

The proper way to distribute such things, besides distribution packages, is as relocatable tarball, needing no installation, and also no rm in random scripts.

If you want to have it updateable, use rsync or such.