An attacker with high physical 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 physical 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 Inspiron 3020's firmware (version: 0.1.0.0, module sha256: 9f5a54f9d0c27666478c65e18a16f306190cf3dee18c3d4f98b528722f330601) as an example.
The following code in the module actually allows leaking memory:
gRT->GetVariable()
offset: 0x1413
gRT->SetVariable()
offset: 0x1442
__int64 __fastcall sub_13D4()
{
signed __int64 v0; // rbx
EFI_EVENT Event; // [rsp+40h] [rbp+10h] BYREF
UINTN DataSize; // [rsp+48h] [rbp+18h] BYREF
Event = 0i64;
DataSize = 8i64;
gRT->GetVariable( // <= first call (we can rewrite DataSize here)
(CHAR16 *)L"BIQ_BOOT_INTERRUPTION",
&VendorGuid,
0i64,
&DataSize,
&Event);
Event = (char *)Event + 1;
gRT->SetVariable( // <= second call
(CHAR16 *)L"BIQ_BOOT_INTERRUPTION",
&VendorGuid,
3u,
DataSize,
&Event);
v0 = sub_14D4();
if ( v0 >= 0 )
{
if ( byte_155A0 )
{
return sub_3F04();
}
else
{
Event = 0i64;
v0 = gBS->CreateEventEx(0x200u, 8ui64, nullsub_1, 0i64, &VariableGuid, &Event);
if ( v0 >= 0 )
{
v0 = gBS->SignalEvent(Event);
gBS->CloseEvent(Event);
}
}
}
return v0;
}
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 BIQ_BOOT_INTERRUPTION
NVRAM variable is greater than 8
.
Thus, a potential attacker can dump X - 8
bytes from the stack (or global memory) into BIQ_BOOT_INTERRUPTION NVRAM variable by setting BIQ_BOOT_INTERRUPTION
NVRAM variable's size to X > 8
.
To fix this vulnerability the DataSize
must be re-initialized with the size of BIQ_BOOT_INTERRUPTION
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 efiXplorer team