Skip to main content
Vulnerability Database/CVE-2025-46712

CVE-2025-46712: Erlang/OTP SSH KEX Handshake Vulnerability

CVE-2025-46712 is a SSH key exchange handshake vulnerability in Erlang/OTP that enables Man-in-the-Middle attackers to inject messages during connection setup. This article covers technical details, affected OTP versions, and patching guidance.

Published:

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

CVE-2025-46712 Overview

CVE-2025-46712 affects Erlang/OTP SSH implementations prior to OTP-27.3.4, OTP-26.2.5.12, and OTP-25.3.2.21. The vulnerability stems from incomplete enforcement of strict Key Exchange (KEX) handshake hardening. The SSH implementation permits optional messages to be exchanged during the handshake phase. A Man-in-the-Middle (MITM) attacker positioned on the network path can inject these optional messages into the SSH connection setup. The flaw is categorized under [CWE-440: Expected Behavior Violation]. The maintainers patched this issue across all three supported OTP branches.

Critical Impact

A network-positioned attacker can inject optional protocol messages during the SSH KEX handshake, undermining the strict KEX hardening protection designed to defeat MITM manipulation of handshake traffic.

Affected Products

  • Erlang/OTP 27 versions prior to OTP-27.3.4
  • Erlang/OTP 26 versions prior to OTP-26.2.5.12
  • Erlang/OTP 25 versions prior to OTP-25.3.2.21

Discovery Timeline

  • 2025-05-08 - CVE-2025-46712 published to NVD
  • 2026-06-17 - Last updated in NVD database

Technical Details for CVE-2025-46712

Vulnerability Analysis

The strict KEX protocol extension was introduced across SSH implementations to defend against the Terrapin-class prefix-truncation attacks disclosed in 2023. Strict KEX requires both peers to reject any non-essential messages during the handshake and reset message sequence numbers after key exchange completion. Erlang/OTP SSH did not fully enforce the first requirement. The implementation continued to accept optional messages interleaved with the KEX exchange, which created an injection window for a MITM attacker. An attacker exploiting this condition can tamper with handshake state in ways the strict KEX mitigation was explicitly designed to prevent. Successful exploitation requires an active network position between client and server.

Root Cause

The root cause is a missing validation step in the SSH transport state machine. The modules ssh_connection_handler.erl and ssh_transport.erl did not strictly filter message types permitted during the KEX phase when strict KEX was negotiated. The fix in commit e4b56a9f4a511aa9990dd86c16c61439c828df83 introduces a dedicated ssh_fsm.hrl include and reworks the next_seqnum function signature to track sequence state tied to the handshake phase. This closes the gap where optional protocol messages were silently accepted.

Attack Vector

Exploitation requires an attacker to intercept and modify SSH traffic in transit between client and server. The attacker injects optional SSH protocol messages during the KEX handshake. Because the receiving Erlang/OTP SSH endpoint accepts these messages instead of rejecting them per the strict KEX specification, the attacker gains the ability to manipulate handshake-adjacent state. The impact is bounded to integrity effects on the SSH session; the vulnerability does not directly yield confidentiality loss or denial of service.

text
// Patch excerpt — lib/ssh/src/ssh_connection_handler.erl
 -include("ssh_transport.hrl")
 -include("ssh_auth.hrl")
 -include("ssh_connect.hrl")
-
 -include("ssh_fsm.hrl")

// Patch excerpt — lib/ssh/src/ssh_transport.erl
 -export([versions/2, hello_version_msg/1])
--export([next_seqnum/1,
+-export([next_seqnum/3,
          supported_algorithms/0, supported_algorithms/1,
          default_algorithms/0, default_algorithms/1,
          clear_default_algorithms_env/0,

Source: Erlang/OTP commit e4b56a9

Detection Methods for CVE-2025-46712

Indicators of Compromise

  • Unexpected SSH session resets or renegotiations originating from Erlang/OTP SSH endpoints.
  • Presence of optional SSH protocol messages (for example SSH_MSG_IGNORE, SSH_MSG_DEBUG) interleaved with KEX traffic captured via network taps.
  • Anomalous latency or injected packets observed in SSH flows terminating at Erlang/OTP-based services such as RabbitMQ, CouchDB, or Ejabberd.

Detection Strategies

  • Inventory all deployed Erlang/OTP runtimes and compare installed versions against OTP-27.3.4, OTP-26.2.5.12, and OTP-25.3.2.21.
  • Deploy network monitoring that inspects SSH handshake message sequencing for strict KEX compliance.
  • Correlate SSH session anomalies with ARP, BGP, or DHCP changes that may indicate attacker positioning for MITM.

Monitoring Recommendations

  • Enable verbose SSH transport logging on Erlang/OTP applications exposing SSH endpoints.
  • Forward SSH connection logs to a centralized analytics platform for sequence-number and message-type analysis.
  • Alert on repeated failed KEX attempts from the same source, which may indicate reconnaissance against the handshake path.

How to Mitigate CVE-2025-46712

Immediate Actions Required

  • Upgrade Erlang/OTP installations to OTP-27.3.4, OTP-26.2.5.12, or OTP-25.3.2.21 depending on your release branch.
  • Audit downstream applications that embed Erlang/OTP SSH (such as RabbitMQ) and apply vendor-released rebuilds that include the patched runtime.
  • Restrict SSH access to management networks and enforce IP allow-listing on Erlang/OTP SSH daemons.

Patch Information

The fix was committed in erlang/otp commit e4b56a9 and shipped in releases OTP-27.3.4, OTP-26.2.5.12, and OTP-25.3.2.21. Full technical details are published in GitHub Security Advisory GHSA-934x-xq38-hhqf.

Workarounds

  • Terminate SSH connections at a hardened bastion or SSH proxy that enforces strict KEX before traffic reaches the Erlang/OTP endpoint.
  • Place Erlang/OTP SSH services behind a VPN or mutually authenticated TLS tunnel to prevent attacker interposition on the network path.
  • Disable SSH on Erlang/OTP services where it is not operationally required until the runtime can be patched.
bash
# Verify installed Erlang/OTP version
erl -eval 'erlang:display(erlang:system_info(otp_release)), halt().' -noshell

# Example upgrade on Debian-based systems using Erlang Solutions repo
sudo apt-get update
sudo apt-get install --only-upgrade esl-erlang

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

Sources: National Vulnerability Database, CISA KEV, Exploit-DB

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.