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 memory corruption vulnerability on Intel platforms allowing a possible attacker to write fixed or predictable data to SMRAM. Exploiting this issue could lead to escalating privileges to SMM.
An attacker can exploit this vulnerability to elevate privileges from ring 0 to ring -2, execute arbitrary code in System Management Mode - an evironment 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 child SW SMI handler registered with GUID a7149597-ca0a-4ff5-a12e-5e5deb1051c8
and located at offset 0x1A24
in the binary.The pseudocode for this handler is shown below:
EFI_STATUS __fastcall SmiHandler(
EFI_HANDLE DispatchHandle,
const void *Context,
void *CommBuffer,
UINTN *CommBufferSize)
{
// [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]
Interface = 0;
if ( CommBuffer && CommBufferSize )
{
Res = gSmst->SmmLocateProtocol(&ProprietaryProtocol_8, 0, &Interface);
if ( !Res )
Res = (*Interface)();
*CommBuffer = Res;
}
return 0;
}
Before SMI handler will be triggered, CommBuffer will be checked for overlap with SMRAM (inside PiSmmCommunicationSmm
module):
EFI_STATUS __fastcall SwSmiHandler(
EFI_HANDLE DispatchHandle,
const void *Context,
void *CommBuffer,
UINTN *CommBufferSize)
{
// [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]
Status = 0;
CommunicationHeader = *gCommunicationHeader;
if ( *gCommunicationHeader )
{
if ( SmmIsBufferOutsideSmmValid(*gCommunicationHeader, 24) )
{
CommBufferSizea[0] = CommunicationHeader->MessageLength;
if ( SmmIsBufferOutsideSmmValid(CommunicationHeader->Data, CommBufferSizea[0]) )
Status = gSmst->SmiManage(
&CommunicationHeader->HeaderGuid,
0,
CommunicationHeader->Data,
CommBufferSizea);
}
}
return -(Status != 0) & 0xA000000000000000;
}
If CommunicationHeader->MessageLength
is 0
and CommunicationHeader->Data
does not overlap with SMRAM, check will pass.
As we can see from the pseudocode, *CommBufferSize
is not checked (only the CommBufferSize
pointer is compared to NULL).But at the same time there is a primitive for writing 8 fixed bytes at the address of CommBuffer
:
This leads to rewriting pointed area with a predictable data - Status code.
As we can see from header of SMRAM dump, first 8 bytes of SMRAM is signature (SMMS3_64
).
$ xxd SMRAM_dump_8b000000_8b7fffff.bin | head
00000000: 534d 4d53 335f 3634 8029 7d8b 0000 0000 SMMS3_64.)}.....
...
Thus, a potential attacker cannot execute arbitrary code, but can carry out a DOS attack.
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