News for hackers. Stuff that matters.
Re:Detecting the use of "curl | bash" server-side by Waterluvian on Saturday July 28, 2018 @10:22PM (#17636157)
So yes, curl bash can be dangerous. But it's just so darn convenient. And when it's coming from a very prominent trusted source like for Get Pip or Amazon AWS it's hard not to just go with.

Surely there's some compromise middle ground? Let me download "safe-curl-bash" (scb) that only runs a script if it's trusted in some manner? Maybe the checksum matches from a crowdsourced database.

"Sorry only 9 people have declared this script valid and your threshold is 100. Here's a cat of the script and we will ask you if it looks valid or not or don't know."

I also think it's a bit more realistic than the, "anyone who does this should be reading the script first to check that it's safe." Yes, and I check the passenger jet for flaws before I board, too!

Just spitballing.

Re:Detecting the use of "curl | bash" server-side by smacktoward on Saturday July 28, 2018 @10:33PM (#17636191)
> Yes, and I check the passenger jet for flaws before I board, too!

There is an entire infrastructure of people and processes in place to make sure that you don't have to check your passenger jet for flaws to be reasonably sure it's safe. No such infrastructure exists to protect you from the consequences of curl-bashing software off some random Web site.

Re:Detecting the use of "curl | bash" server-side by Spivak on Saturday July 28, 2018 @11:59PM (#17636446)
If you're installing software off some random website then you're already hosed no matter what the install process looks like.

Say you already trust the website you're downloading from, is there an increased security risk doing curl | bash as compared to rpm --import https://example.com/RPM-GPG-EXAMPLE && yum install https://example.com/example.rpm

No matter what you're putting 100% faith in the the server and the TLS connection. There are a lot of reasons to prefer packages, but I don't think security is one of them.

Re:Detecting the use of "curl | bash" server-side by fragmede on Sunday July 29, 2018 @11:51AM (#17638706)
Security is one of them.

When RPM-GPG-EXAMPLE and example.rpm are both coming from https://example.com it's less clear. When example.com is coming from a mirror repository, or being emailed around (yes, this happens), package signing asserts that example.rpm was signed by the signatures in RPM-GPG-EXAMPLE, which has a strong (but not bullet-proof) connection as being built by example.com.

From that example, we can see that package signing also protects from someone who's able to break into the main example.com webserver but not example.com's build system - if the attackers did not get into the build system and example.rpm has a valid signature then despite the webserver being broken, the rpm file can still be trusted, assuming the webserver did not have a copy of the private key used for build signing. If we loaded https://example.com/RPM-GPG-EXAMPLE before the webserver was broken into, and then the webserver was broken into and a malicious RPM-GPG-EXAMPLE and example.rpm were uploaded, it would be noticed. (Examining changes to RPM-GPG-EXAMPLE are, unfortunately, left to the reader as an exercise.)

Still, while it's true that loading the file from https://example.com/RPM-GPG-EXAMPLE relies on TLS, but there are methods available to confirm that the file's contents are valid, that don't rely on TLS, if the security folk at example.com are doing their job.

Finally, TLS is not an all or nothing game. Or rather, the certificate used to sign the https connection does not have to be blindly trusted, and in the case of sketchy root certificates, even if https://example.com loads fine in a web browser, it does not mean it should necessarily be trusted. Certificate Transparency (eg crt.sh) is a proper lever when working with example.com.

Security is complicated and there are no silver bullets.

`curl | sudo bash` is batshit though.

Re:Detecting the use of "curl | bash" server-side by gnufied on Sunday July 29, 2018 @11:31AM (#17638617)
Say I already trust packages.redhat.com and install rpms regularly from it. I likely already have trusted their key.

Now packages.redhat.com gets hacked - if hacker also stole private key used for signing packages and replaced the RPMs. I will get warning/error while installing rpms (which I admit most users will ignore) but a curl|bash kinda defeats the point of package signing too.

Re:Detecting the use of "curl | bash" server-side by Waterluvian on Saturday July 28, 2018 @10:38PM (#17636203)
Yes that's fair. My point is that most people using these scripts have nowhere near the expertise to be able to evaluate their safety.
Re:Detecting the use of "curl | bash" server-side by true_religion on Sunday July 29, 2018 @10:42AM (#17638370)
Who are these "most people". I've never seen curl | bash outside of developer circles. "Most" people install things directly from the app store, or use web apps.
Re:Detecting the use of "curl | bash" server-side by ghthor on Saturday July 28, 2018 @11:11PM (#17636315)
Good use case for IPFS. You could curl a hash and check that hash against signatures commited to a blockchain. If the set of signatures exist that you trust, then it's golden, if not, no exec.
Re:Detecting the use of "curl | bash" server-side by gant on Sunday July 29, 2018 @10:41AM (#17638362)
If by "signatures committed to blockchain" you mean git with a GPG signed tip/tag, then yes, sure, blockchain.

If you mean that other thing, no.

Re:Detecting the use of "curl | bash" server-side by ghthor on Monday July 30, 2018 @12:43AM (#17642113)
The only difference is the consensus algorithm. A git repo is proof of authority, or proof of access rights.
Re:Detecting the use of "curl | bash" server-side by j88439h84 on Sunday July 29, 2018 @12:00AM (#17636449)
> when it's coming from a very prominent trusted source like for Get Pip or Amazon AWS

Not a random website, and they do have an infrastructure.

Re:Detecting the use of "curl | bash" server-side by CobrastanJorji on Saturday July 28, 2018 @11:42PM (#17636398)
> when it's coming from a very prominent trusted source like...Amazon AWS.

Be very careful here. https://installation.s3.amazonaws.com/setup.sh looks like a legit URL, but it's just some guy with an S3 bucket named "installation".

Re:Detecting the use of "curl | bash" server-side by smt88 on Saturday July 28, 2018 @11:14PM (#17636321)
Security and convenience are almost always a difficult tradeoff. In the case of curl'ing scripts from trusted websites, what is the benefit for the average lazy user? Are you using an OS that doesn't have a signed package with the same library/program?

It's not trust now that you need to worry about. It's trust later, when curl-bash is part of an automated pipeline that no one pays attention to.

Re:Detecting the use of "curl | bash" server-side by Waterluvian on Saturday July 28, 2018 @11:30PM (#17636368)
"Lazy" isn't a bad thing. When I see a curl-bash command from a reputable site, I'm not about to waste my time evaluating it. Consider step one to three from this site https://docs.aws.amazon.com/AmazonECS/latest/developerguide/... or get-pip instructions from this one: https://packaging.python.org/tutorials/installing-packages/

But I agree with your sentiment. If the exact same step was to `apt install ecs-cli` I would just do that and not feel any inconvenience about it.

Re:Detecting the use of "curl | bash" server-side by erroneousfunk on Monday July 30, 2018 @05:01PM (#17647993)
Your solution depends on third parties checking the script or going based on some knowledge of "trusted sources." That has nothing to do with this hack, which exploits those who are "verifying" the script themselves before executing it.

The simple solution here is not to use curl/execute with a pipe. Just wget to save the file and check it locally (rather than through a browser) before executing.

Re:Detecting the use of "curl | bash" server-side by arminiusreturns on Saturday July 28, 2018 @10:25PM (#17636167)
I think the arch user repo does this correctly by asking, "do you want to edit the packagebuild?" You can just press n to accept defaults, or y to take a look under the hood and make edits before continuing.
Re:Detecting the use of "curl | bash" server-side by oconnor663 on Sunday July 29, 2018 @07:48PM (#17641083)
Preventing the bad guy from "validating" his own script a million times is difficult. At the end of the day, I think security basically has to come from "I trust the website that I'm on."