News for hackers. Stuff that matters.
Re:Matrix.org hacked by tarruda on Friday April 12, 2019 @05:40AM (#19643400)
On the first issue opened by the hacker:

> Complete compromise could have been avoided if developers were prohibited from using ForwardAgent yes or not using -A in their SSH commands. The flaws with agent forwarding are well documented.

I use agent forwarding daily and had no idea it contained well known security holes. If that's the case, why is the feature available by default?

Re:Matrix.org hacked by XMPPwocky on Friday April 12, 2019 @05:43AM (#19643415)
SSH agent forwarding makes your ssh-agent available to (possibly some subset of) hosts you SSH into. This is its purpose. Unfortunately, it also makes your ssh-agent available to (possibly some subset of) hosts you SSH into.
Re:Matrix.org hacked by aidos on Friday April 12, 2019 @05:55AM (#19643468)
I never quite understand why there’s not a confirm version. ForwardWithConfirmation or something. I’m active when I need forwarding - would be happy to simply be prompted before it’s allowed.
Re:Matrix.org hacked by DblPlusUngood on Friday April 12, 2019 @06:15AM (#19643538)
OpenSSH does have confirmation: use the '-c' switch to ssh-add.

https://man.openbsd.org/ssh-add

Re:Matrix.org hacked by aquabeagle on Friday April 12, 2019 @11:15AM (#19645502)
Or "AddKeysToAgent confirm" in ~/.ssh/config
Re:Matrix.org hacked by aidos on Friday April 12, 2019 @07:13AM (#19643762)
Waaaaaaat?! That could definitely be better known.
Re:Matrix.org hacked by Arathorn on Friday April 12, 2019 @07:34AM (#19643853)
TIL :|
Re:Matrix.org hacked by acct1771 on Saturday April 13, 2019 @01:04AM (#19651205)
Hang in, there.
Re:Matrix.org hacked by felipelemos on Friday April 12, 2019 @06:35AM (#19643603)
This could be a sane default.
Re:Matrix.org hacked by e12e on Friday April 12, 2019 @10:35AM (#19645132)
Hm, anything similar for gpg agent (both for gpg, and as a stand-in for ssh-agent)?

Ed: looks like I need to edit my sshcontrol-file

https://www.gnupg.org/documentation/manuals/gnupg/Agent-Conf...

Re:Matrix.org hacked by Leace on Friday April 12, 2019 @06:05AM (#19643505)
If you use Yubikey with touch-to-use enabled that'll be basically what you're asking - each authentication will require touching the token.
Re:Matrix.org hacked by haasted on Friday April 12, 2019 @06:55AM (#19643695)
I just enabled that after seeing this incident.

For people in the same boat, it can be done trivially using the YubiKey Manager CLI: https://developers.yubico.com/yubikey-manager/

Re:Matrix.org hacked by rwmj on Friday April 12, 2019 @06:11AM (#19643520)
Some ssh agent implementations do this, notably the one built into Android ConnectBot can be configured to request confirmation each time it is asked to authenticate. Unfortunately ssh-agent (from OpenSSH) does not as far as I know. It's happy to authenticate as many times as requested without any notification.
Re:Matrix.org hacked by DBFFD990 on Friday April 12, 2019 @09:46AM (#19644718)
It can, and it's determined per key when added to the agent.

Look for -c here: https://man.openbsd.org/ssh-add

Re:Matrix.org hacked by rwmj on Friday April 12, 2019 @11:15AM (#19645508)
Indeed it is - I even checked the man page before posting the comment and completely missed that option.
Re:Matrix.org hacked by scanr on Friday April 12, 2019 @05:47AM (#19643430)
Is there a secure alternative that achieves the same outcome?
Re:Matrix.org hacked by metafunctor on Friday April 12, 2019 @06:09AM (#19643514)
Here are a few ideas that might help.

Use separate keyboard-interactive 2FA (I recommend google-authenticator) for production ssh access.

Use a key system which requires confirmation or a PIN to authenticate (such as a Yubikey). Use a persisting ssh connection with Ansible (ControlPersist) to avoid unnecessary multiple authentications.

Allow connections only from whitelisted IPs, or Uuse port knocking to open temporary holes in your firewall, or require connections to production infrastructure to go through a VPN.

Access production infrastructure from hardware dedicated for that purpose, never do anything else on it.

I wish there was a way in ssh to tag connections and only allow agent forwarding to keys with the same tag. That would prevent agent forwarding production keys from a dev host.

Re:Matrix.org hacked by pas on Friday April 12, 2019 @08:58AM (#19644350)
Re:Matrix.org hacked by XMPPwocky on Friday April 12, 2019 @05:58AM (#19643479)
I'm not sure. A secure, backwards-compatible (with older servers) alternative, which only exposes keys you explicitly choose to expose, should be doable and might help.

another option would be for a SSH client to present a full-screen "$HOST is trying to use your your SSH PRIVATE keys. Press enter, then type "~A" to allow." prompt.

Re:Matrix.org hacked by RL_Quine on Friday April 12, 2019 @05:55AM (#19643466)
`ProxyJump`
Re:Matrix.org hacked by aidos on Friday April 12, 2019 @06:01AM (#19643490)
Hadn’t seem that before. Article here explains is briefly https://www.madboa.com/blog/2017/11/02/ssh-proxyjump/
Re:Matrix.org hacked by theamk on Friday April 12, 2019 @01:42PM (#19647156)
This article is .. weird. It mentions SOCKS5, DynamicForwarding and "decent version of nc", while you don't need anything at all for forwarding connection -- SOCKS is not involved in any way, and initial 1995 release of nc would work just fine.

Here is a much better explanation (from [0]):

> ProxyJump was added in OpenSSH 7.3 but is nothing more than a shorthand for using ProxyCommand, as in: "ProxyCommand ssh proxy-host -W %h:%p"

so the same thing that top poster was talking about.

[0] https://superuser.com/questions/1253960/replace-proxyjump-in...

Re:Matrix.org hacked by metafunctor on Friday April 12, 2019 @06:10AM (#19643517)
Do you keep your keys on the proxy host, then? Otherwise, "ForwardAgent yes" and you're back to the same situation.
Re:Matrix.org hacked by syntonym on Friday April 12, 2019 @06:24AM (#19643565)
ProxyJump uses the keys from the original host, not the proxy host.
Re:Matrix.org hacked by metafunctor on Friday April 12, 2019 @06:33AM (#19643600)
I know. That's why I asked. Chained agent forwarding will serve your keys just the same, so ProxyJump is not "a secure alternative that achieves the same outcome".
Re:Matrix.org hacked by syntonym on Friday April 12, 2019 @06:49AM (#19643667)
Are you disagreeing with the "secure alternative" or the "same outcome"? I thought the difference between ProxyJump and agent forwarding is the following:

Agent forwarding forwards the agent socket to the proxy server. Thus any ssh connection originating from the proxy server can reuse the agent, and with that has the same access to the agent as the originating host.

ProxyJump routes the ssh connection through the proxy host. The crypto takes place between originating host and target host, not between proxy host and target host. ssh connections originating from the proxy host can not access keys from the originating host.

But maybe my understanding of ProxyJump is incorrect?

Re:Matrix.org hacked by metafunctor on Friday April 12, 2019 @07:32AM (#19643844)
I know exactly how agent forwarding and ProxyJump work, but I'm having a hard time understanding what you mean.

ProxyJump proxies your ssh connection, so connecting from A to B via proxy X the connections go A->X and X->B.

You can use AgentForwarding with ProxyJump, in which case agent connections go B->X->A.

I cannot see how ProxyJump would somehow be an alternative to AgentForwarding. You can use both independently.

Re:Matrix.org hacked by Xylakant on Friday April 12, 2019 @07:56AM (#19643977)
> ProxyJump proxies your ssh connection, so connecting from A to B via proxy X the connections go A->X and X->B.

No, it rather works like this:

A -> B via X establishes A->X and then, through that connection tunnels a new ssh-connection from A->B.

A->X, then X->B would require forwarding the Agent from A to X, so that the connection from X->B can authenticate using that agent. Proxying the connection does not require X to ever authenticate to B, the authentication happens straight from A->B (1). Thus, no agent (forwarding) needed. You can also chain ProxyJumps: A->X->Y->B tunnels A->B in A->Y which is then tunneled through A->X. In that regard, ProxyJump and ProxyCommand can replace AgentForwarding in most use cases. There are some uses where AgentForwarding is the only solution, though.

(1) Added benefit: X never sees the actual traffic in unencrypted form and all port forwards A<->B work

Re:Matrix.org hacked by metafunctor on Friday April 12, 2019 @10:59AM (#19645324)
Hehe, I think I figured out the source of the confusion.

I was thinking that the threat is that a compromised B gives access to your keys via agent forwarding. Presumably if you make keys available on B, you need them there. There's nothing ProxyCommand does to help there.

But you're talking about using ProxyCommand as an alternative for connecting A->X and then X->B, so keys are not available on X. That's of course an improvement.

Re:Matrix.org hacked by pas on Friday April 12, 2019 @08:58AM (#19644354)
Re:Matrix.org hacked by brunoqc on Friday April 12, 2019 @09:31AM (#19644600)
That project looks dead.
Re:Matrix.org hacked by technion on Friday April 12, 2019 @07:50AM (#19643935)
I think an issue here is we've been told for a long time "always restrict access to the environment through a bastion host" without much implementation detail discussed after that. Agent forwarding tends to show up as the most efficient way to implement this.
Re:Matrix.org hacked by crazydoggers on Friday April 12, 2019 @11:45AM (#19645829)
Basically you need to make sure the host you are SSH'ing into with an agent is secure. Otherwise the root user on that host can access your agent socket and connect to any other machines your agent can.

So if you SSH -A to a compromised Jenkins server, and you've got all your production keys loaded in your agent, the hacker can now authenticate to all those production machines as well.

So don't ever SSH -A into a machine unless you KNOW its secure. The way I think about it is unless I trust the machine enough to leave my private keys on that machine, then I'm not going to SSH -A into it.

Re:Matrix.org hacked by nightfly on Friday April 12, 2019 @05:45AM (#19643422)
> I use agent forwarding daily

That's why. It's useful, but you have to be mindful of the security risks involved in using it.