Header bannerHeader banner
Advisory ID:
BRLY-2021-013

[BRLY-2021-013] SMM memory corruption vulnerability in combined DXE/SMM driver on Fujitsu device (SMRAM write)

February 4, 2022
Severity:
High
CVSS Score
8.2
Public Disclosure Date:
February 1, 2022

Summary

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

Vendors Affected

Fujitsu
Affected Products icon

Affected Products

Fujitsu LIFEBOOK A3510

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 the BIOS. Such a malicious firmware code in the BIOS could persist across operating system re-installs. Additionally, this vulnerability could potentially be used by threat actors to bypass security mechanisms provided by UEFI firmware (for example, Secure Boot and some types of memory isolation for hypervisors).

Summary

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

Vulnerability Information

  • BINARLY internal vulnerability identifier: BRLY-2021-013
  • CERT/CC assigned case number: VU#796611
  • Insyde PSIRT assigned CVE identifier: CVE-2021-33626
  • CVSS v3.1: 8.2 High AV:L/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H

Affected Fujitsu firmwares with confirmed impact by Binarly REsearch Team

Device name Driver name Driver SHA256 File GUID
Fujitsu LIFEBOOK A3510 SmmResourceCheckDxe 63d2e3d3d8308b77bc35c96098b7b2d9eb119d89e467a6cd5ac82d2e8eef84ec E503CA98-B63E-4592-9BCD-5A4452355134
Fujitsu LIFEBOOK U9310 SmmResourceCheckDxe 45e2f646c1699bd0019f0e4788ba8e8b35af9422f2b5e893e2418113b0f2666c E503CA98-B63E-4592-9BCD-5A4452355134
Fujitsu LIFEBOOK U7511/U7411/U7311 SmmResourceCheckDxe a7b2b0a0e3dd8731c1ee6e241134b002327f5518ef7a69fb866220d436b2a89e E503CA98-B63E-4592-9BCD-5A4452355134
Fujitsu LIFEBOOK U9311 SmmResourceCheckDxe a7b2b0a0e3dd8731c1ee6e241134b002327f5518ef7a69fb866220d436b2a89e E503CA98-B63E-4592-9BCD-5A4452355134
Fujitsu LIFEBOOK E5510/E5410 SmmResourceCheckDxe 45e2f646c1699bd0019f0e4788ba8e8b35af9422f2b5e893e2418113b0f2666c E503CA98-B63E-4592-9BCD-5A4452355134
Fujitsu LIFEBOOK U7510/U7410/U7310 SmmResourceCheckDxe 45e2f646c1699bd0019f0e4788ba8e8b35af9422f2b5e893e2418113b0f2666c E503CA98-B63E-4592-9BCD-5A4452355134

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 the BIOS. Such a malicious firmware code in the BIOS could persist across operating system re-installs. Additionally, this vulnerability could potentially be used by threat actors to bypass security mechanisms provided by UEFI firmware (for example, Secure Boot and some types of memory isolation for hypervisors).

Vulnerability description

In the function at offset 0x1294 (image sha256: 63d2e3d3d8308b77bc35c96098b7b2d9eb119d89e467a6cd5ac82d2e8eef84ec), the child software System Management Interrupt (SWSMI) handler with GUID 4b52e4da-60eb-4ec2-a80c-f9fd0ab85e97 is registered:

__int64 sub_80001294()
{
  // [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]

  v0 = 0;
  if ( SmstIsNotNull() )
  {
    result = gEfiBootServices->LocateProtocol(&EFI_SMM_ACCESS2_PROTOCOL_GUID, 0, &EfiSmmAccess2Protocol);
    if ( result < 0 )
      return result;
    Size = 0;
    EfiSmmAccess2Protocol->GetCapabilities(EfiSmmAccess2Protocol, &Size, 0);
    SmramMap = 0;
    gSmst_36F0->SmmAllocatePool(EfiRuntimeServicesData, Size, &SmramMap);
    EfiSmmAccess2Protocol->GetCapabilities(EfiSmmAccess2Protocol, &Size, SmramMap);
    gSmramRangeCount = Size >> 5;
    return gSmst_36F0->SmiHandlerRegister(SmiHandler_1278, &gSmiHandlerGuid, &DispatchHandle);
  }
  else
  {
    CommBuffer = sub_80001878(56);
    if ( !CommBuffer )
      return EFI_OUT_OF_RESOURCES;
    (CreateEventEx)(8);
  }
  return v0;
}

Find below the decompiled SWSMI handler code:

EFI_STATUS __fastcall SmiHandler_1278(
        EFI_HANDLE DispatchHandle,
        const void *Context,
        void *CommBuffer,
        UINTN *CommBufferSize)
{
  // [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]

  if ( *CommBuffer == 1 )
    sub_80001454(CommBuffer);
  return 0;
}

If the first QWORD from CommBuffer is 1, the function sub_80001454() will be called. Part of its decompiled output is shown below:

__int64 __fastcall sub_80001454(void *CommBuffer)
{
  // [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]

  RangeCount = gSmramRangeCount;
  TotalSize = 0;
  if ( gSmramRangeCount )
  {
    p_PhysicalSize = &SmramMap->PhysicalSize;
    do
    {
      TotalSize += *p_PhysicalSize;
      p_PhysicalSize += 4;
      --RangeCount;
    }
    while ( RangeCount );
  }
  *((_QWORD *)CommBuffer + 2) = TotalSize;
  ...
  *((_QWORD *)CommBuffer + 1) = 0;
  *((_QWORD *)CommBuffer + 3) = Value;
  return result;
}

This shows that the 2nd, 3rd and 4th QWORDs from the CommBuffer will be overwritten.

There is no pointer validation carried out (to ensure CommBuffer and any other Communication Buffer nested contents are not pointing to SMRAM contents). Thus, a potential attacker can write fixed data to SMRAM to corrupt some data inside this memory (for example, change SMI handler's code or modify Smram Map structures to break input pointer validation for other SMI handlers, hence to completely make this mitigation inefficient). This could lead to gaining arbitrary code execution in SMM.

To fix this vulnerability, it is essential to wrap all the input pointers (including the nested pointers) for SMI handlers with sanity checks to make sure they are not pointing into SMRAM.

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
Fujitsu PSIRT is notified 2021-09-10
Fujitsu PSIRT is confirmed issue 2021-09-14
CERT/CC created a case 2021-09-27
Insyde PSIRT assigned CVE number 2021-11-01
Insyde PSIRT provide patch release 2021-11-09
BINARLY public disclosure date 2022-02-01

Acknowledgements

Binarly REsearch Team

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