An attacker with local access can exploit this vulnerability 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.
This vulnerability was detected by the Deep Vulnerability Analysis (DVA) component from Binarly Platform
Binarly REsearch Team has discovered an SMM arbitrary code execution vulnerability on a Fujitsu device allowing a potential attacker to hijack execution flow of code running in the System Management Mode. Exploitation of this issue could lead to escalation of privileges to SMM.
An attacker can exploit this vulnerability to elevate privileges from ring 0 to ring -2, execute arbitrary code in System Management Mode - an environment more privileged than operating system (OS) and completely isolated from it. Running arbitrary code in SMM additionally bypasses SMM-based SPI flash protections against modifications, which can help an attacker to install a firmware backdoor/implant into BIOS. Such a malicious firmware code in BIOS could persist across operating system re-installs. Additionally, this vulnerability potentially could be used by malicious actors to bypass security mechanisms provided by UEFI firmware (for example, Secure Boot and some types of memory isolation for hypervisors).
Let's consider the vulnerability on the example of a module with SHA256 d3715136d50fc486ef59fb4aee1d7f06552fdf98423809939538fe905a1aa0b3
. The pseudocode of the vulnerable ChildSwSmiHandler
function (with the HandlerType
: EFI_SMM_RUNTIME_PROTOCOL_GUID
) is presented below:
EFI_STATUS __fastcall ChildSwSmiHandler(
EFI_HANDLE DispatchHandle,
const void *Context,
char *CommBuffer,
UINTN *CommBufferSize)
{
__int64 Ptr; // [rsp+20h] [rbp-18h]
Ptr = *(CommBuffer + 4);
if ( Ptr )
{
(*(Ptr + 8))(*Ptr, gSmst, CommBuffer + 24); // Arbitrary function call
*(CommBuffer + 4) = 0;
}
return EFI_SUCCESS;
}
As we can see from the pseucode, since a possible attacker controls the contents of СommBuffer
, it allows to specify an arbitrary pointer of a function called here (*(Ptr + 8))(*Ptr, gSmst, CommBuffer + 24)
. Which will lead to hijacking of the execution flow.
To fix this vulnerability, a call to an arbitrary function must be removed and replaced by a call the function from a table that is already located in SMRAM..
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