[BRLY-2021-011]
SMM memory corruption vulnerability in combined DXE/SMM driver on Fujitsu device (SMRAM write).
BINARLY efiXplorer team

Summary

BINARLY efiXplorer 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-011
  • CERT/CC assigned case number: VU#796611
  • Insyde PSIRT assigned CVE identifier: CVE-2021-33627
  • 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 team

Device name Driver name Driver SHA256 File GUID
Fujitsu LIFEBOOK A3510 FwBlockServiceSmm 9f110c958f2dae1c40369babcf3511324e7bc7f24e6b87c58ea74de7d4bcdb86 74D936FA-D8BD-4633-B64D-6424BDD23D24
Fujitsu LIFEBOOK U9310 FwBlockServiceSmm c25ac01091b3dfee3512de1c048ae7357e02e7864906f5c6186e71dc1272c7c8 74D936FA-D8BD-4633-B64D-6424BDD23D24
Fujitsu LIFEBOOK U7511/U7411/U7311 FwBlockServiceSmm 3d950ccd87a793a0a98524c366c4ddc4f1f9cf2f35d653c407ad87c08dccd53e 74D936FA-D8BD-4633-B64D-6424BDD23D24
Fujitsu LIFEBOOK U9311 FwBlockServiceSmm 3d950ccd87a793a0a98524c366c4ddc4f1f9cf2f35d653c407ad87c08dccd53e 74D936FA-D8BD-4633-B64D-6424BDD23D24
Fujitsu LIFEBOOK E5510/E5410 FwBlockServiceSmm c25ac01091b3dfee3512de1c048ae7357e02e7864906f5c6186e71dc1272c7c8 74D936FA-D8BD-4633-B64D-6424BDD23D24
Fujitsu LIFEBOOK U7510/U7410/U7310 FwBlockServiceSmm c25ac01091b3dfee3512de1c048ae7357e02e7864906f5c6186e71dc1272c7c8 74D936FA-D8BD-4633-B64D-6424BDD23D24
Fujitsu LIFEBOOK E459/E449 FwBlockServiceSmm ffff5f7181fc8b25e1f32d1081b5dd6672ed51a3a9fab43f1a3cc163d02afb6e 74D936FA-D8BD-4633-B64D-6424BDD23D24

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 0x172C (image sha256: 9f110c958f2dae1c40369babcf3511324e7bc7f24e6b87c58ea74de7d4bcdb86), the child software System Management Interrupt (SWSMI) handler with GUID 2970687c-618c-4de5-b8f9-6c7576dca83d is registered:

Handle = 0;
gSmst_80005570->SmiHandlerRegister(SmiHandler_800016B0, &gSmiHandlerGuid, &Handle);
Handle = 0;
return gBS_80005240->InstallProtocolInterface(
            &Handle,
            &ProprietaryProtocol_80005190,
            EFI_NATIVE_INTERFACE,
            0);

Below is the decompiled SWSMI handler code:

EFI_STATUS __fastcall SmiHandler_800016B0(
        EFI_HANDLE DispatchHandle,
        const void *Context,
        void *CommBuffer,
        UINTN *CommBufferSize)
{
  EFI_STATUS Status; // rax

  if ( CommBuffer && CommBufferSize && !gExitBootServices && *CommBufferSize == 0x1020 )
  {
    switch ( *CommBuffer )
    {
      case 2:
        Status = sub_80002B00(CommBuffer + 32, *(CommBuffer + 2), *(CommBuffer + 3));
        goto _WriteStatus;
      case 3:
        Status = sub_80002A38(*(CommBuffer + 2), CommBuffer + 32, CommBuffer + 3, *(CommBuffer + 2));
        goto _WriteStatus;
      case 4:
        Status = sub_800029A4(*(CommBuffer + 2), *(CommBuffer + 3));
_WriteStatus:
        *(CommBuffer + 1) = Status;
        break;
    }
  }
  return 0;
}

If the EFI_EVENT_EXIT_BOOT_SERVICES event was not triggered and the size of the communication buffer is 0x1020, the handler performs different actions depending on the value of the first QWORD in the CommBuffer.

Let's consider one of the cases (case 2):

  • if value of the first QWORD in the CommBuffer is 2:

    • in the function sub_80002B00, data is copied from *(CommBuffer + 2) to (CommBuffer + 32), the size is specified in *(CommBuffer + 3)

However, the following checks are missing:

  • checking the size located at *(CommBuffer + 3)

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 and add a check for the size located in *(CommBuffer + 3).

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 efiXplorer team