Improper Certificate Validation Affecting asyncssh package, versions [1.13.1,2.24.2)


Severity

Recommended
0.0
high
0
10

CVSS assessment by Snyk's Security Team. Learn more

Threat Intelligence

Exploit Maturity
Proof of Concept
EPSS
0.48% (44th percentile)

Do your applications use this vulnerable package?

In a few clicks we can analyze your entire application and see what components are vulnerable in your application, and suggest you quick fixes.

Test your applications
  • Snyk IDSNYK-PYTHON-ASYNCSSH-23050765
  • published30 Nov 2026
  • disclosed29 Nov 2026
  • creditChris Purcell

Introduced: 29 Nov 2026

NewCVE-2026-138377  (opens in a new tab)
CWE-295  (opens in a new tab)

How to fix?

Upgrade asyncssh to version 2.24.2 or higher.

Overview

Affected versions of this package are vulnerable to Improper Certificate Validation via the _match_known_hosts function in connection.py when a server uses host-based authentication with known_client_hosts. The vulnerability has two related problems: first, trusted host keys from one host-based authentication attempt accumulate across attempts on the same connection rather than being replaced, allowing a client holding the host key of one known client host to pass the host key check while claiming to be a different known client host; second, X.509 certificates matched in known_client_hosts are appended to the server's global trusted certificate list, causing them to be accepted as trust anchors when validating X.509 user certificates for the remainder of the connection. An attacker can exploit the second problem by making a failed host-based authentication attempt with any host key, which promotes host-only CA certificates into the user-authentication trust store, then authenticating with a user certificate issued under those CAs.

Note: Problem 1 requires trust_client_host to be enabled and a custom validate_host_based_user() that uses client_host in its decision. Problem 2 requires X.509 certificates to be listed in known_client_hosts on a server that also accepts X.509 user certificates by subject name.

Workaround

For problem 1, leave trust_client_host disabled (the default), or do not rely on client_host in validate_host_based_user(). For problem 2, do not list X.509 certificates in known_client_hosts on servers that also accept X.509 user certificates by subject name.

PoC

For problem 1, on the server, `known_client_hosts` lists `build1.corp.test` with host key A and `admin-ws.corp.test` with host key B, and `trust_client_host` is set. `validate_host_based_user()` allows user `admin` only when `client_host` is `admin-ws.corp.test`.

A client holding only host key A makes two host-based attempts on one connection:

1. a request naming `build1.corp.test` (it may fail)
2. a request for user `admin` naming `admin-ws.corp.test`, signed with host key A

The second request passes the host key check, the callback is called with `admin-ws.corp.test`, and the login as `admin` is accepted. A single request naming `admin-ws.corp.test` with host key A is rejected. The stock client sends one host name per connection, so the test client was changed to send a different name on its second attempt.

For problem 2, on the server, `known_client_hosts` contains `* <X.509 CA certificate>`, the authorized keys contain `x509v3-sign-rsa subject=CN=admin`, and no other X.509 certificates are trusted. A user certificate for `CN=admin` issued by that CA is rejected on its own, but accepted if the client first makes a host-based attempt with any host key.

Note: The section describes two server-side scenarios using known_client_hosts configuration but states no specific runtime versions, operating system, or non-default configuration beyond what is described in the vulnerability itself.

CVSS Base Scores

version 4.0
version 3.1