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).
Binarly REsearch Team has discovered SMM arbitrary code execution on Dell devices.
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).
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.
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.
Binarly REsearch Team