Maschinengeflüster

Geschichten aus dem Serverraum

Wall of Shame: curl | sh

01. Juni 2022 — Felix Pankratz

What?

Many online tutorials explaining how to install software provide installation instructions similar to this:

curl -sSL https://example.com/installer.sh | sudo sh

This is bad advice. You should not run commands like this blindly!

Why?

The above command gets a script file from the internet, and executes it as root without you knowing what's going on. This also applies to installations in your user context (no sudo/su). Call me weird, but I like to take a look at what a script from the internet is doing before I run it.

Even if you trust the source, there still exists the possibility of a compromised supply chain - someone unauthorized might have added something nasty to installer.sh. Filip has a very nice blog post about the attack surface offered.

So please, for your own and your devices safety, review installation scripts.

Who?

Rust

$ curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh

"The Rust Programming Language", also known as "the book", is the very first thing recommended to people wanting to learn Rust by the official website. The installation section provides this snippet.

oh-my-zsh

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"

We're getting advanced - providing both curl and wget directly on the homepage!

Gitlab

curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash

Now what is this, a script.deb.sh? Step 2 in the install instructions for Ubuntu and Debian.

Tags: wip, en, admin, security