News for hackers. Stuff that matters.
Re:Curl to shell isn't so bad by mkup on Saturday November 09, 2019 @04:31AM (#21490530)
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.
Re:Curl to shell isn't so bad by glic3rinu on Saturday November 09, 2019 @04:46AM (#21490577)
A common solution is to wrap all code within a function. This way nothing gets executed until the last line, the one that calls the function, is executed.

  function main () {
     # all code goes here
  }
  main
Re:Curl to shell isn't so bad by amalcon on Saturday November 09, 2019 @09:45AM (#21491800)
Common, but not universal. If I pipe a response body into a shell, I don't get to check whether they were careful or not.
Re:Curl to shell isn't so bad by scbrg on Saturday November 09, 2019 @04:34AM (#21490540)
No. It's addressed in the second last bullet, Partial content
Re:Curl to shell isn't so bad by LIV2 on Saturday November 09, 2019 @04:41AM (#21490561)
Yeah "it will happen anyway" misses the point that curl will notify you of the failed download before you run it, whereas piping it to sh will immediately run it
Re:Curl to shell isn't so bad by tonyedgecombe on Saturday November 09, 2019 @04:33AM (#21490538)
Is that really much of a problem? I can't remember the last time I had a download fail part the way through and they are usually much bigger than a bootstrapping script.
Re:Curl to shell isn't so bad by LIV2 on Saturday November 09, 2019 @04:38AM (#21490551)
I mean it's unlikely but imagine it did happen and something in the script like "rm -rf /some/path" gets truncated to "rm -rf /" & immediately run

Even if your connection is TLS secured an MITM attack of causing a connection reset after X bytes could be a viable attack

Re:Curl to shell isn't so bad by Carpetsmoker on Saturday November 09, 2019 @05:36AM (#21490721)
As was pointed out both in the article and the comments here, this is easily addressed by wrapping everything in a function (or subshell, for that matter).