Skip to main content

CVE-2022-29245: CWE-338: Use of Cryptographically Weak Pseudo-Random Number Generator (PRNG) in sshnet SSH.NET

Medium
Published: Tue May 31 2022 (05/31/2022, 16:35:11 UTC)
Source: CVE
Vendor/Project: sshnet
Product: SSH.NET

Description

SSH.NET is a Secure Shell (SSH) library for .NET. In versions 2020.0.0 and 2020.0.1, during an `X25519` key exchange, the client’s private key is generated with `System.Random`. `System.Random` is not a cryptographically secure random number generator, it must therefore not be used for cryptographic purposes. When establishing an SSH connection to a remote host, during the X25519 key exchange, the private key is generated with a weak random number generator whose seed can be brute forced. This allows an attacker who is able to eavesdrop on the communications to decrypt them. Version 2020.0.2 contains a patch for this issue. As a workaround, one may disable support for `curve25519-sha256` and `curve25519-sha256@libssh.org` key exchange algorithms.

AI-Powered Analysis

AILast updated: 06/22/2025, 00:51:45 UTC

Technical Analysis

CVE-2022-29245 identifies a cryptographic vulnerability in the SSH.NET library, specifically in versions 2020.0.0 and 2020.0.1. SSH.NET is a widely used Secure Shell (SSH) library for the .NET framework, facilitating encrypted communications for remote administration and file transfers. The vulnerability arises during the X25519 key exchange process, a modern elliptic curve Diffie-Hellman method used to establish secure session keys. In these affected versions, the client's private key for the X25519 key exchange is generated using the .NET System.Random class. System.Random is a pseudo-random number generator (PRNG) designed for general-purpose use and is not cryptographically secure. Its output can be predicted or brute-forced by attackers, especially if they can observe or capture the communication. This weak randomness compromises the confidentiality of the SSH session because an attacker capable of eavesdropping on the key exchange can potentially reconstruct the private key, decrypting the session traffic. The vulnerability is addressed in version 2020.0.2 of SSH.NET, which replaces System.Random with a cryptographically secure PRNG for key generation. As a temporary mitigation, users can disable support for the affected key exchange algorithms: curve25519-sha256 and curve25519-sha256@libssh.org. No known exploits have been reported in the wild, but the weakness fundamentally undermines the cryptographic guarantees of SSH sessions established with the vulnerable versions.

Potential Impact

For European organizations, this vulnerability poses a significant risk to the confidentiality and integrity of SSH communications that rely on the affected SSH.NET versions. SSH is commonly used for secure remote management of servers, network devices, and cloud infrastructure. If an attacker can intercept the SSH handshake, they could decrypt sensitive data, including credentials, configuration files, or proprietary information. This is particularly concerning for sectors with stringent data protection requirements such as finance, healthcare, and critical infrastructure. The vulnerability could facilitate espionage, unauthorized access, or lateral movement within networks. Given the widespread use of .NET in enterprise environments and the adoption of SSH.NET in various applications, the scope of affected systems can be broad. The ease of exploitation is moderate since it requires the attacker to eavesdrop on the network traffic during the key exchange. However, no authentication or user interaction is needed beyond passive interception. The vulnerability does not directly affect availability but severely impacts confidentiality and integrity.

Mitigation Recommendations

1. Upgrade SSH.NET to version 2020.0.2 or later immediately to ensure the use of a cryptographically secure PRNG for key generation. 2. If upgrading is not immediately feasible, disable the vulnerable key exchange algorithms (curve25519-sha256 and curve25519-sha256@libssh.org) in the SSH client and server configurations to prevent their use. 3. Monitor network traffic for unusual SSH handshake patterns or repeated failed connections that might indicate exploitation attempts. 4. Implement network-level protections such as encrypted VPN tunnels or IPsec to reduce the risk of traffic interception. 5. Conduct an inventory of applications and services using SSH.NET to identify and prioritize patching efforts. 6. Educate developers and security teams about the importance of using cryptographically secure PRNGs in all cryptographic operations to prevent similar issues. 7. Review and enhance logging and alerting mechanisms to detect potential man-in-the-middle or eavesdropping attacks on SSH sessions.

Need more detailed analysis?Get Pro

Technical Details

Data Version
5.1
Assigner Short Name
GitHub_M
Date Reserved
2022-04-13T00:00:00.000Z
Cisa Enriched
true

Threat ID: 682d9848c4522896dcbf65e3

Added to database: 5/21/2025, 9:09:28 AM

Last enriched: 6/22/2025, 12:51:45 AM

Last updated: 8/6/2025, 6:42:09 AM

Views: 16

Actions

PRO

Updates to AI analysis are available only with a Pro account. Contact root@offseq.com for access.

Please log in to the Console to use AI analysis features.

Need enhanced features?

Contact root@offseq.com for Pro access with improved analysis and higher rate limits.

Latest Threats