Header bannerHeader banner
Advisory ID:
BRLY-DVA-2023-028

[BRLY-DVA-2023-028] SMM memory corruption vulnerability in SMM module on Fujitsu device (SMRAM write)

July 2, 2024
Severity:
High
CVSS Score
8.2
Public Disclosure Date:
June 19, 2024

Summary

Binarly REsearch Team has discovered a SMM memory corruption vulnerability in a Fujitsu device allowing a possible attacker to write fixed or predictable data to SMRAM. Exploiting this issue could lead to escalating privileges to SMM.
Vendors Affected Icon

Vendors Affected

Lenovo
Phoenix
Affected Products icon

Affected Products

Yoga Slim 7 Pro

Potential Impact

An attacker with local access can exploit this vulnerability to elevate privileges from ring 3 or ring 0 (depends on the operating system) to a DXE driver and execute arbitrary code. Malicious code installed as a result of this exploitation could survive operating system (OS) boot process and runtime, or modify NVRAM area on the SPI flash storage (to gain persistence). Additionally, threat actors could use this vulnerability to bypass OS security mechanisms (modify privileged memory or runtime variables), influence OS boot process, and in some cases allow an attacker to hook or modify EFI Runtime services.

This vulnerability was detected by the Deep Vulnerability Analysis (DVA) component from Binarly Platform

Summary

Binarly REsearch Team has discovered a SMM memory corruption vulnerability in a Fujitsu device allowing a possible attacker to write fixed or predictable data to SMRAM. Exploiting this issue could lead to escalating privileges to SMM.

Vulnerability Information

  • BINARLY internal vulnerability identifier: BRLY-DVA-2023-028
  • Fujitsu PSIRT assigned CVE identifier: -
  • AMI PSIRT assigned CVE identifier: -
  • CVSS v3.1: 8.2 High AV:L/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H

Affected AMI-based Fujitsu firmware images with confirmed impact by Binarly REsearch Team

The vulnerability was originally discovered on Fujitsu device mentioned below, however later it was confirmed by AMI PSIRT this issue is inside AMI's product.

Device name Unpacked firmware SHA256 Firmware version IBV Module name Module GUID Module SHA256 Module kind
AU47 M1 d3715136d50fc486ef59fb4aee1d7f06552fdf98423809939538fe905a1aa0b3 V5.0.0.8-R1.40.0 AMI SmmRuntime 7c79ac8c-5e6c-4e3d-ba6f-c260ee7c172e 1be4cbba75688e77901f12cbe9964c69421ec13cc0493f12df2fc339e4b77a5d SmmModule
PRIMERGY RX4770 M2 083adc7cc324137950b4bc36308340e3b60b14ab97b7d967f33168930de4973c V5.0.0.9-R1.20.0 AMI SmmRuntime 7c79ac8c-5e6c-4e3d-ba6f-c260ee7c172e 23c3e456e964e0667c2e17794c8b95715701ccdc5926cad4c86387f925c26b08 SmmModule

Potential impact

An attacker can exploit this vulnerability to elevate privileges from ring 0 to ring -2, execute arbitrary code in System Management Mode - an environment more privileged than operating system (OS) and completely isolated from it. Running arbitrary code in SMM additionally bypasses SMM-based SPI flash protections against modifications, which can help an attacker to install a firmware backdoor/implant into BIOS. Such a malicious firmware code in BIOS could persist across operating system re-installs. Additionally, this vulnerability potentially could be used by malicious actors to bypass security mechanisms provided by UEFI firmware (for example, Secure Boot and some types of memory isolation for hypervisors).

Vulnerability description

Let's consider the vulnerability on the example of a module with SHA256 d3715136d50fc486ef59fb4aee1d7f06552fdf98423809939538fe905a1aa0b3. The pseudocode of the vulnerable ChildSwSmiHandler function (with the HandlerType: EFI_SMM_RUNTIME_PROTOCOL_GUID) is presented below:

EFI_STATUS __fastcall ChildSwSmiHandler(
        EFI_HANDLE DispatchHandle,
        const void *Context,
        char *CommBuffer,
        UINTN *CommBufferSize)
{
  __int64 Ptr; // [rsp+20h] [rbp-18h]

  Ptr = *(CommBuffer + 4);
  if ( Ptr )
  {
    (*(Ptr + 8))(*Ptr, gSmst, CommBuffer + 24);
    *((_QWORD *)CommBuffer + 4) = 0; // Arbitrary write (*CommBufferSize is not checked)
  }
  return EFI_SUCCESS;
}

As we can see, input Communication Buffer is not validated to be outside of SMRAM since the Communication Buffer size (*CommBufferSize) is not checked to be valid (not 0 or equal to any fixed expectable value) for relying on the validation implemented in PiSmmCommunicationSmm module (based on a Communication Header).

In this way, a potential attacker can point CommBuffer just before SMRAM and set *CommBufferSize to 1 in order to pass validation in PiSmmCommunicationSmm and corrupt SMRAM (from SMRAM_BASE to SMRAM_BASE + 39).

In order to fix this vulnerability, check for *CommBufferSize should be added:

Ptr2 = (CommBuffer[22] + 8);
for ( i = *Ptr2; i != Ptr2; i = *i )
{
    i[24] = 0;                             // unchecked write (SMRAM corruption)
    i[4] = 0;                              // unchecked write (SMRAM corruption)
    i[6] = 0;                              // unchecked write (SMRAM corruption)
}

Disclosure timeline

This bug is subject to a 90 day disclosure deadline. After 90 days elapsed or a patch has been made broadly available (whichever is earlier), the bug report will become visible to the public.

Disclosure Activity Date (YYYY-mm-dd)
Fujitsu PSIRT is notified 2023-12-22
Binarly Public Disclosure Date 2024-05-15

Acknowledgements

Binarly REsearch Team

Tags
Fujitsu
Vulnerability
FWHunt
See if you are impacted now with our Firmware Vulnerability Scanner