SMM memory corruption vulnerability in SMM driver on multiple HP devices.
BINARLY efiXplorer team has discovered a SMM memory corruption vulnerability on multiple HP devices allowing a possible attacker to write fixed or predictable data to SMRAM. Exploiting this issue could lead to escalating privileges to SMM.
Image preview
Potential Impact
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 the SMM additionally bypasses the SMM-based SPI flash protections against modifications, which can help an attacker to install a firmware backdoor/implant into the BIOS. Such a malicious firmware code in the BIOS could persist across operating system re-installs. Additionally, this vulnerability potentially could be used by threat actors to bypass security mechanisms provided by the UEFI firmware (for example, Secure Boot and some types of memory isolation for hypervisors).
Image preview
Vulnerability Information
- BINARLY internal vulnerability identifier: BRLY-2021-035
- HP PSIRT assigned CVE identifier: CVE-2022-23927
- CERT/CC assigned case number: VU#683814
- CVSS v3.1 8.2 High AV:L/AC:L/PR:H/UI:N/S:C/C:H/I:H/A:H
Image preview
Affected HP firmware
| Device/Firmware | File Name | SHA256 (File PE32 section) | File GUID |
|---|---|---|---|
Device / firmware version: 02.05.01 Rev.A | 017A | 3ff374c3d1a2610f9812ab908c9c5911001870990e5e806513287b845ec891b5 | E5D6844D-5486-436E-AC9D-C22F6759E926 |
Image preview
Vulnerability description
The vulnerability exists in child the SW SMI handler registered with GUID ca9f989d-ef13-41d6-a5c4-0f380c35dae0 and located at offset 0x168C in the driver.
The pseudocode for this handler is shown below:
EFI_STATUS __fastcall SmiHandler_168C(
EFI_HANDLE DispatchHandle,
const void *Context,
CommBuffer *CommBuffer,
UINTN *CommBufferSize)
{
// [COLLAPSED LOCAL DECLARATIONS. PRESS KEYPAD CTRL-"+" TO EXPAND]
if ( CommBuffer && CommBufferSize && *CommBufferSize <= 0x2000 )
{
if ( CommBuffer->Case )
{
if ( CommBuffer->Case != 1 )
{
CommBuffer->Result = EFI_INVALID_PARAMETER;
return 0i64;
}
Flag = 1;
}
else
{
Flag = 0;
}
CommBuffer->Result = sub_1738(Flag, CommBuffer->Msg, CommBuffer->MsgLen);
}
return 0i64;
}
In this case the CommBuffer has the following structure:
00000000 CommBufferStruct struc ; (sizeof=0x20, mappedto_235)
00000000 Case dd ?
00000004 field_4 dd ?
00000008 Result dq ?
00000010 MsgLen dq ?
00000018 Msg dq ?
00000020 CommBufferStruct ends
As we can see the input Communication Buffer is not validated to be outside of the SMRAM since the Communication Buffer size (*CommBufferSize) is not checked correctly (it may be 0). If attacker sets *CommBufferSize to 0, he will bypass validation implemented in PiSmmCommunicationSmm before gSmst->SmiManage call:
CommSize = (UINTN)CommunicateHeader->MessageLength;
if (!SmmIsBufferOutsideSmmValid ((UINTN)&CommunicateHeader->Data[0], CommSize)) {
Status = EFI_SUCCESS;
goto Done;
}
//
// Call dispatch function
//
Status = gSmst->SmiManage (
&CommunicateHeader->HeaderGuid,
NULL,
&CommunicateHeader->Data[0],
&CommSize
);
Keeping this in mind, a possible attacker has limited but still an opportunity to corrupt some SMM memory by pointing Communication Buffer into the SMRAM contents. This leads to rewriting pointed area with a fixed or predictable data - Status code. Writing such data into SMRAM could allow a possible attacker to corrupt some structures at the beginning of this memory (for example, change SMM S3 resume code pointer and hijack execution flow during SMM S3 wake up procedure). This could lead to gaining arbitrary code execution in SMM.
To exploit this vulnerability it is enough to:
- Set up a Communication Buffer (only a Communication Header with MessageSize = 0) just before the SMRAM (
SMRAM_BASE - sizeof(EFI_SMM_COMMUNICATE_HEADER)). - Trigger the SW SMI Handler (SW SMI number and pointer to Communication Buffer are specified in UEFI ACPI table) via
0xB2IO port.
Image preview
Disclosure timeline
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.
| Disclosure Activity | Date |
|---|---|
HP PSIRT is notified | 2021-07-12 |
HP PSIRT confirmed reported issue | 2021-08-09 |
HP PSIRT assigned CVE number | 2021-08-19 |
CERT/CC created a case | 2021-11-16 |
HP PSIRT provide patch release | 2022-03-08 |
BINARLY public disclosure date | 2022-03-08 |
Image preview
Acknowledgements
Image preview
See if you are impacted now with our Firmware Vulnerability Scanner
Find Vulnerabilities, Generate SBOMs & CBOMs