A critical bug that can leak secret cryptographic keys has just just been fixed in OpenSSH, one of the more widely used implementations of the secure shell (SSH) protocol.

The vulnerability resides only in the version end users use to connect to servers and not in versions used by servers. A maliciously configured server could exploit it to obtain the contents of the connecting computer's memory, including the private encryption key used for SSH connections. The bug is the result of code that enables an experimental roaming feature in OpenSSH versions 5.4 to 7.1

"The matching server code has never been shipped, but the client code was enabled by default and could be tricked by a malicious server into leaking client memory to the server, including private client user keys," OpenSSH officials wrote in an advisory published Thursday. "The authentication of the server host key prevents exploitation by a man-in-the-middle, so this information leak is restricted to connections to malicious or compromised servers."

The advisory said that anyone using a vulnerable version should update right away. Those who are unable to update should disable roaming by adding the string UseRoaming no to the global ssh_config(5) file or to the user configuration in ~/.ssh/config, or by entering -UseRoaming=no on the command line.

According to a separate advisory from Qualys, the security firm that discovered and privately reported the vulnerability, the information leak can be exploited only after the end user has been successfully authenticated by the server. While that drastically reduces the chances of the bug being exploited in the wild, Qualys researchers held out the possibility that highly determined attackers already may have made use of the bug, possibly by compromising legitimate servers trusted by end users. Such exploits would be useful once attackers had already compromised a targeted server and wanted to ensure continued access in the event the initial entry point had been fixed.

"This information leak may have already been exploited in the wild by sophisticated attackers, and high-profile sites or users may need to regenerate their SSH keys accordingly," they wrote.

By giving attackers the ability to read the RAM of vulnerable computers, the bug has similarities to the 2014 Heartbleed vulnerability that affected the OpenSSL crypto library. That bug was much more serious because it made it possible for anyone with moderate hacking skills to exploit any website that used OpenSSL. By contrast, the OpenSSH bug can only be exploited after a vulnerable end user connects to a maliciously configured server.

Post updated to add details from Qualys advisory.