hackweb
notes on hacking and technology
IT EN
main menu
user menu
you are not logged in

SSH agent hijacking and mishandled keys

September 16, 2024 · 1 min read · #linux #ssh #lateral-movement

The SSH agent keeps decrypted keys in memory and exposes a socket to sign challenges. Whoever accesses the socket can use the keys without knowing the passphrase.

The routes

Accessible socket: if root (or another compromised user) finds a session's SSH_AUTH_SOCK, they reuse it to authenticate wherever those keys are valid:

SSH_AUTH_SOCK=/tmp/ssh-XXXX/agent.1234 ssh-add -l
SSH_AUTH_SOCK=... ssh target   # signs with the victim's keys

Agent forwarding (ssh -A): if you connect with forwarding to a compromised host, that host's admin uses your agent to hop to other systems as you.

Defence

Do not use -A toward untrusted hosts (use ProxyJump). Passphrase-protected keys, and confirmation per signature (ssh-add -c). Hardware keys (FIDO2/PIV) that cannot be exfiltrated. Tight socket permissions. Per-host, expiring keys (SSH certificates).


« back to home

latest posts
 
your IP address:
216.73.216.108
visitor #1
MOTD:
Every abstraction leaks somewhere.
Here we look at where.
topics