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).
Binarly REsearch Team has discovered a SMM memory corruption vulnerability on a BullSequana Edge server 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 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 the UEFI firmware (for example, Secure Boot and some types of memory isolation for hypervisors).
The vulnerability exists in the SW SMI handler registered with the GUID 52c78312-8edc-4233-98f2-1a1aa5e388a5
and located at offset 0x2090
in the driver:
EFI_STATUS SmiHandler(EFI_HANDLE DispatchHandle, const void *Context, void *CommBuffer, UINTN *CommBufferSize)
{
if ( gUnknownProtocol != CommBuffer || *CommBufferSize != 0x20 || !CommBuffer )
return 0;
if ( *(_QWORD *)CommBuffer != 1 )
{
if ( *(_QWORD *)CommBuffer != 2 )
return 0x8000000000000003;
...
return 0;
}
gPointer = *((_QWORD *)CommBuffer + 2);
result = sub_800014C0(DispatchHandle, Context);
...
}
As we can see in case 1
is passed in the first QWORD
inside a Communication Buffer, a pointer is extracted from it and saved to gPointer
, then sub_800014C0()
is invoked, where the following code is executed:
for ( i = Deref(gPointer); ; i = Deref2(gPointer, v1) )
{
v1 = i;
if ( CompareValues(gPointer, i) )
break;
v2 = *(_QWORD *)(v1 - 0x10);
if ( !*(_BYTE *)(v1 - 8) )
{
if ( *(_BYTE *)(*(_QWORD *)(v2 + 0xB0) + 0x100) & 1 )
{
*(_QWORD *)(v1 - 0xD0) = sub_800041E8;
*(_QWORD *)(v1 - 0xC8) = sub_800044E8;
Several write operations with fixed values are performed into a memory relatively pointed by gPointer
. The problem is that the nested pointer (saved into gPointer)
inside Communication Buffer is not validated to be outside of SMRAM.
This leads to overwriting the pointed area with a fixed or predictable data - functions pointers. Writing such data into SMRAM could allow a possible attacker to modify SMM code or to corrupt some data in SMRAM. This could lead to gaining arbitrary code execution in SMM.
To exploit this vulnerability it is enough to:
*((_QWORD *)CommBuffer + 2)
).0xB2
IO port.To fix this vulnerability, it is essential that all the input pointers (including the nested pointers) for SMI handlers are wrapped with sanity checks to make sure they are not pointing into SMRAM.
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