An attacker with local privileged access can exploit this vulnerability to read the contents of the stack and use this information to exploit other vulnerabilities in DXE. A malicious code installed as a result of the vulnerability exploitation in a DXE driver could survive across an operating system (OS) boot process and runtime or modify NVRAM area on SPI flash storage (to gain persistence on target platform). Additionally, this vulnerability potentially could be used by threat actors to bypass OS security mechanisms (modify privileged memory or runtime variables), influence on the OS boot process, and in some cases would allow an attacker to hook or modify EFI Runtime services.
Binarly REsearch Team has discovered a stack memory leak vulnerability that allows a potencial attacker to write stack memory to NVRAM variable.
An attacker with local privileged access can exploit this vulnerability to read the contents of the stack and use this information to exploit other vulnerabilities in DXE. A malicious code installed as a result of the vulnerability exploitation in a DXE driver could survive across an operating system (OS) boot process and runtime or modify NVRAM area on SPI flash storage (to gain persistence on target platform).Additionally, this vulnerability potentially could be used by threat actors to bypass OS security mechanisms (modify privileged memory or runtime variables), influence on the OS boot process, and in some cases would allow an attacker to hook or modify EFI Runtime services.
The vulnerable functions is a part of protocol with GUID d874d61a-4b87-7608-a00f-58add7052530
.The pseudocode of the vulnerable function is shown below:
__int64 sub_192A0()
{
EFI_GET_VARIABLE GetVariable;
int ResValue;
EFI_SET_VARIABLE SetVariable;
int RunCyclesValue;
__int64 DataSize;
RunCyclesValue = 0;
CheckHwErrRecSupport();
DataSize = 4;
if ( (gRT->GetVariable)(L"MTC", &gVariableGuid, 0, &DataSize, &gMtcValue) )
gMtcValue = 0;
GetVariable = gRT->GetVariable;
DataSize = 4;
if ( (GetVariable)(L"RunCycles", &gVariableGuid, 0, &DataSize, &RunCyclesValue) == EFI_NOT_FOUND )
{
ResValue = 1;
RunCyclesValue = 0;
}
else
{
ResValue = RunCyclesValue + 1;
}
SetVariable = gRT->SetVariable;
RunCyclesValue = ResValue;
(SetVariable)(L"RunCycles", &gVariableGuid, 7, DataSize, &RunCyclesValue);
DataSize = 4;
return (gRT->GetVariable)(L"RunCycles", &gVariableGuid, 0, &DataSize, &RunCyclesValue);
}
As we can see from the pseudocode, for the RunCycles
variable gRT->SetVariable()
service is called with the DataSize
value, which can be overwritten inside the gRT->GetVariable()
service.
Thus, a potential attacker can write X - 4
bytes from the stack to NVRAM if writes any buffer of length X > 4
to the RunCycles
NVRAM variable.
In order to fix this vulnerability, the DataSize
variable must be initialized before gRT->SetVariable()
.
This vulnerability is subject to a 90 day disclosure deadline. After 90 days elapsed or a patch has been made broadly available (whichever is earlier), the vulnerability report will become visible to the public.
Binarly REsearch Team