Glitch effect
Glitch effect

CVE-2023-51385 is a command injection vulnerability in OpenSSH's proxy command feature. An attacker could exploit this flaw by tricking a user or an automated process into connecting to a malicious server with a specially crafted hostname. This could allow the attacker to execute arbitrary commands on the client's machine, posing a significant security risk.

Alright, let's talk about a tricky one. CVE-2023-51385 is a remote code execution (RCE) vulnerability found in OpenSSH, one of the most widely used tools for secure remote connections. Specifically, the flaw exists in how some versions of the SSH client handle hostnames when using the ProxyCommand option. An attacker can craft a malicious hostname that, when used, allows them to execute arbitrary commands on the machine initiating the SSH connection. Think of it as a backdoor that gets opened by a seemingly normal connection attempt.

What is CVE-2023-51385 Vulnerability?

CVE-2023-51385 is a command injection vulnerability affecting the client side of OpenSSH. The issue arises when the ProxyCommand feature is used with a hostname containing shell metacharacters (like backticks `). Because the client-side code in vulnerable versions doesn't properly sanitize the hostname before passing it to the shell for execution, an attacker can embed commands within the hostname. If a user or automated system tries to connect to this malicious hostname, the embedded commands will run on their local machine with their permissions. Yikes.

When was it Discovered?

The vulnerability was publicly disclosed on December 18, 2023. The issue was discovered by security researchers who identified the flawed input validation in the OpenSSH source code. Following responsible disclosure practices, the details were released after a patch was made available by the OpenSSH developers, allowing system administrators time to update their systems before the exploitability became widely known.

Affected Products & Versions

The vulnerability specifically impacts OpenSSH versions before 9.6. If you're using ProxyCommand or a similar feature that relies on it (like ProxyJump with certain configurations), you'll want to check your version ASAP.

Product

Versions Affected

Fixed Versions / Patch Link

OpenSSH

Versions before 9.6

9.6 and later / OpenSSH 9.6 Release Notes

CVE-2023-51385 Technical Description

Let's get into the weeds. The root cause of the CVE-2023-51385 vulnerability lies in a lack of input sanitization within the OpenSSH client. When an SSH connection is initiated using the ProxyCommand option, the client expands tokens like %h (hostname) and %p (port) before passing the resulting string to a shell for execution.

The problem is that if the hostname (%h) contains shell metacharacters, such as backticks (), they are not escaped or removed. The client code essentially builds a command string and hands it off to /bin/sh. For example, a malicious command could look like this: ssh -o ProxyCommand='ssh -W "attacker-command":22 proxy' user@host. The inner command, attacker-command`, would execute on the client's machine.

This flaw is particularly dangerous in environments where hostnames are not fully trusted, such as Git repositories with submodules pointing to malicious URLs or in automated scripts that connect to various hosts.

Tactics, Techniques & Procedures (TTPs)

Threat actors exploiting the CVE-2023-51385 vulnerability typically use social engineering or supply chain manipulation to get a victim to connect to a malicious hostname. A common TTP involves embedding a crafted SSH URL in a project's configuration file (e.g., a .gitmodules file). When a developer clones the repository and initializes submodules, their SSH client could unknowingly execute the embedded payload. This allows the attacker to achieve initial access and potentially move laterally within the network.

Indicators of Compromise

Detecting an active exploit of this vulnerability can be tricky since the initial connection might look legitimate. However, there are a few Indicators of Compromise (IOCs) to watch for. Keep an eye on shell execution logs (bash_history, zsh_history) for suspicious ssh commands that include oddly formatted hostnames or backticks. You should also monitor for unexpected outbound network connections or processes being spawned by an SSH client process, especially if they are running with user-level privileges.

Known Proof-of-Concepts & Exploits

Shortly after disclosure, several security researchers developed and published proof-of-concept (PoC) exploits for CVE-2023-51385. These PoCs demonstrated how a malicious hostname could be used to launch applications, like a calculator, on the client's machine to prove code execution. While there have been no widespread, large-scale campaigns reported as of early 2025, the public availability of these PoCs means that threat actors have the tools to incorporate this CVE-2023-51385 exploit into their attacks. The exploitability is straightforward for anyone who can convince a target to use a crafted hostname.

How to Detect CVE-2023-51385 Vulnerability?

The best way to "detect" the vulnerability is to check your OpenSSH client version. On most Linux systems, you can run ssh -V in your terminal. If the reported version is below 9.6, you are vulnerable. For host-based detection, you can use an Endpoint Detection and Response (EDR) solution to monitor for unusual process chains originating from ssh. For example, an ssh process spawning a shell or other unexpected applications is a major red flag. SIEM rules can also be configured to alert on SSH commands in logs that contain shell metacharacters in the hostname argument.

Impact & Risk of CVE-2023-51385 Vulnerability

The impact of this vulnerability can be severe. An attacker who successfully exploits it gains the ability to execute code with the same privileges as the user running the SSH client. If that user is a developer with sudo rights or access to sensitive infrastructure, the attacker could escalate privileges, exfiltrate data, install persistent malware, or pivot to other systems on the network. The business risk includes data breaches, intellectual property theft, and system downtime. In short, it’s a pretty big deal.

Mitigation & Remediation Strategies

Stop what you're doing and patch! The primary and most effective mitigation is to update OpenSSH to version 9.6 or later. This version includes a fix that properly sanitizes hostnames to prevent command injection.

If you can't update immediately, you have a couple of options, but they're not as good as patching:

  • Avoid Untrusted Hostnames: Be extremely cautious about the hostnames you and your automated systems connect to. Don't clone Git repositories from untrusted sources or connect to SSH servers without verifying the hostname.

  • Restrict ProxyCommand: If possible, disable or strictly limit the use of ProxyCommand in your global and user-specific SSH configuration files (/etc/ssh/ssh_config and ~/.ssh/config).

Ultimately, patching is the only surefire way to remediate this vulnerability. Don't wait.

CVE-2023-51385 Vulnerability FAQs

CVE-2023-51385 is a command injection vulnerability in the OpenSSH client. It works by tricking the client into executing commands hidden within a specially crafted hostname when using the ProxyCommand feature. The client fails to properly clean the hostname, allowing malicious code to run on the user's machine.

This isn't a traditional virus; it's an exploit that requires user interaction. An attacker needs to convince a user or an automated script to initiate an SSH connection to a malicious server address. This is often done by embedding the malicious address in a project file, like a Git submodule, which the user then accesses.

Yes, it's absolutely still a threat. Any system running an unpatched version of OpenSSH (before 9.6) remains vulnerable. Given the widespread use of OpenSSH and the public availability of exploit code, it's an attractive target for attackers looking for an easy way into a network.

The best protection is patching. Organizations must update all OpenSSH clients to version 9.6 or newer. Additionally, they should use security tools to monitor for suspicious process activity and educate developers on the risks of connecting to untrusted hosts.

Glitch effectBlurry glitch effect

Protect What Matters

Secure endpoints, email, and employees with the power of our 24/7 SOC. Try Huntress for free and deploy in minutes to start fighting threats.
Try Huntress for Free