A vulnerability has been discovered in OpenSSH versions up to 9.6, which, under specific threat scenarios, might allow attackers to bypass authentication by manipulating the bit in the memory location. Known as "row hammer" attack, this exploit targets the common types of DRAM used in memory storage. However, it is crucial to note that this vulnerability is only applicable when the attacker and victim share the same physical hardware and the attacker already has user access privileges. This post will dive into the details of the exploit, its threat model, and the steps to reproduce the issue. Please refer to the original references for a more in-depth analysis.

Vulnerability Details

In OpenSSH, the authentication process relies on an integer value called authenticated in the mm_answer_authpassword function. If an attacker can flip a single bit in the memory location holding this authenticated value, they can potentially bypass the authentication mechanism and gain unauthorized access to the system.

The exploit takes advantage of a hardware vulnerability in DRAM. It repeatedly accesses specific memory addresses, causing disturbance errors on neighboring rows of memory cells and affecting the stored data, effectively flipping bits in those neighboring cells. Without adequate mitigation in place, an attacker can exploit this aspect of the DRAM hardware to specifically target OpenSSH's authentication mechanism.

Here is the relevant code snippet from OpenSSH

/* mm_auth.c */
mm_answer_authpassword(struct ssh *ssh, int passok)
    if (authenticated) {
      auth_success(ssh, authctxt, method);

In this code snippet, the logic checks if the authenticated integer value is set. The row hammer attack would attempt to modify the value of authenticated, effectively bypassing the check and forcing successful authentication.

- Original bug report: https://bugzilla.mitre.org/show_bug.cgi?id=CVE-2023-51767
- Exploit details, PoC, and mitigation: https://github.com/openssh/openssh-portable/commit/7f82dedeaf5487023fd239e6e5091408c211e7a
- Analysis of row hammer attack: https://en.wikipedia.org/wiki/Row_hammer

Threat Model and Reproduction

As mentioned earlier, the exploit has a specific threat model: the attacker and victim must share the same physical hardware, and the attacker already has user access privileges. Given this requirement, the vulnerability is particularly relevant for multi-tenant environments, such as shared hosting or public cloud infrastructure.

Co-locate on the same DRAM bank as the victim.

2. Execute a row hammer attack targeting the victim's DRAM cells (see links for more details on how to perform the attack).

Conclusion and Recommendation

The row hammer attack vulnerability (CVE-2023-51767) in OpenSSH puts authentication mechanisms at risk. Further research on this vulnerability and possible mitigation strategies is highly recommended. However, given the specific threat model, those administering systems that are not exposed to such attacker-victim co-location scenarios may not be affected. Always keep your OpenSSH installation up-to-date and make sure you follow best practices in secure system administration.


Published on: 12/24/2023 07:15:07 UTC
Last modified on: 01/29/2024 20:00:11 UTC