OpenSSH ProxyCommand Flaw Allows Remote Code Execution – PoC Released
Security researchers have identified a critical vulnerability in OpenSSH’s ProxyCommand feature, allowing remote code execution on client systems.
Security researchers have identified a critical vulnerability in OpenSSH’s ProxyCommand feature, allowing remote code execution on client systems.
This vulnerability, tracked as CVE-2025-61984 , arises from insufficient filtering of control characters in usernames when expanding the ProxyCommand string. The flaw enables attackers to inject line breaks that can interrupt command execution, resulting in arbitrary code execution on the client side.
The issue is triggered when using the %r token in the ProxyCommand directive within the ~/.ssh/config file. Control characters, such as newlines, are not stripped, which allows execution of attacker-controlled commands.
Affected Products Impact Exploit Prerequisites CVSS 3.1 Score
OpenSSH ≤ 10.0p1 (client) Remote code execution User SSH config with ProxyCommand using %r 8.1 (High)
A proof of concept has been released, demonstrating exploitation in Bash, fish, and csh shells. In Bash, injecting $[*] within an exec invocation generates a syntax error, allowing subsequent commands to execute:
Security researchers have identified a critical vulnerability in OpenSSH’s ProxyCommand feature, allowing remote code execution on client systems.
bash -xc "$(printf 'exec $[*]\necho compromised')"
This prints “compromised” after the error. Similar behaviors are observed in fish and csh shells. Zsh is not affected due to its handling of parse errors.
A potential attack vector involves a malicious Git submodule URL using the %r expansion. Cloning a repository with a crafted .gitmodules entry and matching SSH proxy configuration can lead to arbitrary code execution.
To mitigate this vulnerability, it is recommended to upgrade OpenSSH to version 10.1p1 or later, which disallows control characters in usernames. For those unable to upgrade, quoting the %r token in SSH client configurations can prevent newline injection:
ProxyCommand /usr/bin/nc -X connect -x proxy:8080 '%r@%h:%p'
Additional measures include restricting SSH transport for Git submodules:
git config --global protocol.ssh.allow user
Raising awareness about this vulnerability is crucial for environments using SSH proxies, such as cloud gateway solutions. Proper filtering and version updates are essential to prevent remote code execution.
Based on reporting by GBHackers.
