CVE-2023-25136
Description
Double-free in OpenSSH server 9.1 allows unauthenticated remote attacker to potentially achieve remote code execution or denial of service.
AI Insight
LLM-synthesized narrative grounded in this CVE's description and references.
Double-free in OpenSSH server 9.1 allows unauthenticated remote attacker to potentially achieve remote code execution or denial of service.
Vulnerability
CVE-2023-25136 is a double-free vulnerability in OpenSSH server (sshd) version 9.1 that occurs during the handling of options.kex_algorithms. The bug was introduced in OpenSSH 9.1 and is triggered when parsing a crafted SSH handshake. The vulnerability is exploitable in the default configuration [2].
Exploitation
An unauthenticated remote attacker can exploit this vulnerability by sending a specially crafted SSH handshake to the target server. The double-free can be leveraged to achieve arbitrary control of the instruction pointer, bypassing malloc protections under certain conditions. Proof-of-concept code exists to trigger a denial of service, and research has demonstrated arbitrary RIP control on OpenBSD 7.2 with default settings [2][4].
Impact
Successful exploitation can lead to a denial of service, and potentially to remote code execution. While the sshd process runs unprivileged and sandboxed, the ability to control code execution could allow an attacker to escape the sandbox or cause further compromise. On systems without strong memory protections, the risk of RCE is increased [2][4].
Mitigation
The vulnerability is fixed in OpenSSH 9.2p1, released on February 2, 2023. Users should upgrade to the latest version. No workarounds are available; patching is the only recommended mitigation [2].
AI Insight generated on May 28, 2026. Synthesized from this CVE's description and the cited reference URLs; citations are validated against the source bundle.
Affected products
35- OpenSSH/OpenSSH serverdescription
- osv-coords34 versionspkg:apk/chainguard/opensshpkg:apk/chainguard/openssh-clientpkg:apk/chainguard/openssh-docpkg:apk/chainguard/openssh-keygenpkg:apk/chainguard/openssh-keyscanpkg:apk/chainguard/openssh-keysignpkg:apk/chainguard/openssh-pam-configpkg:apk/chainguard/openssh-pam-configurationpkg:apk/chainguard/openssh-pkcs11-helperpkg:apk/chainguard/openssh-serverpkg:apk/chainguard/openssh-server-configpkg:apk/chainguard/openssh-servicepkg:apk/chainguard/openssh-sftp-serverpkg:apk/chainguard/openssh-sk-helperpkg:apk/wolfi/opensshpkg:apk/wolfi/openssh-clientpkg:apk/wolfi/openssh-docpkg:apk/wolfi/openssh-keygenpkg:apk/wolfi/openssh-keyscanpkg:apk/wolfi/openssh-keysignpkg:apk/wolfi/openssh-pam-configpkg:apk/wolfi/openssh-pam-configurationpkg:apk/wolfi/openssh-pkcs11-helperpkg:apk/wolfi/openssh-serverpkg:apk/wolfi/openssh-server-configpkg:apk/wolfi/openssh-servicepkg:apk/wolfi/openssh-sftp-serverpkg:apk/wolfi/openssh-sk-helperpkg:rpm/almalinux/opensshpkg:rpm/almalinux/openssh-askpasspkg:rpm/almalinux/openssh-clientspkg:rpm/almalinux/openssh-keycatpkg:rpm/almalinux/openssh-serverpkg:rpm/almalinux/pam_ssh_agent_auth
< 9.2_p1-r0+ 33 more
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 9.2_p1-r0
- (no CPE)range: < 8.7p1-29.el9_2
- (no CPE)range: < 8.7p1-29.el9_2
- (no CPE)range: < 8.7p1-29.el9_2
- (no CPE)range: < 8.7p1-29.el9_2
- (no CPE)range: < 8.7p1-29.el9_2
- (no CPE)range: < 0.10.4-5.29.el9_2
Patches
0No patches discovered yet.
Vulnerability mechanics
Root cause
"Pointer aliasing and improper lifetime management in compat_kex_proposal() leads to a double-free when both SSH_BUG_CURVE25519PAD and SSH_OLD_DHGEX compatibility flags are set."
Attack vector
An unauthenticated remote attacker can trigger the double-free by connecting to an OpenSSH 9.1 server with a default configuration and presenting a client banner that causes the server to set both the `SSH_BUG_CURVE25519PAD` and `SSH_OLD_DHGEX` compatibility flags [ref_id=1]. During key exchange, `compat_kex_proposal()` processes the proposal string through `match_filter_denylist()` twice; the first call reassigns the local pointer `p` to newly allocated memory, the second call reassigns `p` again, and then `free(cp)` frees the old allocation while the function returns the dangling pointer `p` [ref_id=2][ref_id=3]. This double-free can crash the forked sshd worker process (denial of service) and, according to third-party research, may be leveraged for limited remote code execution when memory protections such as ASLR and NX are disabled [ref_id=1].
Affected code
The vulnerability resides in `compat.c` within the `compat_kex_proposal()` function. The function is responsible for filtering the key-exchange algorithm proposal string based on compatibility flags. The flawed logic occurs when both `SSH_BUG_CURVE25519PAD` and `SSH_OLD_DHGEX` flags are set, causing the pointer `p` to be reassigned by `match_filter_denylist()` and then freed via `free(cp)`, while the function ultimately returns the already-freed pointer `p` [ref_id=2][ref_id=3].
What the fix does
The patch in commit 486c4dc3 (and the OpenBSD errata 017) restructures `compat_kex_proposal()` to use a separate pointer `cp2` for the second `match_filter_denylist()` call, ensuring that the pointer returned is always the last valid allocated string [ref_id=2][ref_id=3]. Specifically, the first filter result is stored in `cp`, the second filter result is stored in `cp2`, and `cp` is freed only after `cp2` has been assigned; the function then returns `cp` (which now points to `cp2`'s allocation) instead of the dangling `p` [ref_id=3]. This eliminates the double-free by guaranteeing that no pointer is freed while still being referenced as the return value.
Preconditions
- authNo authentication required; the bug is triggered pre-authentication during key exchange.
- configDefault configuration is vulnerable; no special options need to be set.
- inputAttacker must be able to establish a TCP connection to the SSH server and send a client banner that triggers both SSH_BUG_CURVE25519PAD and SSH_OLD_DHGEX compatibility flags.
- configThe target must be running OpenSSH version 9.1p1.
Generated on May 24, 2026. Inputs: CWE entries + fix-commit diffs from this CVE's patches. Citations validated against bundle.
References
16- ftp.openbsd.org/pub/OpenBSD/patches/7.2/common/017_sshd.patch.signvdPatchVendor Advisory
- github.com/openssh/openssh-portable/commit/486c4dc3b83b4b67d663fb0fa62bc24138ec3946nvdPatchThird Party Advisory
- bugzilla.mindrot.org/show_bug.cginvdExploitIssue TrackingThird Party Advisory
- jfrog.com/blog/openssh-pre-auth-double-free-cve-2023-25136-writeup-and-proof-of-concept/nvdExploitThird Party Advisory
- www.openwall.com/lists/oss-security/2023/02/02/2nvdExploitMailing ListThird Party Advisory
- www.openwall.com/lists/oss-security/2023/02/13/1nvdMailing ListThird Party Advisory
- www.openwall.com/lists/oss-security/2023/02/22/1nvdMailing ListThird Party Advisory
- www.openwall.com/lists/oss-security/2023/02/22/2nvdMailing ListThird Party Advisory
- www.openwall.com/lists/oss-security/2023/02/23/3nvdMailing ListThird Party Advisory
- www.openwall.com/lists/oss-security/2023/03/06/1nvdMailing ListThird Party Advisory
- www.openwall.com/lists/oss-security/2023/03/09/2nvdMailing ListThird Party Advisory
- news.ycombinator.com/itemnvdIssue TrackingThird Party Advisory
- security.gentoo.org/glsa/202307-01nvdThird Party Advisory
- security.netapp.com/advisory/ntap-20230309-0003/nvdThird Party Advisory
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/JGAUIXJ3TEKCRKVWFQ6GDAGQFTIIGQQP/nvd
- lists.fedoraproject.org/archives/list/package-announce%40lists.fedoraproject.org/message/R7LKQDFZWKYHQ65TBSH2X2HJQ4V2THS3/nvd
News mentions
0No linked articles in our index yet.