TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Zero Effort Private Key Compromise: Abusing SSH-Agent for Lateral Movement

61 pointsby warrenmover 1 year ago

10 comments

reidacdcover 1 year ago
Not mentioned in the article, but if you add the key to your agent with &quot;ssh-add -c &lt;key&gt;&quot;, then whenever the key is used to connect to another machine by the agent, the agent will prompt (on the machine where it was initially run) to confirm that the connection is intended, generally via &quot;ssh-askpass&quot;.<p>In my world, I use this routinely, precisely to detect a connection using a hijacked session, as described in the article. It does not detect the agent hijacking itself, it only detects new connections -- it pops up for all connections, both intended and unintended.<p>I know we&#x27;re all supposed to do defense in depth, but I confess to having a bit of a jaundiced view of attacks that begin, &quot;first, become root on a machine in the target domain....&quot;. Containment is a good idea, but if you&#x27;re at the point where you&#x27;re doing containment of compromised root accounts &quot;inside&quot;, things have gone pretty far wrong already.
评论 #37530613 未加载
fn-moteover 1 year ago
&gt; So, is this a vulnerability? Well no, not exactly [...]<p>Connecting to a compromised machine with `ssh -A` (agent forwarding) lets the attacker use your credentials for ssh sessions elsewhere. It&#x27;s almost explained in the man page.<p>Avoid the agent forwarding and you are fine.
pgrafover 1 year ago
Nice article, although the title is slightly off. The private key is not compromised (as described agent forwarding uses a challenge-response method) and the attacker can only initiate connections as long as the agent is being forwarded.
评论 #37531341 未加载
Canadaover 1 year ago
OpenSSH 8.9 introduced a restriction feature to mitigate this.<p><a href="https:&#x2F;&#x2F;www.openssh.com&#x2F;agent-restrict.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.openssh.com&#x2F;agent-restrict.html</a>
评论 #37533246 未加载
johnvalukover 1 year ago
Yes, your local agent can be accessed on the destination host by any other user with the necessary privileges (including your own account -- a root compromise is not required). This has been known for a very long time and a warning is included in the documentation. No, it does not compromise any private keys.<p>Your private keys are more likely to be compromised when you store them on untrusted systems. SSH-Agent allows you to avoid that risk.<p>Another mitigation is to use a dedicated agent per private key (or group of keys) to prevent forwarding keys to destinations that don&#x27;t need them.<p>SSH agent restriction (ssh-add -h) looks promising, but support isn&#x27;t widespread and it doesn&#x27;t cover all use cases.<p>The article assumes a remote attacker, but the attacker can more easily be your boss or team. Keep this in mind whenever you forward your agent and plan accordingly.
batch12over 1 year ago
This article helped me evolve my understanding of the impact of the recent openssh vuln, CVE-2023-38408. Gaining RCE on the source system is more valuable if you consider that the vulnerable machine is likely using ssh-agent to connect to other hosts, which makes pivoting potentially much easier.
nullbyteover 1 year ago
This article was much, much longer than it needed to be
g1a55erover 1 year ago
Good find! I was always curious how this worked.<p>I&#x27;m a big fan of tools like secretive[1] that can help solve this problem by using biometrics to shift the UX&#x2F;security trade-off and thus make it feasible to always require some kind of authentication to sign a token with a key.<p>I&#x27;m not aware of any tools that do the same for Linux, and a quick Google search doesn&#x27;t turn up much[2]. It does look like you can at least get a notification[3], though.<p>This could provide another layer of protection on the user&#x27;s endpoint device in addition the network monitoring called out in the article. Defense in depth, and all that.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;maxgoedjen&#x2F;secretive">https:&#x2F;&#x2F;github.com&#x2F;maxgoedjen&#x2F;secretive</a><p>[2] <a href="https:&#x2F;&#x2F;unix.stackexchange.com&#x2F;questions&#x2F;705144&#x2F;unlock-an-ssh-private-key-with-a-biometric-token-instead-of-a-passphrase" rel="nofollow noreferrer">https:&#x2F;&#x2F;unix.stackexchange.com&#x2F;questions&#x2F;705144&#x2F;unlock-an-ss...</a><p>[3] <a href="https:&#x2F;&#x2F;www.insecure.ws&#x2F;2013&#x2F;09&#x2F;25&#x2F;ssh-agent-notification.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;www.insecure.ws&#x2F;2013&#x2F;09&#x2F;25&#x2F;ssh-agent-notification.ht...</a>
评论 #37530377 未加载
评论 #37531511 未加载
评论 #37530359 未加载
keep_readingover 1 year ago
Hijack my ssh-agent but you&#x27;re not using my ssh key for lateral movement unless I touch my Yubikey for you.<p>And I&#x27;ll notice when it&#x27;s blinking but it shouldn&#x27;t be and just unplug it :)
j_not_jover 1 year ago
He lost me at &quot;ssh root@machine&quot;.<p>Just no.