libssh Insecure Configuration Allows Local MITM Attacks (CVE-2025-14821)
CVE-2025-14821 in libssh allows local man-in-the-middle attacks, SSH downgrade attacks, and trusted host manipulation due to insecure default configuration loading from a world-writable directory on Windows.
A critical vulnerability, CVE-2025-14821, has been identified in the libssh library. This flaw arises from an insecure default configuration on Windows systems. Specifically, libssh automatically loads configuration files from the C:\etc directory. Critically, this directory can be created and modified by unprivileged local users. This allows a malicious local user to manipulate the SSH configuration, facilitating man-in-the-middle attacks, downgrading connection security, and manipulating trusted host information. Successful exploitation grants attackers the ability to intercept and potentially modify SSH communications, posing a significant risk to data confidentiality, integrity, and availability.
Attack Chain
- Attacker creates the directory
C:\etcif it does not already exist. - Attacker creates a malicious SSH configuration file (e.g.,
ssh_config) within theC:\etcdirectory. This configuration can specify settings to downgrade encryption or redirect connections. - A legitimate user initiates an SSH connection using an application that leverages the vulnerable libssh library.
- libssh automatically loads the attacker-controlled configuration file from
C:\etc\ssh_config. - The malicious configuration settings are applied, potentially downgrading the encryption algorithm used for the SSH connection.
- The attacker intercepts the SSH traffic, performing a man-in-the-middle attack due to the weakened encryption or connection redirection.
- The attacker can now eavesdrop on or modify the SSH communication, gaining unauthorized access to sensitive information or injecting malicious commands.
- Attacker maintains persistent access or exfiltrates sensitive data obtained through the compromised SSH session.
Impact
Successful exploitation of CVE-2025-14821 allows a local attacker to perform man-in-the-middle attacks on SSH connections. This can lead to the compromise of sensitive data transmitted over SSH, such as credentials, configuration files, or confidential documents. The ability to manipulate trusted host information further exacerbates the risk, potentially allowing attackers to impersonate legitimate servers. The vulnerability affects any Windows system using a vulnerable version of libssh and could impact organizations across all sectors that rely on SSH for secure communication and remote administration.
Recommendation
- Monitor for the creation or modification of files within the
C:\etcdirectory, particularly configuration files likessh_config, using file integrity monitoring (FIM) rules on Windows systems. - Implement the Sigma rule provided to detect the creation of the
C:\etcdirectory by non-system processes. - Restrict write access to the
C:\etcdirectory and its contents using appropriate file system permissions on Windows systems.
Detection coverage 2
Detect Creation of C:\etc Directory by Non-System Processes
mediumDetects the creation of the C:\etc directory, which could be an indicator of CVE-2025-14821 exploitation.
Detect Modification of SSH Config in C:\etc
mediumDetects modification of ssh_config file in the C:\etc directory.
Detection queries are kept inside the platform. Get full rules →