SSH lateral movement

2025-11-02

SSH is routinely abused my malware and threat actors for lateral movement.

Credential theft

Attackers harvest credentials from compromised systems using infostealers, keyloggers, memory scraping, filesystem collection, or by stealing private SSH keys and known_hosts files. Those credentials are then used to authenticate to additional hosts, increasing the attacker’s foothold.

Port forwarding

An attacker can use SSH client features (local/remote port forwarding or dynamic proxying/SOCKS) to pivot traffic through a compromised host. This enables access to internal-only services, bypasses network segmentation or perimeter controls, and can let attackers maneuver around firewall and IDS rules.

Agent hijacking

If SSH agent forwarding is enabled, an attacker who gains control of a host can use the forwarded agent socket to authenticate to other systems without ever possessing the private key file.

Privilege escalation

SSH provides remote shells; once an attacker obtains elevated privileges on a host they can access protected keys/secrets, modify SSH configuration or binaries, deploy backdoors, or create new user accounts — all of which facilitate broader lateral movement.

Some commonly-abused vulnerabilities:

Name/Description CVE Link
Dirty C0w CVE-2016-5195 https://dirtycow.ninja/
Stack Clash CVE-2017-1000364 https://blog.qualys.com/vulnerabilities-threat-research/2017/06/19/the-stack-clash
Baron Samedit CVE-2021-3156 https://blog.qualys.com/vulnerabilities-threat-research/2021/01/26/cve-2021-3156-heap-based-buffer-overflow-in-sudo-baron-samedit
PwnKit CVE-2021-4034 https://blog.qualys.com/vulnerabilities-threat-research/2022/01/25/pwnkit-local-privilege-escalation-vulnerability-discovered-in-polkits-pkexec-cve-2021-4034
Dirty Pipe CVE-2022-0847 https://dirtypipe.cm4all.com/

Many privilege escalation vulnerabilities are specific to certain distributions, software versions, kernel versions, and configurations. the number of these exploitable flaws is staggering. as such, attackers may run automated scripts to check for the presence of these bugs to figure out how to elevate their privileges.

Examples of these include linux exploit suggester, linpeas, and linenum


No notes link to this note