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 OptiPlex 7080's firmware (version: 0.1.16.0, module sha256: f8d98000b805e8f2bae1fb8d9377020ff0beff3fbb237c972079e0be439ef60e) as an example.
The following code in the module actually allows leaking memory:
gRT->GetVariable()
offset: 0x880
gRT->SetVariable()
offset: 0x8bf
__int64 __fastcall sub_7CC(__int64 a1, EFI_SYSTEM_TABLE *SystemTable)
{
__int64 v2; // rbx
__int64 v3; // r8
__int64 v5; // [rsp+30h] [rbp-20h] BYREF
_DWORD v6[6]; // [rsp+38h] [rbp-18h] BYREF
__int64 v7; // [rsp+60h] [rbp+10h] BYREF
unsigned int v8; // [rsp+70h] [rbp+20h] BYREF
__int64 v9; // [rsp+78h] [rbp+28h] BYREF
v7 = a1;
v2 = 0i64;
v6[0] = -2117640072;
v9 = 0i64;
v6[1] = 1130938334;
v6[2] = 156733591;
v6[3] = 1696251924;
if ( !gST_0 )
{
gST_0 = SystemTable;
gBS_0 = SystemTable->BootServices;
gRT = SystemTable->RuntimeServices;
}
if ( sub_8D4(a1) )
{
v9 = 0i64;
(gBS_0->InstallProtocolInterface)(&v9, &AMI_SETUP_NVRAM_UPDATE_GUID, 0i64, 0i64);
v5 = 4i64;
if ( (gRT->GetVariable)(L"AmiHardwareSignatureSetupUpdateCountVar", v6, &v8, &v5, &v7) >= 0 )
{
LODWORD(v2) = v7;
v3 = v8;
}
else
{
v3 = 7i64;
v8 = 7;
}
LODWORD(v7) = v2 + 1;
return (gRT->SetVariable)(L"AmiHardwareSignatureSetupUpdateCountVar", v6, v3, v5, &v7);
}
return v2;
}
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 AmiHardwareSignatureSetupUpdateCountVar
NVRAM variable is greater than 4
.
Thus, a potential attacker can dump X - 4
bytes from the stack (or global memory) into AmiHardwareSignatureSetupUpdateCountVar NVRAM variable by setting AmiHardwareSignatureSetupUpdateCountVar
NVRAM variable's size to X > 4
.
To fix this vulnerability the DataSize
must be re-initialized with the size of AmiHardwareSignatureSetupUpdateCountVar
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