Junglewise Threat Intelligence

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

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

Technologies: Openssh.

Executive brief

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.

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