Memory Corruption vulnerability in DXE driver.
BINARLY efiXplorer team has discovered an integer overflow on memory allocation size that leads to OOB Write operations during PNG file processing in AMI firmware.
Image preview
Potential Impact
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.
Image preview
Vulnerability Information
- BINARLY internal vulnerability identifier: BRLY-LOGOFAIL-2023-019
- AMI PSIRT assigned CVE identifier: CVE-2023-39538
- 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 modules
| Module name | Module GUID | Module SHA256 |
|---|---|---|
AMITSE | b1da0adf-4f77-4070-a88e-bffe1c60529a | 439e73d391b7f7540f6faa58afdc2722bda250468d4a4f7f5f84228c1f77ddbe |
Image preview
Vulnerability description
The pseudocode of the vulnerable function is shown below:
unsigned __int64 __fastcall sub_33FE4(
__int64 a1,
unsigned int a2,
_QWORD *a3,
UINTN *a4,
unsigned int *a5,
unsigned int *a6)
{
__int64 v8; // rbx
__int64 height; // rcx
__int64 width; // rax
UINTN size; // rcx
_BYTE *ZeroPool; // rax MAPDST
unsigned int i; // r8d
unsigned int j; // r9d
__int64 v16; // rdx
_BYTE *v17; // rdx
dword_973A0 = sub_186A0;
dword_97330 = 0x7FFFFFFF;
dword_97334 = 0x7FFFFFFF;
dword_97338 = 0x7FFFFFFF;
v8 = 0i64;
if ( DecodePNG(a1, a2) )
return 0x8000000000000015ui64;
height = Height;
width = Width;
*a5 = Height;
*a6 = width;
size = 4 * width * height;
*a4 = size;
ZeroPool = AllocateZeroPool(size);
*a3 = ZeroPool;
if ( !ZeroPool )
return 0x8000000000000009ui64;
for ( i = 0; i < *a5; ++i )
{
for ( j = 0; j < *a6; ZeroPool += 4 )
{
if ( j >= Width )
v16 = 4 * Width * (i + 1) - 4;
else
v16 = 4 * (j + i * Width);
v17 = (DecodedImg + v16);
++j;
*ZeroPool = v17[2];
ZeroPool[1] = v17[1];
ZeroPool[2] = *v17;
}
}
return v8;
}
As we can see from the pseudocode, the width and height variables are not validated. The attacker can arbitrarly set these variables an thus trigger an integer overflow when ZeroPool is initialized from EfiLibAllocateZeroPool((4 * width * height)). Since ZeroPool is later used in this function to copy the uncompressed PNG image, the integer overflow forces the allocation of buffer that is too small to contain the intended data, thus creating an arbitrary heap overflow.
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 (YYYY-mm-dd) |
|---|---|
Lenovo PSIRT is notified | 2023-06-21 |
Lenovo ID (LEN-132940) is assigned | 2023-06-22 |
CERT/CC is notified | 2023-07-10 |
AMI PSIRT confirmed reported issues | 2023-10-05 |
AMI PSIRT assigned CVE ID | 2023-12-01 |
BINARLY public disclosure date | 2024-06-19 |
Image preview
Acknowledgements
Image preview
See if you are impacted now with our Firmware Vulnerability Scanner
Find Vulnerabilities, Generate SBOMs & CBOMs