TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Curl to shell isn't so bad

266 pointsby stargraveover 5 years ago

26 comments

yoavmover 5 years ago
Not so bad comparing to what? Yeah, comparing to downloading a tar file from the website and running .&#x2F;configure, make etc - right, it&#x27;s probably quite a similar risk. But who does that?<p>Every decent Linux distro has a package manager that covers 99% of the software you want to install, and comparing to an apt-get install, pacman -S, yum install and so on - running is a script off some website is way more risky. My package manager verifies the checksum of every file it gets to make sure my mirror wasn&#x27;t tempered with, and it works regardless of the state of the website of some random software. If I have to choose between a software that&#x27;s packaged for my package manager and one I have to install with a script - I&#x27;ll always choose the package manager. And we didn&#x27;t even start to talk about updates - as if that isn&#x27;t a security concern.<p>The reason we should discourage people from installing scripts of the internet is because it would be much better if that software would just be packaged correctly.
评论 #21490646 未加载
评论 #21491547 未加载
评论 #21491475 未加载
评论 #21491967 未加载
评论 #21491335 未加载
评论 #21490724 未加载
评论 #21492354 未加载
评论 #21493206 未加载
评论 #21494171 未加载
评论 #21494056 未加载
LIV2over 5 years ago
I disagree with some of this, I.e paste jacking.<p>Plenty of software projects put more care and focus into their software and not in their website, if you&#x27;re running a vulnerable version of Wordpress or whatever CMS it&#x27;d be easy for someone to insert something malicious without being noticed whereas something that modified your code would show up in git, code reviews etc
评论 #21490798 未加载
评论 #21490873 未加载
评论 #21490503 未加载
avaloneonover 5 years ago
I&#x27;m surprised that no one has yet mentioned that piping curl to bash can be detected by the server (previous discussion at <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17636032" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=17636032</a>). This allows an attacker to send different code if it&#x27;s being piped to bash instead of saved to disk.<p>IMHO, &quot;curl to shell&quot; is uniquely dangerous, since all the other installation vectors mentioned don&#x27;t support the bait-and-switch.
评论 #21494817 未加载
评论 #21490648 未加载
评论 #21490628 未加载
lawlover 5 years ago
&gt; Not knowing what the script is going to do.<p>Yep, this is why i hate piping curl to sh. Much prefer how e.g. go does this:<p>Tells you to just run<p><pre><code> tar -C &#x2F;usr&#x2F;local -xzf go1.13.4.linux-amd64.tar.gz </code></pre> It&#x27;s not that I don&#x27;t trust the installer script to not install malware. But I don&#x27;t trust the installer script to not crap all over my system.
评论 #21490427 未加载
andreareinaover 5 years ago
My experience is that software that installs via curl|bash tends to ignore my preferences as expressed via $PREFIX&#x2F;DESTDIR, $XDG_{CACHE,CONFIG,DATA}_HOME, etc. It&#x27;ll install who-knows-where and probably leave dotfiles all over my home directory.<p>Maybe curl|bash is <i>functionally</i> equivalent to git clone &amp;&amp; .&#x2F;configure &amp;&amp; make &amp;&amp; make install, but my bet is on the one providing a standard install flow to be a better guest on my system.
评论 #21491307 未加载
lokedhsover 5 years ago
The points raised in the article are correct, and I&#x27;m much more concerned with the willingness of people to run arbitrary software on their primary computers in general, than the specific case of piping to sh. I think piping to sh just emphasises how insecure the entire practice is, and arguing against that is analogous to close your eyes to protect yourself from the attacking tiger.<p>The only system I&#x27;ve worked with that helps you truly deal with this is Qubes OS. Perhaps Fedora Silverblue will achieve this as well, once it comes out of beta.
评论 #21490523 未加载
sjyover 5 years ago
Has running a curl-to-bash command found during normal user-initiated web browsing <i>ever</i> resulted in a malware infection? Even anecdotal evidence would be valuable at this point.
评论 #21490653 未加载
评论 #21492073 未加载
评论 #21490678 未加载
评论 #21490635 未加载
评论 #21492605 未加载
tannhaeuserover 5 years ago
Yeah I was asking this question on SO - How to responsibly publish a script - but got no response, a sarcastic &quot;Tumbleweed&quot; badge even. My concern was that the script could be easily hosted elsewhere and we&#x27;d have multiple versions with potential malicious mods flying around. In the absence of alternatives curl-bashing isn&#x27;t so bad after all because it promotes a canonical download location from a domain&#x2F;site you control, even if I hated it initially as a long-term Unix user.
eadmundover 5 years ago
&gt; There is no fundamental difference between curl .. | sh versus cloning a repo and building it from source.<p>Not true: when you clone a repo with signed commits, you have forensic evidence that the repo signer provided the code you ran, while when you use curl you have … just the code itself.<p>That&#x27;s not a <i>lot</i>, but it&#x27;s not <i>nothing</i>.
评论 #21491115 未加载
kijinover 5 years ago
I hate install scripts, period. They feel so Windows-ish. Just distribute a .deb, .rpm, .snap, homebrew package, npm package, or whatever is the most appropriate for your software. All the scripting you need to do should be done inside of the regular package installation process, and even that should be kept to a minimum.<p>The only software that has any right to rely on an ad-hoc install script on a Unix-like system is the package manager itself. It&#x27;s awful enough that I have to do apt update and npm update separately. Please don&#x27;t add even more ways to pollute my system.
评论 #21490728 未加载
评论 #21490751 未加载
paxyover 5 years ago
The average non-technical user is never going to open up the terminal and run commands. The well educated technical user is going to be vary of untrusted sites and various forms of attacks (which I&#x27;m assuming the author of this post falls under).<p>IMO this is good advice for those that fall in the middle of these two categories, i.e. <i>slightly</i> technical people who run into problems and copy-paste solutions from Stack Overflow hoping that something will work.<p>&gt; you’re not running some random shell script from a random author<p>This is <i>exactly</i> what is happening in the vast majority of these cases. These users are going to be vary if linked to an executable or installer, but &quot;hey just run this simple line of code&quot; sounds like a very appealing solution.
评论 #21490563 未加载
jchwover 5 years ago
Agreed. If I don’t trust the server, or don’t have a secure connection to it, it is not likely wise to run any non trivial code downloaded from it.<p>Verifying a hash that comes from the same server also doesn’t make that much sense. Verifying a PGP signature would be a compelling reason to not pipe to shell, and that’s really about it.
评论 #21491233 未加载
esotericnover 5 years ago
For the most part this is a problem with non-rolling-release distros.<p>There are very few instances in which I&#x27;ve had to even use an installer on Arch. For many of those cases, the AUR provides a package that verifies the hash of the downloaded file anyway.<p>I&#x27;ve constantly been frustrated when using Ubuntu because something basic like having &#x27;vim&#x27; not be months out of date requires a PPA.<p>The &#x27;official&#x27; Rust installation method is a curl | sh. Or:<p><pre><code> $ pacman -Q rustup &amp;&amp; rustup -V rustup 1.20.2-1 rustup 1.20.2 (2019-10-16)</code></pre>
评论 #21492401 未加载
slimover 5 years ago
the problem is mainly that the script is executed without leaving a trace. if you downloaded the script then executed it, you would have something to inspect in case something goes wrong.<p>it&#x27;s too easy, and people with very scarce knowledge could develop a habit of doing this without asking questions and not even leaving any trace for a senior to inspect in case of a problem happening
评论 #21491122 未加载
评论 #21491119 未加载
fortyover 5 years ago
&gt; There is no fundamental difference between curl .. | sh versus cloning a repo and building it from source<p>I would say it depends. If the commits are signed by a key you know it&#x27;s probably better. Even if it&#x27;s not the case, cloning with SSH if you know the host key is also slightly better than downloading through HTTPS where any (compromised) trusted CA can MITM your connection :) (you can argue that those to use cases are rare in practice, and I would agree with you ;))
评论 #21491240 未加载
eavotanover 5 years ago
&gt; Not knowing what the script is going to do.<p>This is more like: not knowing what to do, when it doesn&#x27;t work. And this is always the case until it works. Which is just a local Phenomenon and i can&#x27;t expect things that work for me to work for others. So why don&#x27;t write an expressive installation documentation with multiple steps instead of one-liners that either work or don&#x27;t. There is just no in between.<p>Take the installation instruction of syncthing for example:<p><pre><code> curl -s https:&#x2F;&#x2F;syncthing.net&#x2F;release-key.txt | sudo apt-key add - echo &quot;deb https:&#x2F;&#x2F;apt.syncthing.net&#x2F; syncthing stable&quot; | sudo tee &#x2F;etc&#x2F;apt&#x2F;sources.list.d&#x2F;syncthing.list </code></pre> These two steps are hard to automate, if you don&#x27;t have an interactive shell.<p>Same goes for the saltstack-boostrap-script. This script doesn&#x27;t work on all platform equally good. This is not an reliable state. So in the end I&#x27;ll stick with the normal way to install things which is very easy to automate.
Nikskoover 5 years ago
I ran into this recently at work. I wanted to write a script that you could curl into bash to quickly set up some common tools.<p>Firstly, I made sure that the script told you what it would do before doing it.<p>Secondly, my instructions are two lines. Curl to a file, then run it through bash. A compromise, but if you mistrust the script, you can inspect it yourself before running it.
e12eover 5 years ago
&gt; Either way, it’s not a problem with just pipe-to-shell, it’s a problem with any code you retrieve without TLS.<p>Well, yes. But the <i>typical</i> alternative is a tar-ball and a gpg signature - both via insecure transport, but verifiable (like with tls and a CA).<p>Git will typically be via ssh or https - so to a certain degree over a secure channel.
mkupover 5 years ago
If curl loses connection to the source website while downloading the script, then partially downloaded script will be executed, no matter what. This is a main drawback of curl-to-shell piping approach, and the original article is missing it entirely.
评论 #21490577 未加载
评论 #21490540 未加载
评论 #21490538 未加载
评论 #21490544 未加载
saagarjhaover 5 years ago
A small benefit of downloading the installer is that this lets you run a checksum on it.
评论 #21490462 未加载
bauerdover 5 years ago
I remember someone curling a Heroku CLI install script and upon inspection, it would have tried to install a specific version of Ruby too instead of just the client. Since then I always glance through the script first
daxterspeedover 5 years ago
Is there a simple command you can use to read the contents of the script (pipe) before it&#x27;s sent to sh? Something like:<p><pre><code> curl ... | less-and-maybe-cancel | sh</code></pre>
评论 #21491568 未加载
评论 #21491499 未加载
评论 #21492690 未加载
ZoomZoomZoomover 5 years ago
I think normalization of this practice makes the scripts the primary attack interest of the wrongdoers, and these scripts are often an easier target.
tedunangstover 5 years ago
Sometimes I just want to download software without installing it. This is complicated by install scripts that obfuscate the real source or break it into dozens of parts.
apiover 5 years ago
Curl to shell is a result of Linux&#x27;s fragmentation. It&#x27;s the only way to provide a simple install process.
评论 #21495737 未加载
评论 #21496165 未加载
tandavover 5 years ago
I always install docker using simple command<p><pre><code> curl -fsSL get.docker.com | sh </code></pre> Instead of copy pasting dozen of commands from docs &#x2F; SO
评论 #21491598 未加载