# CVE-2023-51385: OpenSSH OS command injection via shell metacharacters in hostnames

Source: https://junglewise.ai/threats/cve-2023-51385-openssh-os-command-injection-via-shell-metacharacters-in  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2023-12-18. Updated: 2026-05-12  
License: CC BY 4.0 with a link back

CVE-2023-51385 · Severity: medium · CVSS 6.5 · Published 2023-12-18

OpenSSH is a widely used suite of secure networking utilities for remote login and file transfer. A vulnerability exists where specially crafted usernames or hostnames containing shell characters can trigger unintended command execution on the client system. This typically occurs when OpenSSH is invoked by other applications, such as Git, using untrusted data from external sources like malicious repositories.

## Quick answers

**Is CVE-2023-51385 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2023-51385 being exploited in the wild.

**How severe is CVE-2023-51385?** Medium severity, with a CVSS score of 6.5, published 18 December 2023.

**Which products and versions are affected?** OpenSSH OpenSSH before 9.6.

**Is there a fix for CVE-2023-51385?** A patch was published on 2023-12-18: OpenSSH portable commit 7ef3787 applied to ban metacharacters Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2023-51385 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2023-51385?** Check whether anything you run is named in the advisory. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## Technical details

An OS command injection vulnerability exists in OpenSSH before version 9.6 due to improper neutralization of shell metacharacters in user or host names. When these names are provided via the command line and subsequently referenced by expansion tokens (e.g., in ProxyCommand or ProxyJump directives), they can be interpreted by the shell. A common attack vector involves a victim cloning a malicious Git repository containing submodules with crafted hostnames. The fix, introduced in version 9.6, involves banning most shell metacharacters in user and host names provided specifically via the command line.

## Affected products

- OpenSSH OpenSSH before 9.6

## Timeline

- 2023-12-18: advisory: Initial release of OpenSSH 9.6 addressing the issue
- 2023-12-18: disclosed: CVE-2023-51385 published
- 2023-12-18: patched: OpenSSH portable commit 7ef3787 applied to ban metacharacters

## References

- [http://seclists.org/fulldisclosure/2024/Mar/21](http://seclists.org/fulldisclosure/2024/Mar/21)
- [http://www.openwall.com/lists/oss-security/2023/12/26/4](http://www.openwall.com/lists/oss-security/2023/12/26/4)
- [https://github.com/openssh/openssh-portable/commit/7ef3787c84b6b524501211b11a26c742f829af1a](https://github.com/openssh/openssh-portable/commit/7ef3787c84b6b524501211b11a26c742f829af1a)
- [https://lists.debian.org/debian-lts-announce/2023/12/msg00017.html](https://lists.debian.org/debian-lts-announce/2023/12/msg00017.html)
- [https://security.gentoo.org/glsa/202312-17](https://security.gentoo.org/glsa/202312-17)
- [https://security.netapp.com/advisory/ntap-20240105-0005/](https://security.netapp.com/advisory/ntap-20240105-0005/)
- [https://support.apple.com/kb/HT214084](https://support.apple.com/kb/HT214084)
