The vulnerability is a classic stack-based buffer overflow in the MakeTable function within the Tiano decompression logic in uefi_firmware/compression/Tiano/Decompress.c. The MakeTable function populates a histogram Count of size 17 with code lengths read from the compressed data. The vulnerability exists because there is no validation to ensure the code length values (BitLen[Index]) are within the valid range of 0 to 16 before using them as an index into the Count array. An attacker can craft a malicious firmware image with code lengths greater than 16. When MakeTable processes this, it writes past the end of the Count array on the stack, leading to memory corruption. This can cause a crash or, potentially, arbitrary code execution.
The patch introduces a check if (BitLen[Index] > 16) inside the loop in MakeTable to prevent this out-of-bounds write.
The vulnerable functions identified are:
MakeTable: The function containing the direct out-of-bounds write.
ReadPTLen and ReadCLen: These functions read the malicious data and pass it to MakeTable.
TianoDecompress: The top-level API function that triggers the vulnerable decompression path. These functions would appear in a runtime profile or stack trace during exploitation.