curl https://some-url/ | sh

I see this all over the place nowadays, even in communities that, I would think, should be security conscious. How is that safe? What’s stopping the downloaded script from wiping my home directory? If you use this, how can you feel comfortable?

I understand that we have the same problems with the installed application, even if it was downloaded and installed manually. But I feel the bar for making a mistake in a shell script is much lower than in whatever language the main application is written. Don’t we have something better than “sh” for this? Something with less power to do harm?

  • FizzyOrange@programming.dev
    link
    fedilink
    arrow-up
    5
    arrow-down
    4
    ·
    edit-2
    22 hours ago

    it is detectable on server side, if you download the script or pipe it into a shell

    Irrelevant. This is just an excuse people use to try and win the argument after it is pointed out to them that there’s actually no security issue with curl | bash.

    It’s waaaay easier to hide malicious code in a binary than it is in a Bash script.

    You can still see the “hidden” shell script that is served for Bash - just pipe it through tee and then into Bash.

    Can anyone even find one single instance of that trick ever actually being used in the wild (not as a demo)?

    • Undaunted@feddit.org
      link
      fedilink
      arrow-up
      4
      ·
      21 hours ago

      I never tried to win any argument. Hell I was not even aware that I’m participating in one. I just wanted to share the info, that even if the vendor is absolutely trustworthy and even if you validated the script by downloading and looking at it, there’s still another hole that’s not obvious to see.

      Yes it’s unlikely, but again, I never said it were. There are also arguments you can run curl with, to tell it to do the download first and then push it through the pipe afterwards, though I don’t know them by heart now.

      It won’t cost you anything to set those parameters, when you insist to use curl | bash, just in the off chance that someone’s trying to do what I mentioned.

      But I’m also someone who usually validates their downloads with a checksum so maybe I’m just weird. Who knows.