VMWare Workstation uses PhoenixBIOS 4.0 Release 6 for its legacy BIOS emulation. One backdoor (not malicious in anyway; just the lingo for emulation stuff) into this feature, was that the guest can communicate with the hypervisor during this time. This is done via an emulated I/O port.
By viewing an open source project called
open-vm-tools, a few specific backdoor functions related to the BIOS emulation were found. The most interesting of the bunch ended up being
BDOOR_CMD_PATCH_ACPI_TABLES because it parses configuration tables (ACPI) from the guest.
Essentially, the ACPI is an open standard that operating systems use in order to discover computer hardware components and perform power management operations. More information can be found
here.
The flow for this function is as follows:
- The ACPI table is validated for legitimacy.
- The ACPI structures are used in order to find the Differentiated System Description Table (DSDT).
- Once the DSDT is found, the AML (ACPI Machine Language) code is patched out.
Both of the vulnerabilities are Time-of-check Time-of-use (TOCTOU) race conditions that lead to memory corruption.
The first one exists because of a size in the ACPI header for a checksum. First, these fields are validated and a memory mapping is made for this. However, once more the size of the length is validated once again! In order to exploit this, have the size of the table be different on the two separate fetches in order to have a cause an OOB write.
The second bug is exactly the same as the first (same size check) but it is used on a read instead of a write of the checksum calculation.
This bug is in a unique part of the system; hence, requires an interesting way to exploit it!
Although the backdoor function (from VMWare) should be disabled after booting the computer, the code is hittable via the Guest OS. Since the BIOS memory is writable, we can force the call of this function with a modified BIOS data!
First, the author creates a fake RSDP structure structure. Now, since we can overwrite the RSDT structure with our RSDP write, we can control the entire ACPI parsing process. This is important because we force the TOCTOU to happen by editing these components of the BIOS as the function calls are being made to the hypervisor.
To actually exploit this, the DSDT table (where the vuln is at) would need to be at the far end of Guest RAM. This is because the OOB write & OOB read are linear, requiring the physical mapped addresses to be at the right location in order to cause any damage.
For the OOB, the leak is super clever! By setting up the checksum to be known by the attacker and increase the size by one byte (OOB by one byte), the checksum would be recalculated. From this checksum value, you could find the leaked bytes! This process can be repeated N times to leak linearly arbitrary memory.
The write primitive is extremely constrained to what values can be written, making it a less interesting item to work with.
Overall, this is a really interesting article which talks about the internals of VMWares virtualization and about very low level interfaces that are seldomly talked about.