Detecting the use of “curl – bash” server side
The unfortunate problem with this is that while piping directly into bash can be exploited, it remains as one of the easiest ways to install programs.<p>Taking RVM for example. Their instructions are to run this: `curl -sSL <a href="https:&#x2F;&#x2F;get.rvm.io" rel="nofollow">https:&#x2F;&#x2F;get.rvm.io</a> | bash -s stable`. The script that is executed is 887 lines long. The installation is &quot;complex&quot;, requiring a lot of different stages. Now, the solution to this is &quot;Use a package manager&quot;. Sure, that works in a lot of cases. However, when you have something like RVM which is used across several major operating systems, and hundreds of different flavours, each with their own quirks and package managers it suddenly gets difficult to manage each of these.<p>The problem we face is, how can we make it easy to install something, while still being safe and maintainable?<p>Breaking this down further, there are 2 issues to solve. The first is &quot;How do we ensure what we download is what the maintainer says that we should download?&quot;. I.e. How do we make sure there are no malicious injections. That one is simple. Use SSL.<p>The second issue is, &quot;I want to install this thing but I don&#x27;t know if I can trust the installer&quot;. Are you crazy!? This isn&#x27;t an issue. If you don&#x27;t trust the installer, you sure as hell can&#x27;t trust the product. If you don&#x27;t trust either of them, then you automatically don&#x27;t trust the other and shouldn&#x27;t be installing it.<p>The result is that, yes, people can maliciously serve up code when you pipe the output of curl through bash without you realising. However, this is no different than blindly trusting and installing a script.