by tempura · 15y ago · 0 comments
The root user on the forwarding machine should be trusted because they can monitor the contents of the agent socket while your connection is active, being able to eavesdrop on communications, but since your private key never leaves your own host, there's no way it could be leaked.
The fact that your private key is never transmitted is one of the core strengths of asymmetric keys. Did you think you were leaking your private key to any server you SSH'd to?
All Mallory must do is rifle through your known_hosts (or bash_history if hashing is enabled), wait for you to connect, then su to your account, fix up the environment, and SSH to some boxes of yours, and update your authorized_keys there to let him connect while you're offline, or starting up a quick background netcat and disconnecting.
This requires no magic tools, and syslog/lastlog on the remote machine won't show much of interest, especially if you're like me and rely on logging in multiple times "quickshot" to remote hosts, except for remote host names the lastlog is basically unreadable already.
agent forwarding is not enabled by default, so if you've turned it on, you should know what you're doing. it should only be enabled in ~/.ssh/config per-host, for hosts that you trust.
you should also enable confirmation in ssh-agent so that whenever a key is used, you must manually confirm it. it will prevent attacks like this where another user on a compromised machine will use your agent to login to another machine.
i wrote about doing this on osx, but it works similarly on any other platform - http://jcs.org/macssh
I no longer use agent forwarding. For config changes I prefer keeping "smarts" close to home and away from production, and in most cases do dumb pushes via rsync/SSH, rather than those machines ever having direct access to revision control, etc.
Just because a configuration needs to be added to a file doesn't mean that everyone using that config has added it themselves, or understands the implications.
Seems that an agent notification of auth requests would help mitigate some of the risks here.