/

CVE-2026-45309

Severity:

HIGH RISK

(7.5)

Path Traversal (CWE-22) in AsyncSSH AuthorizedKeysFile

CVE-2026-45309

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Authentication Bypass via Unauthorized Key Files

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

AsyncSSH expands an AuthorizedKeysFile %u token using the raw SSH username, allowing path traversal sequences to escape the intended authorized-keys directory.

When a server is configured with user-expanded authorized-keys paths, an attacker-controlled username containing traversal characters may cause the server to read and trust an attacker-selected key file.

AsyncSSH expands an AuthorizedKeysFile %u token using the raw SSH username, allowing path traversal sequences to escape the intended authorized-keys directory.

When a server is configured with user-expanded authorized-keys paths, an attacker-controlled username containing traversal characters may cause the server to read and trust an attacker-selected key file.

Affected context

This vulnerability occurs in AsyncSSH server deployments that:

  • Use OpenSSH-compatible AuthorizedKeysFile directives
  • Include the %u token for per-user authorized key paths (e.g., authorized_keys/%u)
  • Accept or derive SSH usernames that are not sanitized for path traversal characters

Under these conditions, the server's key lookup logic can be directed outside the intended authorized-keys directory.

This vulnerability occurs in AsyncSSH server deployments that:

  • Use OpenSSH-compatible AuthorizedKeysFile directives
  • Include the %u token for per-user authorized key paths (e.g., authorized_keys/%u)
  • Accept or derive SSH usernames that are not sanitized for path traversal characters

Under these conditions, the server's key lookup logic can be directed outside the intended authorized-keys directory.

Exploit preconditions

  • Attack surface: SSH server authentication logic using AsyncSSH
  • Required access: Ability to initiate SSH connections and supply a crafted SSH username
  • Trigger point: Expansion of the AuthorizedKeysFile %u token during pre-authentication config reload and key file resolution
  • Why exploitation is possible: The username is interpolated into file paths without normalization or validation, enabling traversal via /, \, or .. segments
  • Attack surface: SSH server authentication logic using AsyncSSH
  • Required access: Ability to initiate SSH connections and supply a crafted SSH username
  • Trigger point: Expansion of the AuthorizedKeysFile %u token during pre-authentication config reload and key file resolution
  • Why exploitation is possible: The username is interpolated into file paths without normalization or validation, enabling traversal via /, \, or .. segments

Why this happens

The underlying bug stems from unsafe use of user-controlled data in filesystem paths.

AsyncSSH expands the %u placeholder in AuthorizedKeysFile using the raw SSH username and then directly uses that value to construct the path to the authorized-keys file.

Without proper sanitization, normalization, or restriction to a fixed directory root, this behavior matches CWE-22: Improper Limitation of a Pathname to a Restricted Directory, as attackers can introduce traversal sequences to access files outside the expected location and influence authentication decisions.

The underlying bug stems from unsafe use of user-controlled data in filesystem paths.

AsyncSSH expands the %u placeholder in AuthorizedKeysFile using the raw SSH username and then directly uses that value to construct the path to the authorized-keys file.

Without proper sanitization, normalization, or restriction to a fixed directory root, this behavior matches CWE-22: Improper Limitation of a Pathname to a Restricted Directory, as attackers can introduce traversal sequences to access files outside the expected location and influence authentication decisions.

Potential impact

  • An attacker could cause the server to load an authorized-keys file from an unintended directory.
  • Authentication may succeed using public keys not actually associated with the target account.
  • SSH access could be granted based on attacker-selected key material, effectively bypassing normal account authorization.
  • Misuse of arbitrary filesystem locations may expose sensitive configuration or key files used in authentication decisions.
  • An attacker could cause the server to load an authorized-keys file from an unintended directory.
  • Authentication may succeed using public keys not actually associated with the target account.
  • SSH access could be granted based on attacker-selected key material, effectively bypassing normal account authorization.
  • Misuse of arbitrary filesystem locations may expose sensitive configuration or key files used in authentication decisions.

General mitigation guidance

Mitigation generally focuses on constraining how user input influences filesystem paths and enforcing strict directory boundaries.

Recommended defensive patterns include:

  • Normalizing and validating usernames before using them in path expansion, rejecting any containing /, \, or ...
  • Confining AuthorizedKeysFile lookups to a fixed base directory and enforcing that resolved paths remain within that directory.
  • Avoiding direct interpolation of user-controlled values into file paths; instead, map usernames to safe, canonical identifiers.
  • Applying least-privilege to the SSH service's filesystem access so that even misdirected paths cannot reach sensitive files.

Mitigation generally focuses on constraining how user input influences filesystem paths and enforcing strict directory boundaries.

Recommended defensive patterns include:

  • Normalizing and validating usernames before using them in path expansion, rejecting any containing /, \, or ...
  • Confining AuthorizedKeysFile lookups to a fixed base directory and enforcing that resolved paths remain within that directory.
  • Avoiding direct interpolation of user-controlled values into file paths; instead, map usernames to safe, canonical identifiers.
  • Applying least-privilege to the SSH service's filesystem access so that even misdirected paths cannot reach sensitive files.

How teams detect issues like this

Detection typically involves examining both configuration and code paths where usernames influence filesystem access.

Approaches include:

  • Static analysis rules that flag path construction using raw usernames or other user-controlled identifiers.
  • Code review practices that look for AuthorizedKeysFile or similar directives using expansion tokens without validation.
  • Configuration audits to identify patterns like authorized_keys/%u and confirm associated sanitation logic.
  • File access monitoring around the authorized-keys directory to detect unexpected lookups in sibling or parent directories.

Detection typically involves examining both configuration and code paths where usernames influence filesystem access.

Approaches include:

  • Static analysis rules that flag path construction using raw usernames or other user-controlled identifiers.
  • Code review practices that look for AuthorizedKeysFile or similar directives using expansion tokens without validation.
  • Configuration audits to identify patterns like authorized_keys/%u and confirm associated sanitation logic.
  • File access monitoring around the authorized-keys directory to detect unexpected lookups in sibling or parent directories.

Sources

SourceLink
github.comgithub.com/ronf/asyncssh/commit/2af2382cce946c959a378a62f257af253dc4ab51
github.comgithub.com/ronf/asyncssh/commit/3d515ba9ba0cd9990d248bdf62bcf05d51261a88
github.comgithub.com/ronf/asyncssh/security/advisories/GHSA-g794-3fmp-753h

Frequently asked

questions

It primarily affects SSH authentication decisions. While it does not directly provide arbitrary code execution, successful unauthorized SSH logins can be a stepping stone toward broader compromise depending on account privileges and server hardening.

The attacker needs network access to the AsyncSSH server and the ability to initiate SSH sessions using crafted usernames. No prior filesystem or local account access is required for exploitation.

The safest pattern is to ensure that user-controlled data is never used directly in filesystem paths. Implement strict validation and normalization of usernames, enforce directory confinement for key files, and prefer mapping usernames to trusted, internal identifiers.

Establish coding standards that prohibit unsanitized input in path construction, use APIs or utility functions that enforce directory boundaries, and integrate automated checks—such as static analysis and configuration linting—into the development and deployment pipeline to catch risky patterns early.

It primarily affects SSH authentication decisions. While it does not directly provide arbitrary code execution, successful unauthorized SSH logins can be a stepping stone toward broader compromise depending on account privileges and server hardening.

The attacker needs network access to the AsyncSSH server and the ability to initiate SSH sessions using crafted usernames. No prior filesystem or local account access is required for exploitation.

The safest pattern is to ensure that user-controlled data is never used directly in filesystem paths. Implement strict validation and normalization of usernames, enforce directory confinement for key files, and prefer mapping usernames to trusted, internal identifiers.

Establish coding standards that prohibit unsanitized input in path construction, use APIs or utility functions that enforce directory boundaries, and integrate automated checks—such as static analysis and configuration linting—into the development and deployment pipeline to catch risky patterns early.

Find out what's already
exploitable in your codebase.