News for hackers. Stuff that matters.
Re:Zellij: A terminal workspace with batteries included by slang800 on Friday August 12, 2022 @07:17PM (#32445101)
Please do not pipe scripts downloaded through curl into bash. Use a package manager. That way the downloaded binary can be verified against a checksum and/or GPG signing.
Re:Zellij: A terminal workspace with batteries included by ReganLaitila on Friday August 12, 2022 @11:13PM (#32446575)
Please lend your own time and energy to generate packages for bespoke distributions and package managers. You will need: deb, rpm, apk, AppImage, casks, tars, and likely more. Make sure to spend your time submitting your package to maintainers for each repository/registry for each distribution and each distro version. Don't forget to test each and every permutation!

Is all that too hard? No problem. Stand up your own repository for each distribution mechanism and instruct the user to run a bunch of random curl and key handling commands to bind their machine to this new software supply chain attack channel. At least this 'potentially malicious' code is being checksumed/gpg verified!

-- the point --

'curl | sh' is inherently no different from a trust perspective then issuing a package installation command or installing a new repository source for a package manager. Each user makes the value judgement if they trust the software or not. Your free to run the 'curl' part and inspect the script, or contribute packages to the byzantine linux/unix ecosystem if it boils your blood so hard.

Practicality is a feature sometimes.

Re:Zellij: A terminal workspace with batteries included by 411111111111111 on Friday August 12, 2022 @11:43PM (#32446700)
It is inherently different, because it's been proven that you can detect the use of curl|bash Serverside. This makes it possible to serve the malicious payload only to people which do that.

But I'd agree that the hurdle to get your package into system repositories likely ain't with it. People are free to compile it themselves, download it manually or whatever floats their boats if they don't want to use the quick and easy install script... Which they can audit by saving it to the filesystem before executing the file.

Re:Zellij: A terminal workspace with batteries included by ReganLaitila on Saturday August 13, 2022 @12:02AM (#32446784)
"It is inherently different, because it's been proven that you can detect the use of curl|bash Serverside"

Malicious people do malicious things? I worry that we conflate trust with validity. Some package systems do it better than others, but in principle you trust that for example, a maintainer of a package repository is not serving you bad checksums and malicious content. After all these systems get their checksums/keys on-first-use, so you still need to make the trust judgement. And they could still change the responses based on your ip, user agent, or other metadata they have access to when you interact with the system.

To boil it down to my gripe, the comments about checksums/gpg signing being the reason to never 'curl | sh' make no sense until you can clear the trust argument first, which no one does. And once you do clear the trust argument, and conclude the source is trustworthy, we can have a more technical debate on the distribution mechanism itself and what makes sense from that perspective.

edit: forgot to add, 'curl | sh' is also a trust on-first-use scenario just like with package ecosystems.

Re:Zellij: A terminal workspace with batteries included by 411111111111111 on Saturday August 13, 2022 @01:55AM (#32447296)
I think I wasn't clear enough so I'll try to rephrase it:

A compromise from a malicious curl|bash script is basically impossible to detect. All other avenues at least give you the potential ability to figure out how you were compromised after the fact. With curl|bash there is no trail and you can never find out which commands were actually excecuted, because it's possible to detect the |bash on the server that's providing the script.

Re:Zellij: A terminal workspace with batteries included by ReganLaitila on Saturday August 13, 2022 @02:34AM (#32447450)
Thanks for the clarification I see now what your getting to. I agree having proper packages makes sense at some point in a project's maturity, as you have more infrastructure, checks, and gates to ensure that what you requested is 'valid', and the system produces enough logs/data to compare to other systems to detect drift/compromise. I tend to see if a project gets popular enough, with enough eyeballs/contributors, official packages tend to become inevitable.

Since we've passed the trust gate up to this point for discussion purposes, I still wonder if there is a better model for young projects. Its not just we have multiple package formats, its the per distro/version matrix that tends to bite small developers and projects on time commitment. I would like to see something better than 'curl | sh' that is practical and portable across the unix-y ecosystem. Perhaps a third-party checksum db that caches valid script hashes ala golang sumdb or similar. Seems ripe for improvement.

Re:Zellij: A terminal workspace with batteries included by rabite on Saturday August 13, 2022 @03:34AM (#32447706)
> because it's been proven that you can detect the use of curl|bash Serverside.

Sure, but what you're missing is that this argument would also strike down package managers. For example, you could similarly fingerprint the difference in behaviors for apt-get vs normal http utilities and only serve malicious packages to people grabbing via apt (likely someone trying to run the code) vs downloading in a browser or via curl/wget (most likely an auditor). This is trivial to do and of course individual packages as well as entire package delivery mechanisms have been compromised.

The value add for package systems is signatures.

Re:Zellij: A terminal workspace with batteries included by 411111111111111 on Saturday August 13, 2022 @07:43AM (#32448956)
I am not aware of any implementation that's able to do that.

Feel free to create a proof of concept if that's actually possible, then you'll be able to discuss it.

You'll likely also get incredible job offers as that would be a Goldmine for blackhats and various state actors

Re:Zellij: A terminal workspace with batteries included by rank0 on Saturday August 13, 2022 @04:57AM (#32448077)
How do you detect curl | bash server side?
Re:Zellij: A terminal workspace with batteries included by linza on Saturday August 13, 2022 @05:04AM (#32448098)
Re:Zellij: A terminal workspace with batteries included by samatman on Friday August 12, 2022 @09:35PM (#32446071)
Definitely don't curl | less first if you're concerned, or make a tmpfile if you're really paranoid.

That would be using your tools, not kvetching online. And we can't have that.

Re:Zellij: A terminal workspace with batteries included by da39a3ee on Friday August 12, 2022 @07:26PM (#32445171)
Please don't contribute worthless and irrelevant comments like this. As you doubtless well know, piping from curl into bash is something that a large subset of respected programmers think is reasonable, and another rather tedious subset do not. For example, the entire Rust community clearly has a consensus that it's reasonable: https://rustup.rs/ As does homebrew https://brew.sh/ and pyenv https://github.com/pyenv/pyenv-installer#install to name whatever came to my mind in 30s thought.

Since the debate has such large numbers on both sides, your individual opinion on it is neither interesting nor germane.

Re:Zellij: A terminal workspace with batteries included by OJFord on Friday August 12, 2022 @08:57PM (#32445814)
Why do you think your opinion is more valuable than that to which you reply?

For what it's worth, I can rattle off many more project names at random in 30s, and odds are they'll all have installation methods that aren't curl-pipe-shell, there are just so many more of them.

Re:Zellij: A terminal workspace with batteries included by da39a3ee on Sunday August 14, 2022 @03:58PM (#32462402)
Please read what I wrote more carefully: I wasn't giving an opinion (other than the word "tedious"). I was pointing out the fact that there are large numbers of experienced software engineers on both sides of this argument, and hence it isn't an argument that can be settled, or even helpfully contributed to, by individuals giving their opinions. It's got to the point where it's more like politics or religion or something.
Re:Zellij: A terminal workspace with batteries included by LanternLight83 on Friday August 12, 2022 @07:42PM (#32445285)
I for one think that this individual opinion has value under this post as a PSA to people who might not otherwise give the command a second thought, regardless of the conclusion they take away.
Re:Zellij: A terminal workspace with batteries included by aspaceman on Friday August 12, 2022 @07:37PM (#32445248)
"a bunch of folks do something insecure" does not speak argument.

The argument is that it is insecure. Most easily because I can inject, "cat ~/.ssh/*_rsa | curl ..." and get your company ssh keys. There's no reason rust, brew and all the rest can't provide a Download page with a checksum. They choose not to, like this project chose not to, because it doesn't look as sexy.

It's really silly.

Re:Zellij: A terminal workspace with batteries included by carlhjerpe on Friday August 12, 2022 @08:42PM (#32445712)
Sure you can, but there's always going to be trust somewhere. I trust that the curl | bash examples I see are from reputable sources, and I trust their infra as much as someone else's to be safe (https protects MITM attacks). NixOS is a cool example of complete package transparency with their binary cache, if your expressions don't evaluate the same as theirs you'll build from source.

But really, curl | bash isn't the end of the world.

If they do it against a github url they also have the security of github behind you, because you can't differentiate on user agent there, which seems to be the commonly argued pitfall. Or other ways to detect you're not a browser, on a hosted platform you have someone else's security team behind your back.

Re:Zellij: A terminal workspace with batteries included by qbasic_forever on Friday August 12, 2022 @07:47PM (#32445327)
If someone has pulled off a sophisticated enough attack to intercept your http curl of the script and inject a malicious version, why can't they also intercept your brower http requests for the download page and inject different html that gives a good hash/checksum of the malicious script?

Going even further, what is stopping a malicious attack on the package source itself--like someone gaining control of the package source and committing a malicious version (as NPM, pypi and other registries have seen)?

The point is, "use your package manager" is not any better in the grand scheme of things than blindly curling and executing a script. Neither option is perfectly secure.

Re:Zellij: A terminal workspace with batteries included by nine_k on Friday August 12, 2022 @09:08PM (#32445897)
No, the concern is not your computer is compromised. Yours is a low-value target, sorry.

It's their http server, or a machine that feeds that http server, which is a good target for a compromise. Injecting a little bit of malicious code that steals something, or installs a fileless piece of malware, would bring massive benefits to the perpetrator, even if the exploit is short-lived.

That shell script should be a zip (gzip, xz) file, with a sha256 hash of it published on a different, separately hosted resource.

Maybe we should provide an utility that just does that in one command. It could even be a shell script...

Re:Zellij: A terminal workspace with batteries included by qbasic_forever on Friday August 12, 2022 @09:14PM (#32445933)
Realistically a poisoned ARP or DNS attack that redirects your machine's traffic to the attacker's server, both for the download and the download page, is something to be concerned about. This only requires someone to have access to your local network, not to your machine. It could be as innocent as working at a coffee shop from their wifi network and an attacker being on it too...
Re:Zellij: A terminal workspace with batteries included by moondev on Friday August 12, 2022 @11:06PM (#32446529)
curl validates the TLS certificate by default, it will fail in your scenario unless you pass -k. dev TLD requires https on all connections
Re:Zellij: A terminal workspace with batteries included by yunohn on Friday August 12, 2022 @07:39PM (#32445266)
Why can’t the downloaded binary package do the exact same thing? Or do you decompile and go through those as well?
Re:Zellij: A terminal workspace with batteries included by aspaceman on Friday August 12, 2022 @07:42PM (#32445291)
It could, but I can trust that no individual stepped in the middle of that process.

I trust Rust to not put such a thing in their binary. I do not trust an arbitrary man in the middle, and it's trivial to modify a shell script.

Without a checksum, I can't ensure the binary im piping through the shell is the binary they posted and built. Anyone can step in, modify a few lines, and get access to a large part of my system. The barrier to entry to add such capability to arbitrary binaries is outrageously high.

Re:Zellij: A terminal workspace with batteries included by yunohn on Friday August 12, 2022 @07:45PM (#32445311)
Install scripts are usually hosted on GitHub/etc and changes are clearly tracked. Compiled binaries are untracked and do not offer the same guarantees. I would trust the script more than a binary that could’ve been modified anywhere along the build process.

Not everyone uses Linux, and not every package can be audited by repo devs. It’s simply not scalable.

Re:Zellij: A terminal workspace with batteries included by moondev on Friday August 12, 2022 @07:49PM (#32445348)
> Most easily because I can inject, "cat ~/.ssh/*_rsa | curl ..."

If you can inject that breaking TLS which secures everything on the internet, why can't you inject your own checksum on the "download page"?

Re:Zellij: A terminal workspace with batteries included by zbird on Friday August 12, 2022 @09:37PM (#32446087)
Checksums and the binaries can be stored in different places for redundancy.
Re:Zellij: A terminal workspace with batteries included by zbird on Friday August 12, 2022 @09:39PM (#32446100)
Trusting it because other people trust it for no apparent reason does not seem like a very compelling argument. For all I know, the Rust and homebrew communities know squat about how to securely deliver binaries.
Re:Zellij: A terminal workspace with batteries included by user00012-ab on Friday August 12, 2022 @10:11PM (#32446303)
I wish I could upvote da39a3ee's comment 100 more times. I hate condescending know it all people, and da39a3ee stated this way more eloquently then I would have.
Re:Zellij: A terminal workspace with batteries included by inetsee on Friday August 12, 2022 @07:40PM (#32445270)
Have you read the Hacker News Guidelines, particularly the section labeled "In Comments"? If you haven't, I suggest that you should.
Re:Zellij: A terminal workspace with batteries included by yunohn on Friday August 12, 2022 @07:48PM (#32445336)
Do you mean for the original comment complaining about the script?

> Please don't complain about tangential annoyances—things like article or website formats, name collisions, or back-button breakage. They're too common to be interesting.

> Avoid unrelated controversies, generic tangents, and internet tropes.

> Please don't post shallow dismissals, especially of other people's work.

> Please don't pick the most provocative thing in an article or post to complain about in the thread. Find something interesting to respond to instead.

Re:Zellij: A terminal workspace with batteries included by yunohn on Friday August 12, 2022 @07:43PM (#32445298)
The developer has accounted for this with a prominent link to the file in question, see “View the script that will be executed here”.
Re:Zellij: A terminal workspace with batteries included by tslocum on Friday August 12, 2022 @07:56PM (#32445385)
This actually doesn't protect you the way you think it does. Using a simple check of the user agent which makes the request, an innocuous file may be served to browser requests, while an infected file may be served to cURL requests.
Re:Zellij: A terminal workspace with batteries included by kej on Friday August 12, 2022 @09:17PM (#32445954)
You can even get more devious and use timing differences to serve one thing to `curl` and a different thing to `curl | bash`: https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-b...