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 Latitude 3120's firmware (version: 0.1.13.1, module sha256: adc756cd7143c8c1ec9e1f776aa1c7cee49da09f6e02b5bc609bc6969d977dcb) as an example.
The following code in the module actually allows leaking memory:
gRT->GetVariable()
offset: 0xa65
gRT->SetVariable()
offset: 0xa9c
EFI_STATUS __fastcall sub_8AC()
{
EFI_GUID VendorGuid; // [rsp+30h] [rbp-D0h] BYREF
EFI_GUID v2; // [rsp+40h] [rbp-C0h] BYREF
EFI_GUID v3; // [rsp+50h] [rbp-B0h] BYREF
char Data[226]; // [rsp+60h] [rbp-A0h] BYREF
__int16 v5; // [rsp+142h] [rbp+42h]
int v6[2]; // [rsp+300h] [rbp+200h] BYREF
char v7; // [rsp+30Ah] [rbp+20Ah]
char v8; // [rsp+930h] [rbp+830h]
UINT32 Attributes; // [rsp+A90h] [rbp+990h] BYREF
char v10; // [rsp+A98h] [rbp+998h] BYREF
int v11; // [rsp+A99h] [rbp+999h]
__int16 v12; // [rsp+A9Dh] [rbp+99Dh]
UINTN DataSize; // [rsp+AA0h] [rbp+9A0h] BYREF
VendorGuid.Data1 = -1332766721;
*&VendorGuid.Data2 = 1100211944;
*VendorGuid.Data4 = -1637967959;
*&VendorGuid.Data4[4] = 853215899;
v2.Data1 = 1165015025;
*&v2.Data2 = 1229172200;
*v2.Data4 = 1681965965;
*&v2.Data4[4] = -2078047118;
v3.Data1 = -1426528487;
*&v3.Data2 = 1083787512;
*v3.Data4 = 1600452518;
*&v3.Data4[4] = 1028417981;
sub_1130(v6, 0, 0x77Fui64);
v10 = 0;
v11 = 0;
v12 = 0;
DataSize = 667i64;
gRT->GetVariable(L"CpuSetup", &VendorGuid, &Attributes, &DataSize, Data);
v5 = 256;
gRT->SetVariable(L"CpuSetup", &VendorGuid, Attributes, DataSize, Data);
DataSize = 1919i64;
gRT->GetVariable(L"PchSetup", &v2, &Attributes, &DataSize, v6);
v8 = 0;
v7 = 0;
gRT->SetVariable(L"PchSetup", &v2, Attributes, DataSize, v6);
DataSize = 7i64;
gRT->GetVariable(L"SiSetup", &v3, &Attributes, &DataSize, &v10);
LOBYTE(v11) = 0;
return gRT->SetVariable(L"SiSetup", &v3, Attributes, DataSize, &v10);
}
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 SiSetup
NVRAM variable is greater than 7
.
Thus, a potential attacker can dump X - 7
bytes from the stack (or global memory) into SiSetup NVRAM variable by setting SiSetup
NVRAM variable's size to X > 7
.
To fix this vulnerability the DataSize
must be re-initialized with the size of SiSetup
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