An attacker with high local access can exploit this vulnerability to read the contents of stack memory or global memory. This information could help with exploitation of other vulnerabilities in DXE to elevate privileges from ring 3 or ring 0 (depends on the operating system) to a DXE driver and execute arbitrary code. Malicious code installed as a result of this exploitation could survive operating system (OS) boot process and runtime, or modify NVRAM area on the SPI flash storage (to gain persistence). Additionally, threat actors could use this vulnerability to bypass OS security mechanisms (modify privileged memory or runtime variables), influence OS boot process, and in some cases allow an attacker to hook or modify EFI Runtime services.
Binarly REsearch Team has discovered a memory contents leak / information disclosure vulnerability that allows a potential attacker to dump stack memory or global memory into an NVRAM variable. This in turn could help building a successful attack vector based on exploiting a memory corruption vulnerability.
An attacker with high local access can exploit this vulnerability to read the contents of stack memory or global memory. This information could help with explotation of other vulnerabilities in DXE to elevate privileges from ring 3 or ring 0 (depends on the operating system) to a DXE driver and execute arbitrary code. Malicious code installed as a result of this exploitation could survive operating system (OS) boot process and runtime, or modify NVRAM area on the SPI flash storage (to gain persistence). Additionally, threat actors could use this vulnerability to bypass OS security mechanisms (modify privileged memory or runtime variables), influence OS boot process, and in some cases allow an attacker to hook or modify EFI Runtime services.
Let's take Precision 3240 Compact's firmware (version: 0.1.15.0, module sha256: 59f51092b44581ea5525d187d17b176c700057900475cbc552f68e1999f5eaf4) as an example.
The following code in the module actually allows leaking memory:
gRT->GetVariable()
offset: 0x716
gRT->SetVariable()
offset: 0x760
char __fastcall sub_6B8(unsigned int a1)
{
unsigned int v2; // ebx
char result; // al
EFI_GUID VendorGuid; // [rsp+30h] [rbp-10h] BYREF
bool Data; // [rsp+58h] [rbp+18h] BYREF
UINTN DataSize; // [rsp+60h] [rbp+20h] BYREF
VendorGuid.Data1 = -1954858115;
*&VendorGuid.Data2 = 1210466085;
*VendorGuid.Data4 = 365057174;
*&VendorGuid.Data4[4] = 845990413;
Data = 0;
DataSize = 1i64;
if ( (gRT->GetVariable(L"EfiExternalGfxState", &VendorGuid, 0i64, &DataSize, &Data) & 0x8000000000000000ui64) != 0i64 )
{
if ( sub_630() )
{
Data = 1;
v2 = 240;
}
else
{
Data = 0;
v2 = 180;
}
gRT->SetVariable( // <= second call
L"EfiExternalGfxState",
&VendorGuid,
7u,
DataSize,
&Data);
if ( a1 < v2 )
__outbyte(0xCF9u, 6u);
}
result = sub_630();
if ( Data != (result != 0) )
{
Data = result != 0;
(gRT->SetVariable)(L"EfiExternalGfxState", &VendorGuid, 7i64, DataSize, &Data);
result = 6;
__outbyte(0xCF9u, 6u);
}
return result;
}
The gRT->SetVariable()
service is called with the DataSize
as an argument, which will be overwritten inside the gRT->GetVariable()
service if the length of EfiExternalGfxState
NVRAM variable is greater than 1
.
Thus, a potential attacker can dump X - 1
bytes from the stack (or global memory) into EfiExternalGfxState NVRAM variable by setting EfiExternalGfxState
NVRAM variable's size to X > 1
.
To fix this vulnerability the DataSize
must be re-initialized with the size of EfiExternalGfxState
before calling gRT->SetVariable()
.
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