CVE-2022-45047 Overview
CVE-2022-45047 is an insecure deserialization vulnerability affecting Apache MINA SSHD versions 2.9.1 and earlier. The class org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider uses Java deserialization to load a serialized java.security.PrivateKey. This class is one of several implementations that developers using Apache MINA SSHD can choose for loading the host keys of an SSH server. An attacker capable of supplying a maliciously crafted serialized object could exploit this vulnerability to achieve remote code execution on affected systems.
Critical Impact
This insecure deserialization vulnerability allows remote attackers to execute arbitrary code on vulnerable SSH servers by exploiting unsafe Java object deserialization in the host key loading mechanism.
Affected Products
- Apache SSHD versions <= 2.9.1
- Applications and services utilizing SimpleGeneratorHostKeyProvider for SSH host key management
- Systems running Apache MINA SSHD with default or custom configurations using the vulnerable class
Discovery Timeline
- 2022-11-16 - CVE-2022-45047 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2022-45047
Vulnerability Analysis
This vulnerability is classified as CWE-502 (Deserialization of Untrusted Data). The SimpleGeneratorHostKeyProvider class in Apache MINA SSHD implements functionality for loading SSH server host keys from persistent storage. The implementation uses Java's native deserialization mechanism to reconstruct java.security.PrivateKey objects from serialized data.
Java deserialization vulnerabilities are particularly dangerous because they can be exploited to instantiate arbitrary classes and execute code during the deserialization process. When an attacker can control or manipulate the serialized data being processed by SimpleGeneratorHostKeyProvider, they may craft malicious serialized objects that, when deserialized, trigger a chain of method invocations (known as a "gadget chain") leading to arbitrary code execution.
The network-accessible nature of SSH servers makes this vulnerability especially concerning, as remote attackers may be able to exploit it without requiring prior authentication or user interaction.
Root Cause
The root cause is the use of Java's ObjectInputStream for deserializing key material without proper input validation or class whitelisting. Java deserialization is inherently unsafe when processing untrusted data because the deserialization process can instantiate objects and invoke methods based solely on the serialized data stream. The SimpleGeneratorHostKeyProvider fails to implement adequate safeguards against malicious serialized objects.
Attack Vector
The vulnerability is exploitable over the network. An attacker would need to be able to supply a maliciously crafted serialized Java object to the deserialization routine used by SimpleGeneratorHostKeyProvider. This could occur in scenarios where:
- The attacker can manipulate the stored host key file before it is loaded by the SSH server
- The attacker can intercept and modify host key data during transmission if keys are loaded from a remote source
- The attacker has access to inject malicious serialized data through other input vectors that feed into the host key loading process
The exploitation requires the presence of exploitable "gadget" classes in the application's classpath, which is common in Java applications that include libraries such as Apache Commons Collections, Spring Framework, or other commonly used dependencies.
Detection Methods for CVE-2022-45047
Indicators of Compromise
- Unexpected process spawning from Java-based SSH server processes
- Unusual network connections initiated by the SSH server application
- Modifications to host key files or unexpected file access patterns in key storage directories
- Error logs indicating deserialization failures or class loading issues
- Suspicious outbound network traffic from systems running Apache MINA SSHD
Detection Strategies
- Monitor for usage of Apache MINA SSHD versions 2.9.1 or earlier in your software inventory
- Implement file integrity monitoring on SSH host key storage locations
- Deploy runtime application security monitoring (RASP) to detect deserialization attacks
- Analyze Java application logs for anomalous class loading or serialization-related exceptions
- Use network intrusion detection systems to identify potential exploitation traffic patterns
Monitoring Recommendations
- Enable detailed logging for Apache MINA SSHD server instances
- Configure alerting for any modifications to SSH host key files
- Monitor memory and CPU utilization anomalies in SSH server processes
- Track process genealogy to identify unexpected child processes spawned by the SSH server
- Implement network traffic analysis for SSH server systems to detect command and control communications
How to Mitigate CVE-2022-45047
Immediate Actions Required
- Upgrade Apache MINA SSHD to version 2.9.2 or later immediately
- Review applications using Apache MINA SSHD and identify all instances of SimpleGeneratorHostKeyProvider usage
- Consider switching to alternative host key provider implementations that do not use Java deserialization
- Restrict file system access to host key storage locations
- Implement network segmentation to limit exposure of vulnerable SSH server instances
Patch Information
The Apache MINA SSHD project has addressed this vulnerability in versions after 2.9.1. Organizations should upgrade to the latest stable release of Apache MINA SSHD. For detailed information, refer to the Apache Mina Developer Discussion and the NetApp Security Advisory for additional vendor-specific guidance.
Workarounds
- Avoid using SimpleGeneratorHostKeyProvider and implement alternative host key loading mechanisms
- If upgrading is not immediately possible, implement Java serialization filters (JEP 290) to restrict deserializable classes
- Use file system permissions to ensure only trusted processes can write to host key storage locations
- Deploy network-level controls to restrict access to SSH server management interfaces
- Consider implementing a Web Application Firewall (WAF) or similar controls to inspect and filter traffic to SSH services
# Configuration example
# Verify current Apache MINA SSHD version in Maven projects
mvn dependency:tree | grep sshd
# Update pom.xml to use patched version
# Change version from <= 2.9.1 to latest secure version
# <dependency>
# <groupId>org.apache.sshd</groupId>
# <artifactId>sshd-core</artifactId>
# <version>2.10.0</version>
# </dependency>
# Enable Java serialization filtering (Java 9+)
# Add to JVM startup parameters:
# -Djdk.serialFilter=!org.apache.commons.collections.*
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


