[BRLY-2022-004] SMM arbitrary code execution in USBRT SMM driver on Dell devices.

March 21, 2022

Summary

BINARLY efiXplorer team has discovered SMM arbitrary code execution on Dell devices.

Vulnerability Information

  • BINARLY internal vulnerability identifier: BRLY-2022-004
  • CERT/CC assigned case number: VU#540990
  • Dell PSIRT assigned CVE identifier: CVE-2022-24419
  • CVSS v3.1 8.2 High AV:L/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H

Affected Intel firmwares with confirmed impact by Binarly team

Device/Firmware File Name SHA256 (File PE32 section) File GUID
DELL Edge Gateway 5000/5100 USBRT 217ceec06cedd1628740e578ea7fe47639e94ad463f641d1b4f22fa907d5d4e8 04EAAAA1-29A1-11D7-8838-00500473D4EB
DELL Edge Gateway 3000 USBRT 217ceec06cedd1628740e578ea7fe47639e94ad463f641d1b4f22fa907d5d4e8 04EAAAA1-29A1-11D7-8838-00500473D4EB

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

The vulnerability exists in SW SMI handler located at offset 0x1C00 in the driver.The handler is registered as follows:

The pseudocode of the vulnerable handler is shown below:

MACRO_EFI SwSmiHandler()
{
  unsigned __int8 *Struct;

  Struct = *(gUsbData + 22080);
  if ( Struct )
    *(gUsbData + 22080) = 0;
  else
    Struct = *(16 * MEMORY[0x40E] + 0x104);
  if ( !Struct )
    return EFI_OUT_OF_RESOURCES;
  CallApiFunction(Struct);
  return 0;
}

void __fastcall CallApiFunction(unsigned __int8 *Struct)
{
  unsigned __int8 Index;

  if ( Struct )
  {
    Index = *Struct;
    if ( *Struct )
    {
      if ( Index < 0x20 || Index > 0x38 )
      {
        Struct[2] = 0xF0; // Arbitrary SMRAM write
        return;
      }
      Index -= 31;
    }
    gUsbApiTable[Index]();
  }
}

As you can see from the pseudocode, the Struct pointer can be controlled by an attacker, but is not checked for overlap with SMRAM.

This means that a potential attacker can write 0xF0 to a controlled location in SMRAM. Such an error leads to the execution of arbitrary code in SMM.

To protect against exploitation, it is necessary to check the Struct buffer so that it does not overlap with SMRAM. In addition, you need to check all the functions inside the gUsbApiTable table.

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
Dell PSIRT is notified 2021-12-08
Dell PSIRT confirmed reported issue 2022-02-25
Dell PSIRT assigned CVE number 2022-02-25
Dell PSIRT provide patch release 2022-02-25
BINARLY public disclosure date 2022-03-10

Acknowledgements

BINARLY efiXplorer team

References

Tags
Dell
SMM
DXE