Libssh Vulnerability Exposes Servers to Attacks
19.10.2018 securityweek
Vulnerebility

Servers using libssh to implement the Secure Shell (SSH) remote login protocol may be vulnerable to attacks due to the existence of an authentication bypass flaw discovered recently by a researcher.

Peter Winter-Smith, security consultant at NCC Group, found that versions 0.6 and later of libssh are affected by a flaw that can be exploited by an attacker to authenticate on a server without needing any credentials.

When authentication is initiated, the server expects a SSH2_MSG_USERAUTH_REQUEST message. However, Winter-Smith discovered that an attacker can trick the server into believing authentication was successful by sending it a SSH2_MSG_USERAUTH_SUCCESS message, which is normally only intended for communications from the server to the client.

The vulnerability, tracked as CVE-2018-10933, was patched on Tuesday with the release of libssh 0.8.4 and 0.7.6. The issue was reported to libssh developers on June 25.

An Internet scan conducted with the Shodan search engine shows over 6,300 servers using libssh, and a Censys scan reveals more than 3,300 servers. However, many of them may not be vulnerable to attacks leveraging CVE-2018-10933.

"Not all libSSH servers will necessarily be vulnerable to the authentication bypass," explained Winter-Smith. "Since the authentication bypass sets the internal libSSH state machine to authenticated without ever giving any registered authentication callbacks an opportunity to execute, servers developed using libSSH which maintain additional custom session state may fail to function correctly if a user is authenticated without this state being created."

Many users were concerned about the risk posed by the vulnerability, especially since libssh is also used by GitHub. However, GitHub clarified that while it applied the patches "out of an abundance of caution," the vulnerability did not affect its services due to how the library is used.

Experts also clarified that the vulnerability does not impact OpenSSH, libssh2, curl, or libcurl. Linux distributions are affected, but their developers should release patches in the upcoming period.

NCC Group has published a technical advisory for the vulnerability, which also includes proof-of-concept (PoC) code.

"It is important to note that the authentication bypass exploit detailed above is the most obvious route to exploitation for the overarching issue – the libSSH server state machine is vulnerable to being updated by messages intended only for handling on the client side," Winter-Smith clarified. "Even servers which are not vulnerable to the authentication bypass will may still be vulnerable to other unexpected state manipulation issues, so it is imperative that all services built on top of libSSH are updated even if not demonstrated vulnerable to the authentication bypass."