VYPR
Medium severity6.5NVD Advisory· Published Feb 3, 2023· Updated May 28, 2026

CVE-2023-25136

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

Patches

0

No 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

News mentions

0

No linked articles in our index yet.