Skip to content

Heap Buffer Overflow in Tcg2MeasureGptTable()

High
jkmathews published GHSA-xvv8-66cq-prwr Jan 9, 2024

Package

SecurityPkg (EDK2)

Affected versions

<=202311

Patched versions

None

Description

Summary

Tcg2MeasureGptTable() reads untrusted input from disk, and an attacker can set up a malicious GPT table that triggers an integer overflow that leads to a buffer overflow. This is due to a lack of validation of the GPT Primary Header.

This vulnerability was originally reported at https://bugzilla.tianocore.org/show_bug.cgi?id=4117.

Details

Tcg2MeasureGptTable() lacks checks for integer overflows when computing NumberOfPartitionEntries * SizeOfPartitionEntry at multiple places in the function. One way of triggering this vulnerability could be to overflow the EventSize computation at line 251 in SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c, which would lead to AllocateZeroPool() returning a much smaller object than expected, thus leading to a heap-buffer overflow when copying the partition entries into the allocated buffer shortly after the allocation takes place.

Impact

An attacker could use this heap-buffer overflow to achieve arbitrary code execution in the DXE phase in a number of ways:

  1. Corrupting PREV-NEXT pointers of an object in the heap to setup an unlink() attack. By default all memory is RWX, so this primitive could be very powerful as could allow an attacker to overwrite code from UEFI applications, or pointers from the BootServices table.
  2. Using the heap-buffer overflow itself to overwrite UEFI application code.

Mitigation release plan

Patch files are available now via https://bugzilla.tianocore.org/show_bug.cgi?id=4117. Patch will be integrated for the Feb 2024 EDK2 release.

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Local
Attack complexity
High
Privileges required
Low
User interaction
None
Scope
Changed
Confidentiality
Low
Integrity
Low
Availability
High

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:C/C:L/I:L/A:H

CVE ID

CVE-2022-36763

Weaknesses

Credits