CVE Professor
/
All CVEs
CVE-2026-138376

CVE-2026-138376 — Ronf Asyncssh — CWE-287

MEDIUM CVSS 7.4 ⚡ EPSS 0.8% Shodan

AsyncSSH 1.13.1 before 2.24.2 contains an improper authentication vulnerability in SSHConnection._match_known_hosts that accumulates trusted client host keys across host-based authentication attempts on one connection. With trust_client_host enabled, attackers holding one known client host's private key can retry naming another known host and log in as users authorized only from that host.

AsyncSSH 1.13.1 before 2.24.2 contains an improper authentication vulnerability in SSHConnection._match_known_hosts that accumulates trusted client host keys across host-based authentication attempts on one connection. With trust_client_host enabled, attackers holding one known client host's private key can retry naming another known host and log in as users authorized only from that host.

CVSS v3.1 Vector Metrics
CVSS:3.1/AV:N/AC:H/PR:H/UI:N/S:U/C:H/I:H/A:N
Attack Vector Network AV:N
Attack Complexity High AC:H
Privileges Req. High PR:H
User Interaction None UI:N
Scope Unchanged S:U
Confidentiality High C:H
Integrity High I:H
Availability None A:N
EPSS — Exploit Prediction Scoring System
0.8%
30-day probability
In the 57. percentile of all CVEs — higher exploitation probability than most vulnerabilities.
AI Security Analysis & Remediation

🎯 What is this vulnerability?

This vulnerability is a logic flaw in host-based authentication state management within the AsyncSSH Python library. Specifically, it affects the SSHConnection._match_known_hosts method.

Technical Flaw:
When trust_client_host is enabled (a feature allowing the server to trust client host keys for authentication), the library fails to properly isolate or reset the set of "trusted" client host keys between different authentication attempts on the same SSH connection.

1. State Accumulation: The method accumulates trusted client host keys. If an attacker presents a valid host key for Host A, that key is added to the internal trusted set for that connection session.
2. Lack of Reset: When the attacker subsequently attempts to authenticate as a different user or claims to be from Host B, the previously trusted key for Host A remains in the trusted set.
3. Bypass Mechanism: If the server's authorized_keys or host-based authentication configuration allows access from Host B, and the attacker can somehow satisfy the host key check for Host B (or if the logic incorrectly allows the accumulated trust from Host A to satisfy the requirement for Host B due to improper scoping), the authentication succeeds.

Essentially, the server confuses "I have seen a valid key for Host A" with "The current connection is from a trusted host," allowing an attacker who possesses the private key for any known client host to potentially authenticate as users authorized only from other known hosts, provided the connection context allows the state to persist.

CWE-287 (Improper Authentication): The system fails to properly verify the identity of the client by relying on accumulated state rather than the specific host key presented in the current authentication attempt.

⚡ Attack Chain

1. Discovery & Reconnaissance

  • Target Identification: Identify services running AsyncSSH (common in Python-based SSH servers, IoT devices, or custom automation frameworks).
  • Version Check: Use nmap with the ssh2 script or manual banner grabbing to identify the AsyncSSH version.
  • nmap -sV -p 22 --script ssh2 <target_ip>
        # Look for "SSH-2.0-AsyncSSH_1.13.1" or similar
  • Configuration Audit: Determine if trust_client_host is enabled. This is often a non-default setting, so it requires specific server configuration. An attacker might attempt to connect and observe if host-based authentication is accepted.
  • 2. Exploitation

    Prerequisites:
  • Attacker possesses the private host key for at least one known client host (Host A) that is trusted by the server.
  • The target user account is authorized to log in from a different* known client host (Host B) via host-based authentication.
  • trust_client_host is enabled on the server.
  • Mechanism:
    1. The attacker initiates an SSH connection to the target.
    2. The server requests the client host key.
    3. The attacker presents the valid private key for Host A.
    4. The server verifies Host A's key and adds it to the internal trusted set for this connection.
    5. The attacker then attempts to authenticate as a user who is only authorized from Host B.
    6. Due to the bug in _match_known_hosts, the server's internal state still considers the connection "trusted" because Host A's key was accepted, or the logic fails to strictly bind the current authentication attempt to the specific host key required for the user's authorization.
    7. Authentication succeeds.

    Illustrative PoC (Conceptual):
    Note: This is a conceptual representation. Actual exploitation requires a custom SSH client that can manipulate the host key presentation sequence or exploit the state accumulation bug. Standard ssh clients do not easily allow presenting multiple host keys in a single authentication flow in this manner.

    # Conceptual Python PoC using AsyncSSH client (illustrative)
    import asyncio
    import asyncssh
    
    async def exploit():
        # Attacker has private key for Host A (trusted)
        # Target user is only authorized from Host B
        
        # Step 1: Connect and present Host A's key
        # In a real attack, the attacker might need to force the server to 
        # accept Host A's key first, then attempt user auth for a Host B-only user.
        
        # This is highly dependent on the specific implementation of the server's 
        # authentication flow. The bug implies that once a host key is trusted, 
        # subsequent auth attempts might bypass strict host matching.
        
        try:
            conn = await asyncssh.connect(
                'target_ip',
                username='victim_user', # User authorized only from Host B
                client_keys=['host_a_private_key.pem'], # Presenting Host A's key
                known_hosts=None # Disable client-side host verification for testing
            )
            print("[+] Authentication successful despite host mismatch!")
            await conn.close()
        except asyncssh.DisconnectError as e:
            print(f"[-] Failed: {e}")
    
    asyncio.run(exploit())

    Important: The exact exploitation may require a custom SSH client that can send multiple host key authentication attempts in a specific sequence to trigger the state accumulation bug. Standard ssh clients typically present one host key per attempt.

    3. Post-Exploitation

  • Access: The attacker gains shell access as the victim_user.
  • Privilege Escalation: If victim_user has sudo privileges or is part of a privileged group, the attacker can escalate to root.
  • Lateral Movement: With access to the host, the attacker can pivot to other internal systems.
  • Data Exfiltration: Access to files, databases, or other sensitive data on the host.
  • 🌍 Real World Impact

  • Confidentiality (High): Unauthorized access to user accounts and their data.
  • Integrity (High): Attacker can modify files, configurations, or data as the compromised user.
  • Availability (None): No direct impact on service availability.
  • Practical Consequences:
    Bypass of Host-Based Restrictions: Organizations that rely on host-based authentication (e.g., "only allow access from the build server") can be bypassed if an attacker compromises the private key of any* other trusted host.

  • Lateral Movement: An attacker who compromises one low-privilege host (Host A) can use its host key to access other hosts (Host B) that only trust Host B, if the server's trust_client_host is enabled and the bug is present.

  • Trust Model Breakdown: The integrity of the host-based authentication model is compromised, making it unreliable for access control.
  • 🛡️ Remediation & Mitigation

    1. Upgrade

  • Affected Versions: AsyncSSH 1.13.1 prior to 2.24.2.
  • Fix: Upgrade to AsyncSSH version 2.24.2 or later.
  • pip install --upgrade asyncssh

    2. Workarounds

  • Disable trust_client_host: If host-based authentication is not strictly required, disable trust_client_host in the server configuration. This is the most effective mitigation.
  • # In AsyncSSH server configuration
        server = asyncssh.SSHServer(
            host_keys=['server_host_key.pem'],
            trust_client_host=False  # Disable host-based authentication
        )
  • Restrict Access: If host-based authentication is required, ensure that only critical, highly secured hosts are added to the trusted list. Avoid trusting hosts that may be compromised.
  • Network Segmentation: Restrict SSH access to trusted hosts via firewall rules (e.g., iptables or cloud security groups) to limit the attack surface.
  • 3. Detection

  • Log Analysis: Monitor SSH server logs for authentication attempts where the client host key does not match the expected host for the user.
  • * Look for patterns where a user authorized from Host B authenticates using Host A's key. * Example log pattern (varies by implementation):
    Accepted publickey for victim_user from 192.168.1.100 port 54321 ssh2: RSA SHA256:HostAKeyFingerprint

    If victim_user is only authorized from Host B, this is a potential indicator of exploitation.

  • Host Key Monitoring: Monitor for unexpected changes in client host keys. If a trusted host's key changes, investigate immediately.

  • Unusual Authentication Sequences: Look for multiple authentication attempts from the same IP address with different host keys in a short period.
  • ⚠️ Urgency

  • CVSS Score: 7.4 (Medium)
  • CISA KEV: No
  • Exploit Complexity: High (Requires specific configuration trust_client_host enabled, possession of a trusted host's private key, and knowledge of the bug).
  • Patching Priority: Medium-High

  • Immediate Action: If trust_client_host is enabled in your environment, upgrade to AsyncSSH 2.24.2 immediately. The risk is significant if you rely on host-based authentication for access control.
  • If trust_client_host is disabled: The risk is low, but upgrading is still recommended as part of regular patch management.
  • Justification: While the exploit complexity is high, the impact is severe (bypass of authentication controls). Organizations using host-based authentication for security boundaries should treat this as a priority.
[🤖 CVE Professor AI Security Engine]
Target Reconnaissance Queries (FOFA & Shodan)

FOFA Query

app="ronf asyncssh"
PoC & Exploit Intelligence (GitHub)
Technical reference / advisory repository for CVE-2026-138376
Technical reference / advisory repository for CVE-2026-138376
Technical reference / advisory repository for CVE-2026-138376
Technical reference / advisory repository for CVE-2026-138376
CVSS Score
7.4 / 10 · CVSS MEDIUM
Weakness Types (CWE)
Affected Products (1)
ronf:asyncssh
Related CVEs
6.0
CVE-2026-144666
AsyncSSH before 2.24.2 contains an arbitrary file write vulnerability in the SCP client that allows malicious
9.8
CVE-2026-145051
WWBN AVideo before 29.9.0 contains an authentication bypass vulnerability in the LoginWordPress plugin that al
9.3
CVE-2026-47677
FacturaScripts is an open source accounting and invoicing software. Prior to version 2026.3, there is an authe
8.7
CVE-2026-120762
Improper authorization in the push-publish bundle receiver (user import handler) in dotCMS versions before 26.
8.1
CVE-2026-145022
ZITADEL from 4.0.0 before 4.20.5 contains an MFA bypass vulnerability in Login V2 that allows attackers knowin
7.7
CVE-2026-132111
Improper authentication in the legacy login path (LoginFactory.doLogin) in dotCMS versions before 26.11.11-01
5.4
CVE-2026-144906
A flaw was found in the UMA permission grant implementation of Keycloak, an identity and access management sol