CVE-2023-51384
Medium · 5.5CVSS
5.5
EPSS
0.4%
Published
Dec 18, 2023
CISA due date
—
Cloudanix analysis
A flaw in the SSH agent could let someone bypass limits on which servers certain hardware-backed keys are allowed to reach.
- Exploitation
- Local Privilege
- Attacker needs
- Low Privilege
- Complexity
- Low
- Impact
- Data Exposure
- Component
- Application
- Class
- Authorization Bypass
- Remediation
- Upgrade
- Effort
- Medium
- Patch risk
- Low
What it actually does
ssh-agent in OpenSSH applies destination constraints only to the first PKCS#11 key returned by a token, leaving additional keys unconstrained.
Why it matters to the business
Local users or processes could reach SSH destinations that were intended to be blocked by per-key constraints, increasing the chance of unauthorized remote access or lateral movement.
How an attack unfolds
An attacker with local access loads a PKCS#11 token that returns multiple private keys into ssh-agent while specifying destination constraints; only the first key receives the constraints, allowing the remaining keys to be used for SSH connections to any destination.
How to fix it
Upgrade OpenSSH to 9.6 or newer; apply commit 881d9c6af9da4257c69c327c4e2f1508b2fa754b in openssh-portable.
How to confirm the fix worked
Confirm the running ssh-agent binary is built from a version containing commit 881d9c6af9da4257c69c327c4e2f1508b2fa754b; test addition of a multi-key PKCS#11 token and verify constraints are enforced on all keys.
Typical attack path
- Obtain local access to a host running ssh-agent
- Insert a PKCS#11 token configured to return multiple keys and request addition with destination constraints
- ssh-agent stores the keys but applies constraints solely to the first key
- Use any unconstrained key via ssh-agent to initiate SSH sessions to arbitrary hosts
How to detect it
Review ssh-agent debug or system logs for PKCS#11 key-addition events; correlate with outbound SSH connections that violate expected destination policies.
What your security team should do
- Upgrade all OpenSSH installations to a fixed version as soon as possible
- Audit systems for use of PKCS#11-backed keys in ssh-agent
- Review and tighten destination constraints where multiple keys may be returned
- Monitor SSH connection logs for unexpected destinations from hosts using ssh-agent
The record
In ssh-agent in OpenSSH before 9.6, certain destination constraints can be incompletely applied. When destination constraints are specified during addition of PKCS#11-hosted private keys, these constraints are only applied to the first key, even if a PKCS#11 token returns multiple keys.
Affected packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| Alpine:v3.16 | openssh | 0 | 9.0_p1-r5 |
| Alpine:v3.17 | openssh | 0 | 9.1_p1-r5 |
| Debian:12 | openssh | 0 | 1:9.2p1-2+deb12u2 |
| Debian:13 | openssh | 0 | 1:9.6p1-1 |
| Debian:14 | openssh | 0 | 1:9.6p1-1 |
| Mageia:9 | openssh | 0 | 9.3p1-2.1.mga9 |
| Ubuntu:18.04:LTS | openssh-ssh1 | 0 | No fix |
| Ubuntu:20.04:LTS | openssh | 0 | 1:8.2p1-4ubuntu0.11 |
| Ubuntu:20.04:LTS | openssh-ssh1 | 0 | No fix |
| Ubuntu:22.04:LTS | openssh | 0 | 1:8.9p1-3ubuntu0.6 |
| Ubuntu:22.04:LTS | openssh-ssh1 | 0 | No fix |
| Ubuntu:23.10 | openssh | 0 | 1:9.3p1-1ubuntu3.2 |
| Ubuntu:24.04:LTS | openssh | 0 | 1:9.6p1-3ubuntu1 |
| Ubuntu:24.04:LTS | openssh-ssh1 | 0 | No fix |
| Ubuntu:24.10 | openssh-ssh1 | 0 | No fix |
| Ubuntu:Pro:18.04:LTS | openssh-ssh1 | 0 | No fix |
| Ubuntu:Pro:20.04:LTS | openssh-ssh1 | 0 | No fix |
Related vulnerabilities
- CVE-2023-51385 In ssh in OpenSSH before 9.6, OS command injection might occur if a user name or host… Also affects openssh
- CVE-2023-48795 The SSH transport protocol with certain OpenSSH extensions, found in OpenSSH before 9.6… Also affects openssh
- CVE-2023-28531 ssh-add in OpenSSH before 9.3 adds smartcard keys to ssh-agent without the intended… Also affects openssh
- CVE-2021-41617 sshd in OpenSSH 6.2 through 8.x before 8.8, when certain non-default configurations are… Also affects openssh
- CVE-2016-10009 Untrusted search path vulnerability in ssh-agent.c in ssh-agent in OpenSSH before 7.4… Also affects openssh
- CVE-2024-6387 A security regression (CVE-2006-5051) was discovered in OpenSSH's server (sshd). Also affects openssh
- CVE-2023-25136 OpenSSH server (sshd) 9.1 introduced a double-free vulnerability during… Also affects openssh
- CVE-2016-10708 sshd in OpenSSH before 7.4 allows remote attackers to cause a denial of service (NULL… Also affects openssh