Exploiting an Unbounded memcpy in Parallels Desktop: A Pwn2Own 2021 Guest-to-Host Virtualization Escape
The Parallels Desktop host process handling guest toolgate requests contained an integer overflow that turned a size value into an empty Qt byte array, so a later flattening loop performed an unbounded memcpy into QtCore's data section. A separate drag-and-drop handler lacked a null-terminator check and could overflow a stack buffer, giving a semi-controlled pointer write that the authors used to make the wild copy survivable and reach code execution on the host.
Published on blog.ret2.io
This post details the development of a guest-to-host virtualization escape for Parallels Desktop on macOS, as used in our successful Pwn2Own 2021 entry. Given privileged code execution in the guest (i.e. via kernel module), the exploit obtains code execution in the Parallels application process running on the host…
The full write-up lives on its author's site
It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.
Context
This write-up covers the development of a guest-to-host virtualization escape for Parallels Desktop on macOS, as used in the RET2 Systems entry for Pwn2Own 2021. The starting condition is privileged code execution in the guest (for example via a kernel module); the goal is code execution in the Parallels application process running on the host system.
Parallels Desktop is a virtualization product for macOS, comparable to VirtualBox or VMware. It acts as a hypervisor to allow running guest operating systems (for example Windows or Linux) on a macOS host, described in the vendor's marketing byline as running them 'all without rebooting!'.

The image shows Parallels Desktop as a consumer-oriented virtualization solution on macOS systems.
The post first looks at how Parallels was evaluated and at some of its relevant attack surface, then demonstrates how an unbounded memcpy(...) corruption style vulnerability was exploited reliably to achieve arbitrary code execution.
The video is a demo of the exploit running inside the guest popping calc on the host.
Setup
The researcher's primary motivation for looking at Parallels was its sudden inclusion in Pwn2Own 2021. Prior to this, nobody at RET2 had used Parallels before, let alone tried poking at it for vulnerabilities.
When faced with a new target, a helpful first step is to see what previous work already exists: writeups, bugs, exploits, or other relevant documentation and materials. At the time (early 2021), public research on Parallels was scarce, save for one ZDI blog post and a handful of ZDI advisories. Since Pwn2Own, a few more resources have trickled out (the report links three), but the number of public works is still limited.
For the practical work, the researcher created a new VM and spent time getting acquainted with Parallels' features. The guest tools (Parallels Tools) implicitly provide most of the sharing features offered by Parallels: drag-and-drop, copy-pasting between host and guest, shared folders, and dynamic screen resolution.
The report notes that some of Parallels' by-design shared folder behaviour could be used for a guest-to-host escape. As part of the Pwn2Own meta-game, the researcher opted to ignore these issues fearing a possible collision (it seemed at least two other teams ended up finding these same issues).
For Linux guests, Parallels provides source code for the kernel modules, which must be built from source depending on the specific Linux distribution. There are five kernel modules, each with separate source directories:
prl_tg: interfaces with the "toolgate", a generic way to pass data to operations identified by opcodeprl_eth: virtual networkprl_fs: shared foldersprl_fs_freeze: a suspend/resume helper dealing with filesystem structuresprl_vid: video, potentially with some sort of DRM
By spawning a few VMs and looking at the system process list, the researcher inferred that prl_vm_app is the binary that runs for each guest. The prl_vm_app Mach-O was massive, and putting in reversing effort starting at the entrypoint did not prove immediately helpful.
Finding it
Guest-to-host attack surface
After creating a new VM and spending time getting acquainted with Parallels' features, some of the more interesting functionality that immediately stood out was the numerous "tools" made available to the guest VM. The focus shifted to the host-side implementation of these tools, presuming it was likely that the guest directly controlled input to that part of the code.
One of the header files for prl_tg included opcode definitions for a multitude of toolgate operations, and based on the large number of them, this interface appealed the most.
// mouse pointer requests (from PCI video)
#define TG_REQUEST_SET_MOUSE_POINTER 0x100
#define TG_REQUEST_HIDE_MOUSE_POINTER 0x101
#define TG_REQUEST_DISABLE_MOUSE_POINTER 0x102
// multi-head support (from PCI video)
#define TG_REQUEST_VID_QUERY_HEADS 0x110
#define TG_REQUEST_VID_ENABLE_HEAD 0x111
...
// shared folders requests
#define TG_REQUEST_FS_MIN 0x200
#define TG_REQUEST_FS_GETLIST 0x200
...
// CPTool requests
#define TG_REQUEST_CPTOOL_MIN 0x8010
#define TG_REQUEST_CPTOOL_HOST_TO_GUEST_COMMAND 0x8010
#define TG_REQUEST_CPTOOL_GUEST_TO_HOST_COMMAND 0x8011
#define TG_REQUEST_CPTOOL_MAX 0x8012
// Shell integration tool
#define TG_REQUEST_SHELLINT_MIN 0x8020
#define TG_REQUEST_SHELLINT_ENABLED 0x8020
...
// OpenGL
#define TG_REQUEST_GL_VERSION 0x8130
#define TG_REQUEST_GL_CREATE_PROCESS 0x8131
...
This is a sample of some of the opcodes defined in prl_tg/Toolgate/Interfaces/Tg.h.
From the guest tools source code, the guest kernel invokes toolgate operations by writing the physical address of a request structure to an I/O port. The request structure contains an opcode, size, and optionally inline data and/or "out-of-line" buffers.
None of the information gathered from the guest tools source code can be taken as ground truth: it is merely a suggestion of intent. The host-side implementation of the toolgate had to be found to see how things really (don't) work.
Locating the toolgate entrypoint
Shared folders were something easily poked at (for example with simple command-line file operations in the guest), and internally appeared to be implemented with toolgate requests. Finding the host implementation of shared folders seemed a promising path to finding the overall toolgate implementation.
The following procedure can be used to locate the prl_vm_app function responsible for shared folders requests:
- create a guest with tools installed; default config shares the home directory at
/media/psf/Home - on the host, attach (for example with lldb) to the
prl_vm_appprocess and set a breakpoint onunlink - in the guest, create and delete a file in the shared folder, hitting the breakpoint
- look at the backtrace
Matching up the backtrace functions with those in a disassembler or decompiler, you should see a function with a switch-case over the various toolgate opcodes for shared folders requests.
However, this function solely handles shared folders requests, and reversing deeper into the backtrace does not bring you to the initial toolgate entrypoint as hoped. The shared folders requests are handled on a separate thread; the requests are taken from a queue and handled asynchronously. The search then turns to finding where the queue is populated.
This can be done with watchpoints:
- set a breakpoint where the requests are taken off the queue
- in the guest, trigger a shared folders toolgate request, hitting the breakpoint
- note the address of the array used for the queue slots, set a watchpoint on the next array slot
- in the guest, trigger another shared folders request, hitting the watchpoint
- look at the backtrace
The watchpoint should trigger on a thread named VCPU0 (or potentially another "virtual CPU" thread if there are multiple cores), and reversing through the backtrace should eventually reveal the toolgate entrypoint, where the guest-supplied request structure is parsed and interpreted.
Toolgate protocol and handlers
Using the guest tools source as a guide, the researcher reverse engineered how toolgate requests are parsed and handled.
To interact with the toolgate, the guest writes a physical address to a TG_PORT_SUBMIT I/O port. Other ports are indicated in the guest tools source (these port numbers would be offset by a base port):
/* Symbolic offsets to registers. */
enum TgRegisters {
TG_PORT_STATUS = 0,
TG_PORT_MASK = 0,
TG_PORT_CAPS = 0x4,
TG_PORT_SUBMIT = 0x8,
TG_PORT_CANCEL = 0x10,
TG_MAX_PORT = 0x18
};
For example, the base port in the guest is usually 0x8000, so to submit a toolgate request, the physical address of the request structure would be written to port 0x8008 with the out instruction.
The host then expects a TG_PAGED_REQUEST structure to be present at the guest physical address (again, structure definitions taken from guest tools source):
typedef struct _TG_PAGED_REQUEST {
unsigned Request;
unsigned Status;
unsigned RequestSize;
unsigned short InlineByteCount;
unsigned short BufferCount;
TG_UINT64 RequestPages[1/*RequestPageCount*/];
// char InlineBytes[(InlineByteCount + 7) & ~7];
// TG_PAGED_BUFFER Buffers[BufferCount];
} TG_PAGED_REQUEST;
typedef struct _TG_PAGED_BUFFER {
TG_UINT64 Va;
unsigned ByteCount;
unsigned Writable:1;
unsigned Reserved:31;
// TG_UINT64 Pages[];
} TG_PAGED_BUFFER;
Request: the "opcode" of the toolgate operationStatus: a return value written by the host to indicate success, an error, or pending- Certain requests are asynchronous (and will be pending), as seen with shared folders earlier. These can be canceled by writing the request's physical address to the
TG_PORT_CANCELport.
- Certain requests are asynchronous (and will be pending), as seen with shared folders earlier. These can be canceled by writing the request's physical address to the
RequestSize: size of the variably sizedTG_PAGED_REQUESTRequestPages: physical page frame numbers for each page in theTG_PAGED_REQUESTstructure- Only really necessary if the request spans multiple pages.
RequestPages[0]is somewhat redundant considering the physical address written to the I/O port
- Only really necessary if the request spans multiple pages.
Buffers: "out-of-line" data blobs, again with physical page frame numbers for each page of each blob- The name
Vaimplying virtual address is a bit odd, but in reality only the page offset (Va & 0xfff) matters; thePagesarray defines the actual location in guest memory by page frame number
- The name
The host is free to use the inline data and/or the buffers both as input and/or output. For example, a specific opcode may expect Buffers[0] to be an input buffer, and will use Buffers[1] as the output.
In prl_vm_app, the toolgate is represented by a CPCIToolgate class. One member is an array of registered handler entries containing a minimum/maximum opcode and the handler object itself. Upon receiving a guest request, this array is searched through to find the handler (if any) that handles the given opcode. Then a virtual call on the handler object does all the operation-specific work.
The members of this array define the attack surface. Breaking in the debugger and dumping the handlers array maps opcode ranges to their handlers:
| Opcode range (inclusive) | Handler C++ class name |
| ------------------------ | ----------------------- |
| 0x200-0x23f | CSFoldersTool |
| 0x8000-0x8001 | CUTCommandsSender |
| 0x8010-0x8012 | CPTool |
| 0x8020-0x8029 | CSMTool |
| 0x8030-0x8033 | LayoutSyncHost |
| 0x8040-0x8044 | CSFoldersTool |
| 0x8050-0x8050 | Tg2OtgImpl |
| 0x8200-0x8202 | CGracefulShutdownHost |
| 0x8210-0x8211 | CToolsCenterHost |
| 0x8220-0x8221 | CSIAServer |
| 0x8230-0x8231 | CCoherenceToolServer |
| 0x8301-0x8301 | CWinMicroApp |
| 0x8302-0x8302 | CFavRunAppsHost |
| 0x8304-0x8304 | CDragAndDropBase |
| 0x8320-0x8328 | CSHAShellExt |
| 0x8340-0x8347 | CUIEmuHost |
| 0x8410-0x8411 | CSharedProfileTool |
| 0x8420-0x8440 | CInvSharing |
| 0x8500-0x8503 | CDesktopUtilitiesHost |
| 0x8700-0x8702 | CSFilterTgHandler |
| 0x8800-0x8801 | CHostCEP |
| 0x8900-0x8900 | CPrintingTool |
| 0x9020-0x9021 | CLocationTool |
| 0x9030-0x9030 | CEnergySavingTool |
| 0x9040-0x9043 | CVSDebug |
| 0x9050-0x9050 | AutoPauseHost |
| 0x9060-0x9060 | VmHostname |
| 0x9070-0x9070 | UniversalChannelHost |
| 0x9080-0x9080 | CDynResHost |
| 0x9100-0x9101 | CWinMicroApp |
| 0x9110-0x9111 | VolumeControllerHost |
| 0x9120-0x9124 | TimeSynchronizationHost |
| 0x9200-0x9200 | CToolbox |
There seemed to also be a video toolgate completely separate from the standard toolgate (different virtual device, different I/O base port). This component was not investigated much, but contained the following opcode ranges dumped dynamically as before:
| Opcode range (inclusive) | Handler C++ class name |
| ------------------------ | ---------------------- |
| 0x100-0x11f | VideoTgHandler |
| 0x400-0x41f | DirectXHandler |
| 0x8100-0x811f | VideoTgHandler |
| 0x8130-0x813f | OpenGLHandler |
The reversing effort can then focus on the handlers' virtual methods for handling toolgate requests, code known to be reachable with arbitrary input. Based on the handler class names, these requests should do "interesting" things. The workflow is to pick a handler class, find its vtable (which will have a symbol name like vtable for 'CDragAndDropBase'), then reverse the virtual handler function (for example, the function at offset 16 in the vtable).
From here to vulnerability discovery is mostly the standard reversing grind. The report moves on to the bugs found in some of these opcode handlers.
Exploitation
Bug 1: Megasmash (an unbounded memcpy(...))
Opcode 0x8050 is handled by Tg2OtgImpl, seemingly a proxy between the toolgate and "OTG" (possibly Open Tools Gate). The proxy works something like this:
Buffers[0]contains a header of sorts. This includes the size of the OTG input request, and will contain the output return value and response size once handled- According to the input size from the header, the remaining buffers (starting at
Buffers[1]) are "flattened" into a single byte array. This flattened array is treated as the OTG request to pass through. - An OTG opcode is fetched from offset 0 in the flattened blob, and the request is dispatched to the appropriate OTG handler for that opcode
- The return value and response size are set in the header, and the response blob is "unflattened" into
Buffers[1]onwards
The flattened request is represented by a QByteArray, a class supplied by the 3rd-party QtCore library, part of the Qt family. It is instantiated in the following way, using size from the input header:
QByteArray::QByteArray(&arr, hdr[2], 0LL);
And the respective QtCore implementation:
QByteArray::QByteArray(int size, Qt::Initialization)
{
d = Data::allocate(uint(size) + 1u);
Q_CHECK_PTR(d);
d->size = size;
d->data()[size] = '\0';
}
There is a pretty standard integer overflow here. If the provided size is -1 (0xffffffff), the size passed to Data::allocate will be 0.
Looking at the allocate implementation, the following code will return a special empty singleton in QtCore's data section, qt_array_empty:
QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment,
size_t capacity, AllocationOptions options) Q_DECL_NOTHROW
{
...
// Don't allocate empty headers
if (!(options & RawData) && !capacity) {
...
return const_cast<QArrayData *>(&qt_array_empty);
}
...
}
A QByteArray typically stores its data inline; in other words, d->data() in the snippet above is effectively (void*)d + sizeof(*d) (a pointer to the address immediately following the declared structure fields). In the case of the singleton, the inline data would also be in the data section (although it has size zero).
Back in the OTG proxy, the provided buffers are flattened by a loop, which copies one buffer at a time into increasing offsets of the newly constructed QByteArray (which is expected to have size 0xffffffff, but is actually empty).
The overall effect of this loop can be summed up as:
memcpy(QtCore_data_section, controlled_data, 0xffffffff);
In theory, this lets the attacker corrupt a significant portion of QtCore's data section. There is, however, the small problem of the excessively large copy being guaranteed to cause a fault (there will be a read-only mapping at some point after the writable data section).
These kinds of "wild copy" bugs are less than ideal but have been proven exploitable by researchers several times in the past (the report links two examples). Sometimes it is possible to modify memory or program state during the copy loop to cut it short, which was not viable in this case. Another method is to race another thread using the corrupted data before the copying thread crashes, which the researcher could not find a reliable method of doing.
So this bug was kept "in our back pocket" for now.
Bug 2: An information leak
This bug is less exciting, but provides a useful information leak to bypass ASLR in the host process.
The OTG handler for OTG opcode 10 appears to fetch various configuration settings for the guest. Different types of settings can be requested; the vulnerable type is 2. Here is a rough pseudocode interpretation for this type of request:
void otg_getdisablewin7logo(QByteArray *req, QByteArray *out) {
QByteArray::resize(out, 0x90); // new bytes left uninitialized ([docs](https://doc.qt.io/qt-5/qbytearray.html#resize))
// write the first 0x20 bytes of out->data()
memcpy(out->data(), req->data(), 0x10);
if (CVmRunTimeOptions::isDisableWin7Logo(...))
*(long*)(out->data() + 0x10) = 0x600000001;
else
*(long*)(out->data() + 0x10) = 0x1f00000000;
*(int*)(out->data() + 0x18) = ...;
*(int*)(out->data() + 0x1c) = 1;
}
This handler resizes the output QByteArray to size 0x90, then proceeds to populate the first 0x20 bytes. The remaining 0x70 bytes are left uninitialized, and will be copied out to the guest by the OTG proxy.
This allows leaking 0x70 bytes of uninitialized heap memory from the prl_vm_app host process, which can be repeated as necessary to obtain any leaks (heap or .text) needed.
Bug 3: Limited stack buffer overflow
Opcode 0x8304 is handled by CDragAndDropBase, presumably to implement drag and drop behaviour.
This handler uses "worker" objects, represented by CDragDropWorkerBase. An initial request must be made to create a new worker, and a handle to this worker is passed back to the guest for use in subsequent requests. As a side note, the handle was simply the heap address of the worker object, so was a limited information leak by itself.
Drag-and-drop requests have their own structure expected by the host, including a type field specifying what drag-and-drop operation to perform. A pseudocode snippet of the vulnerable code is reproduced below, preceded by some relevant structure definitions (struct interpretations are the researcher's own):
// input request from guest, completely controlled
struct dnd_blob {
unsigned type;
...
QChar qstr[1024];
... // 0x74 additional bytes
};
// internal message passed off to further layers
struct msg {
...
QChar qstr[1024];
... // 0x68 byte gap
CDragDropWorkerBase* worker;
};
void CDragAndDrop_process_blob(CDragDropWorkerBase* worker, tg_req* req, dnd_blob blob) {
switch (blob.type) {
case 0x107:
QString qstr = QString::fromUtf16(&blob.qstr, -1).normalized(); // [1]
...
struct msg msg;
msg.worker = worker;
memcpy(msg.qstr, qstr.utf16(), 2*qstr.size() + 2); // [2]
...
msg.worker->queued_req = req; // [3]
return;
}
}
The guest-supplied string is supposed to contain a maximum of 1024 UTF-16 characters. At the first annotation [1] the length passed to QString::fromUtf16(...) is -1, indicating that the input should be treated as null-terminated to determine the actual length.
There is no check, however, that the input indeed contains a null terminator. The 0x74 additional bytes following the input (and potentially whatever is on the stack afterwards) may be interpreted as part of the string, exceeding the expected 1024 length limit.
At [2], the string is copied into a local stack structure. This is where the overflow can occur. There is just enough data in the input dnd_blob structure to corrupt the msg.worker pointer with a controlled value, which is written to at [3]. This gives a write of an uncontrolled value (the req pointer) to an arbitrary location.
In theory, if the contents of the stack after the dnd_blob structure were non-zero and somewhat controllable, this overflow could corrupt the return address or other stack data. Empirically, there seemed to always be zeroes following the dnd_blob, and this path was not pursued.
Exception handling on macOS
It is likely possible the semi-controlled pointer write above would have been enough to finagle a way to code execution. Instead, the exploit leverages this weaker bug to render the megasmash (bug #1) reliably exploitable.
The key realisation is that when the megasmash inevitably causes a page fault, this does not necessarily result in the death of the process. As part of the Mach architecture of macOS, the page fault generates an exception (EXC_BAD_ACCESS), which is sent as a mach message to the registered exception port (at either the thread, task, or host level). The thread that generated the exception remains suspended until a response to the mach message is received (but other threads may continue to run).
prl_vm_app, however, does register a task-level exception port using task_set_exception_ports, for 3 exception types: EXC_BAD_ACCESS, EXC_BAD_INSTRUCTION, and EXC_ARITHMETIC.
I know the pieces fit
In terms of intended functionality, the researcher's guess is that Parallels intercepts these exceptions for crash reporting purposes. A separate thread is spawned with the sole purpose of, in a loop, reading messages from the exception port, handling them, and responding back.
What happens if this exception handling thread triggers an exception?
- The exception handling thread enters the kernel exception delivery code, and is effectively suspended
- The kernel waits for a response...
This response will never come, seeing as the thread intended by prl_vm_app to respond to the exception port message is itself suspended due to an exception.
As a side note, a potentially more robust technique would have been to set the exception ports at the thread level (with thread_set_exception_ports), for each individual thread except for the exception handler. That way, exceptions generated by the handler will get forwarded to the default host-level machinery.
If a way is found to force the exception handler thread to fault, the megasmash suddenly seems a lot more exploitable:
- Perform whatever setup so the exception handler will crash later
- Megasmash the QtCore data section, which faults and generates an exception
- Exception handler faults and generates an exception, leaving both threads suspended indefinitely
- Wait for another thread to use the corrupted QtCore data section in an interesting way
Using the limited stack-based buffer overflow (bug #3), a pointer the exception handler will later attempt dereferencing can be corrupted, causing the thread to fault and suspend indefinitely.
This is simple to achieve in practice. When the exception handler is being initialised, prior to calling task_set_exception_ports, the pre-existing ports are retrieved (with task_get_exception_ports) and stored in a heap allocated structure. Later on, when the handler thread receives an exception message, one of its first actions is to reset the exception ports to the original ones using this structure. This heap pointer resides in the data section, and serves as the target pointer to corrupt.
Putting everything together
The final exploit looks something like this:
- Use the info leak (bug #2) to obtain the base addresses of
prl_vm_appand QtCoreprl_vm_app: Experimenting by running the leak many times had a text pointer showing up relatively often. It turned out to be a function pointer passed toCFRunLoopTimerCreate- QtCore: The
CDragDropWorkerBaseobjects containQListobjects, which if empty, contain a pointer toQListData::shared_null(in the QtCore data section). By spraying many workers then deleting them, we can (eventually) get this leak
- Use the uncontrolled pointer write (bug #3) to corrupt the pointer to the original exception ports
- By misaligning the write 4 bytes into the 8-byte pointer, we can ensure the new value will be a non-canonical garbage address
- Megasmash the QtCore data section (bug #1)
- We target a function pointer
qt_signal_spy_callback_set(a hook of sorts triggered often through normal operation ofprl_vm_app) with fully controlled and carefully placed data, amidst our massive corruption of Qt's writable data segment - The megasmash will run off the end of the writable data segment triggering an
EXC_BAD_ACCESS
- We target a function pointer
- Crash the exception handler thread
- The
prl_vm_appexception handler will attempt to restore the original exception ports from the heap-allocated structure. Since we corrupted this pointer with an invalid address in step 2, it will force the exception handler thread to fault.
- The
- Wait for another thread to use the corrupted function pointer
- Stack pivot, short ropchain to call
system(...)rcxhappens to be pointing into the corrupted QtCore data section, anlea rsp, [rcx+0x30] ; retgadget kicks off the ropchain
- Providing the string
open -a Calculatortosystem(...)is sufficient to pop calc
- Stack pivot, short ropchain to call
Roughly, the steps described above which make up the final exploit are illustrated by the following animation:
A less dramatic video of the successful $40,000 exploit entry running live is available on ZDI's day two stream of Pwn2Own 2021. The full exploit code can be found here on GitHub.
Root cause
Three distinct bugs are chained.
Bug 1 (megasmash). The OTG proxy takes a size from a guest-controlled header and passes it to the QByteArray constructor. In QtCore, Data::allocate(uint(size) + 1u) overflows when size is 0xffffffff: uint(size) + 1u becomes 0, and allocate returns the qt_array_empty singleton in QtCore's data section instead of a real allocation. The QByteArray is then treated as if it had size 0xffffffff, and the flattening loop copies guest buffers into it, producing memcpy(QtCore_data_section, controlled_data, 0xffffffff). The copy is guaranteed to fault once it reaches a read-only mapping after the writable data segment.
Bug 2 (info leak). The handler for OTG opcode 10, type 2, resizes the output QByteArray to 0x90 and populates only the first 0x20 bytes. The remaining 0x70 bytes are left uninitialised and are copied out to the guest by the OTG proxy.
Bug 3 (stack buffer overflow). QString::fromUtf16(&blob.qstr, -1) treats the guest string as null-terminated, but there is no check that a null terminator is present within the expected 1024 UTF-16 characters. The 0x74 additional bytes after the input, and potentially whatever is on the stack afterwards, may be interpreted as part of the string. The subsequent memcpy(msg.qstr, qstr.utf16(), 2*qstr.size() + 2) then overflows the local msg structure on the stack, allowing the msg.worker pointer to be corrupted with a controlled value, which is then written to at msg.worker->queued_req = req. That is a write of an uncontrolled value (the req pointer) to an arbitrary location.
Why the defences did not stop it: the report does not describe ASLR, stack canaries or other mitigations being bypassed in detail beyond the use of the info leak to defeat ASLR. The report does not say which other mitigations were present. The key design weakness that made the megasmash survivable is that prl_vm_app registers a task-level exception port for EXC_BAD_ACCESS, EXC_BAD_INSTRUCTION and EXC_ARITHMETIC, and handles those exceptions on a thread that can itself be made to fault, leaving both the faulting thread and the handler suspended indefinitely rather than killing the process.
Impact
Given privileged code execution in the guest (for example via a kernel module), the exploit obtains code execution in the Parallels application process running on the host system. In the demonstrated case, the payload runs open -a Calculator via system(...), popping calc on the host. The report describes this as a guest-to-host virtualization escape and states that the entry was successful at Pwn2Own 2021.
Fix
The bugs used in this exploit were all patched by Parallels version 49187.
- Bug #3 (the stack buffer overflow) was patched with a check for a null word in the first 1024 UTF-16 characters
- Bug #2 (the information leak) was patched by calling
bzero(...)after resizing the output array - Bug #1 (megasmash) was patched by ensuring the size passed to
QByteArrayis non-negative- While potentially a dangerous pattern, Qt stated that the QtCore integer overflow was not a bug in QtCore, instead that it is a misuse of the API to ask to create a structure with negative size
- Interestingly, at the time, the master branch of QtCore did not exhibit the integer overflow due to a refactor in how the size parameter is passed around
The confusion over whether Qt should actually fix the overflow further delayed the publication of this writeup.
For one reason or another, ZDI opted to drop Parallels from 2022's competition:
RIP Parallels 2021-2021 https://t.co/aThASMwp1P
, Bruno (@bkth_) January 12, 2022
Variants to test
- Other toolgate handlers. The handler table maps many opcode ranges to classes (
CPTool,CSMTool,CUIEmuHost,CInvSharing,CDesktopUtilitiesHost, and so on). For each, find the vtable (for examplevtable for 'CDragAndDropBase') and reverse the virtual handler function. A positive result is a handler that copies guest-controlled data into a fixed-size buffer or uses a guest-supplied length without validation. - Other OTG opcodes behind
Tg2OtgImpl. The proxy flattens buffers according to a header size and dispatches on an OTG opcode at offset 0. Try other OTG opcodes and other settings types for the opcode 10 handler. A positive result is another handler that resizes an output buffer and leaves part of it uninitialised, or that trusts a length field. - Null-termination assumptions. Look for other uses of
QString::fromUtf16(..., -1)or similar APIs on guest input where the buffer is not guaranteed to contain a terminator within its declared length. A positive result is a string whose length exceeds the declared field size and overflows a destination. - Exception port handling. On other macOS applications that register task-level exception ports, check whether the handler thread can be made to fault. A positive result is a process that survives a faulting thread because the exception handler is itself suspended, leaving corrupted state usable by other threads.
- Wild copy survival. For other unbounded copies, look for a mechanism that keeps the faulting thread alive (exception ports, signal handlers, a supervisor) and for another thread that uses the corrupted data. A positive result is a corrupted data section that is consumed by a different thread after the copy faults.
- Integer overflow in allocation size. Look for
uint(size) + 1ustyle arithmetic where a negative size wraps to zero and returns a shared empty singleton. A positive result is a structure that reports a huge size while pointing at a small or empty allocation.
What happened, in plain words
This is a story about a security researcher who found a way to break out of a virtual machine. A virtual machine (VM) is a computer running inside another computer. The outer computer is called the host, and the inner one is called the guest. People use VMs so they can run Windows on a Mac, or test software safely, without buying a second machine.
The product involved is Parallels Desktop, a popular program for macOS that lets you run Windows or Linux in a window on your Mac. The researcher worked for a company called RET2 Systems, and they entered their work into Pwn2Own 2021, a yearly contest where security researchers try to break into well-known software. The entry was successful.
The starting point of the attack is unusual: the researcher assumes they already have privileged code execution in the guest. That means they can already run any program they like inside the virtual machine, with the highest level of permission (the level normally reserved for the operating system itself). The goal is to get from there to running code on the host, meaning on the real Mac, outside the VM. That jump is called a guest-to-host virtualization escape, and it is considered serious because the whole point of a VM is that the guest should be contained.
To get there, the researcher chained together three separate bugs:
- A megasmash: a copy operation that writes far more data than it should, because of a number that wraps around to zero.
- An information leak: a bug that hands back a chunk of the host's memory that was never properly cleared, revealing where things live in memory.
- A stack buffer overflow: a bug that lets the researcher overwrite a pointer (a memory address) on the host.
On their own, none of these is a clean path to running code. Together, plus a quirk in how macOS handles crashes, they let the researcher run the command open -a Calculator on the host, which pops up the macOS Calculator app. That is the classic harmless proof that you have taken control.
The video above is a demo of the exploit running inside the guest and popping Calculator on the host.
Background: what Parallels Desktop is
Parallels Desktop is a virtualization product for macOS, comparable to VirtualBox or VMware. It acts as a hypervisor, which is the piece of software that creates and runs virtual machines. The vendor's marketing byline describes running guest operating systems (for example Windows or Linux) on a macOS host 'all without rebooting!'.

The image shows Parallels Desktop as a consumer-oriented virtualization solution on macOS systems.
A useful everyday comparison: think of the host as a building and the guest as a room inside it. The hypervisor is the walls and the door. Normally the guest can do whatever it likes inside its room, but it cannot walk through the wall. A guest-to-host escape is finding a hole in that wall.
Setup: how the researcher got started
The researcher's primary motivation for looking at Parallels was its sudden inclusion in Pwn2Own 2021. Before that, nobody at RET2 had used Parallels, let alone tried to find vulnerabilities in it.
When you face a new target, a helpful first step is to see what previous work already exists: writeups, bugs, exploits, or other documentation. At the time (early 2021), public research on Parallels was scarce, apart from one ZDI blog post and a handful of ZDI advisories. Since Pwn2Own, a few more resources have trickled out, but the number of public works is still limited.
Why does this matter? Because reading what others found tells you where to look, saves time, and helps you avoid repeating work. It is like reading the reviews before visiting a restaurant.
For the practical work, the researcher created a new VM and spent time getting to know Parallels' features. The guest tools (called Parallels Tools) provide most of the sharing features: drag-and-drop, copy-pasting between host and guest, shared folders, and dynamic screen resolution. These are the features that make a VM feel seamless, and they are exactly the features where the guest sends data to the host, which is where bugs tend to live.
The report notes that some of Parallels' by-design shared folder behaviour could be used for a guest-to-host escape. As part of the Pwn2Own meta-game (the strategy of the contest), the researcher chose to ignore these issues, fearing a possible collision with another team (it seemed at least two other teams ended up finding the same issues). In other words, they wanted a bug nobody else would submit.
For Linux guests, Parallels provides source code for the kernel modules. Source code is the human-readable text a program is written in, before it is turned into something the computer runs. These modules must be built from source depending on the specific Linux distribution. There are five kernel modules, each with separate source directories:
prl_tg: interfaces with the "toolgate", a generic way to pass data to operations identified by opcodeprl_eth: virtual networkprl_fs: shared foldersprl_fs_freeze: a suspend/resume helper dealing with filesystem structuresprl_vid: video, potentially with some sort of DRM
A kernel module is a piece of code that plugs into the operating system's core (the kernel) to add a feature. A toolgate here is Parallels' name for a channel through which the guest asks the host to do something. An opcode is simply a number that says which operation is being requested, like choosing item 7 from a menu.
By spawning a few VMs and looking at the system process list, the researcher inferred that prl_vm_app is the binary that runs for each guest. A process is a running program; the process list is the list of everything currently running. A binary is a compiled program file. The prl_vm_app Mach-O was massive, and starting the reverse engineering from the entrypoint did not prove immediately helpful. Mach-O is the file format macOS uses for programs. Reverse engineering means taking a compiled program and working out what it does, usually without the original source code.
Finding it
Guest-to-host attack surface
After creating a new VM and getting acquainted with Parallels' features, the most interesting functionality was the numerous "tools" made available to the guest VM. The researcher focused on the host-side implementation of these tools, presuming the guest directly controlled input to that part of the code. Attack surface means all the places where an outsider can send data into a program; the bigger it is, the more chances there are for a bug.
One of the header files for prl_tg included opcode definitions for many toolgate operations. A header file is a file that declares names and numbers used by the code. Because there were so many operations, this interface appealed the most.
// mouse pointer requests (from PCI video)
#define TG_REQUEST_SET_MOUSE_POINTER 0x100
#define TG_REQUEST_HIDE_MOUSE_POINTER 0x101
#define TG_REQUEST_DISABLE_MOUSE_POINTER 0x102
// multi-head support (from PCI video)
#define TG_REQUEST_VID_QUERY_HEADS 0x110
#define TG_REQUEST_VID_ENABLE_HEAD 0x111
...
// shared folders requests
#define TG_REQUEST_FS_MIN 0x200
#define TG_REQUEST_FS_GETLIST 0x200
...
// CPTool requests
#define TG_REQUEST_CPTOOL_MIN 0x8010
#define TG_REQUEST_CPTOOL_HOST_TO_GUEST_COMMAND 0x8010
#define TG_REQUEST_CPTOOL_GUEST_TO_HOST_COMMAND 0x8011
#define TG_REQUEST_CPTOOL_MAX 0x8012
// Shell integration tool
#define TG_REQUEST_SHELLINT_MIN 0x8020
#define TG_REQUEST_SHELLINT_ENABLED 0x8020
...
// OpenGL
#define TG_REQUEST_GL_VERSION 0x8130
#define TG_REQUEST_GL_CREATE_PROCESS 0x8131
...
Line by line, in plain words:
- Lines starting with
//are comments, notes for humans that the computer ignores. #define NAME VALUEgives a name to a number. It is like writing a label on a switch so you do not have to remember that switch 256 is the mouse pointer.TG_REQUEST_SET_MOUSE_POINTER 0x100means "the operation for setting the mouse pointer is number 0x100". The0xprefix means the number is written in hexadecimal, a base-16 way of writing numbers that programmers use because it lines up neatly with how computers store data.0x100is 256 in ordinary decimal.- The
...lines mean the list continues; the report only shows a sample. - The comments group the operations: mouse pointer, multi-head (multiple monitors), shared folders, CPTool, shell integration, OpenGL (3D graphics).
This is a sample of some of the opcodes defined in prl_tg/Toolgate/Interfaces/Tg.h.
From the guest tools source code, the guest kernel invokes toolgate operations by writing the physical address of a request structure to an I/O port. An I/O port is a numbered channel the CPU uses to talk to devices, a bit like a mailbox number. A physical address is the actual location of data in the machine's memory chips. A request structure is a block of data laid out in a defined order, like a form with fixed fields.
None of the information gathered from the guest tools source code can be taken as ground truth: it is merely a suggestion of intent. The host-side implementation had to be found to see how things really (don't) work. This is an important habit: the guest-side code tells you what the designers meant to happen, not what actually happens on the host.
Locating the toolgate entrypoint
Shared folders were easy to poke at (for example with simple command-line file operations in the guest), and internally appeared to be implemented with toolgate requests. Finding the host implementation of shared folders seemed a promising path to finding the overall toolgate implementation.
The following procedure can be used to locate the prl_vm_app function responsible for shared folders requests:
- create a guest with tools installed; default config shares the home directory at
/media/psf/Home - on the host, attach (for example with lldb) to the
prl_vm_appprocess and set a breakpoint onunlink - in the guest, create and delete a file in the shared folder, hitting the breakpoint
- look at the backtrace
Let us unpack the tools mentioned:
- lldb is a debugger, a tool that lets you pause a running program and inspect it. "Attaching" means connecting the debugger to a process that is already running.
- A breakpoint is a marker that tells the debugger "pause here".
unlinkis the system call (a request to the operating system) that deletes a file. Setting a breakpoint on it means the program will pause whenever any file is deleted.- A backtrace is the list of function calls that led to the current point, like a family tree of "who called whom". It tells you the path the program took to get here.
Matching up the backtrace functions with those in a disassembler or decompiler, you should see a function with a switch-case over the various toolgate opcodes for shared folders requests. A disassembler turns a compiled program back into assembly instructions; a decompiler goes further and tries to produce C-like code. A switch-case is a programming construct that picks one branch based on a value, exactly like a menu.
However, this function solely handles shared folders requests, and reversing deeper into the backtrace does not bring you to the initial toolgate entrypoint as hoped. The shared folders requests are handled on a separate thread; the requests are taken from a queue and handled asynchronously. A thread is a unit of work inside a process; a process can have many threads running at once. A queue is a line of items waiting to be processed, first in, first out. Asynchronously means the work happens later, not immediately, so the caller does not wait.
The search then turns to finding where the queue is populated. This can be done with watchpoints:
- set a breakpoint where the requests are taken off the queue
- in the guest, trigger a shared folders toolgate request, hitting the breakpoint
- note the address of the array used for the queue slots, set a watchpoint on the next array slot
- in the guest, trigger another shared folders request, hitting the watchpoint
- look at the backtrace
A watchpoint is like a breakpoint but for memory: it pauses the program when a particular memory location is read or written. An array is a numbered list of items stored one after another in memory. A slot is one position in that list.
The watchpoint should trigger on a thread named VCPU0 (or potentially another "virtual CPU" thread if there are multiple cores), and reversing through the backtrace should eventually reveal the toolgate entrypoint, where the guest-supplied request structure is parsed and interpreted. A virtual CPU is the pretend processor the guest sees; VCPU0 is the first one. Parsing means reading structured data and making sense of its fields.
Toolgate protocol and handlers
Using the guest tools source as a guide, the researcher reverse engineered how toolgate requests are parsed and handled. A protocol is an agreed way of exchanging messages.
To interact with the toolgate, the guest writes a physical address to a TG_PORT_SUBMIT I/O port. Other ports are indicated in the guest tools source (these port numbers would be offset by a base port):
/* Symbolic offsets to registers. */
enum TgRegisters {
TG_PORT_STATUS = 0,
TG_PORT_MASK = 0,
TG_PORT_CAPS = 0x4,
TG_PORT_SUBMIT = 0x8,
TG_PORT_CANCEL = 0x10,
TG_MAX_PORT = 0x18
};
Line by line:
/* ... */is another style of comment.enum TgRegisters { ... };defines a named list of constants. An enum (enumeration) is a way to give names to a set of related numbers.TG_PORT_STATUS = 0means the status port is at offset 0 from the base port.TG_PORT_SUBMIT = 0x8means the submit port is at offset 8 (in decimal) from the base.TG_PORT_CANCEL = 0x10means the cancel port is at offset 16 in decimal.TG_MAX_PORT = 0x18means the highest offset is 24 in decimal.
For example, the base port in the guest is usually 0x8000, so to submit a toolgate request, the physical address of the request structure would be written to port 0x8008 with the out instruction. The out instruction is a CPU instruction that sends a value to an I/O port. 0x8000 + 0x8 = 0x8008, which is how the submit port is reached.
The host then expects a TG_PAGED_REQUEST structure to be present at the guest physical address (again, structure definitions taken from guest tools source):
typedef struct _TG_PAGED_REQUEST {
unsigned Request;
unsigned Status;
unsigned RequestSize;
unsigned short InlineByteCount;
unsigned short BufferCount;
TG_UINT64 RequestPages[1/*RequestPageCount*/];
// char InlineBytes[(InlineByteCount + 7) & ~7];
// TG_PAGED_BUFFER Buffers[BufferCount];
} TG_PAGED_REQUEST;
typedef struct _TG_PAGED_BUFFER {
TG_UINT64 Va;
unsigned ByteCount;
unsigned Writable:1;
unsigned Reserved:31;
// TG_UINT64 Pages[];
} TG_PAGED_BUFFER;
Line by line:
typedef struct _TG_PAGED_REQUEST { ... } TG_PAGED_REQUEST;defines a struct, which is a bundle of named fields stored together in memory, like a form with boxes.typedefgives the struct a shorter name to use later.unsigned Request;is a field holding the opcode (which operation).unsignedmeans a whole number that cannot be negative.unsigned Status;is where the host writes back whether the request succeeded, failed, or is still pending.unsigned RequestSize;is the total size of this request structure.unsigned short InlineByteCount;is how many bytes of data are stored right inside the request. A byte is 8 bits, the basic unit of data.unsigned short BufferCount;is how many separate buffers (chunks of data) are attached.TG_UINT64 RequestPages[1/*RequestPageCount*/];is an array of 64-bit numbers listing the physical pages that hold the request. A page is a fixed-size block of memory (commonly 4096 bytes) that the operating system manages as a unit.- The commented lines show that the inline bytes and the buffers follow the fixed fields in memory; they are variable in size, so they cannot be declared with a fixed length.
- The second struct,
TG_PAGED_BUFFER, describes one attached buffer:Va(an address),ByteCount(how many bytes),Writable:1(a single bit saying whether the host may write into it), andReserved:31(padding bits). The:1and:31syntax means "use this many bits", a space-saving trick called a bitfield.
Now the fields in plain terms:
Request: the "opcode" of the toolgate operation.Status: a return value written by the host to indicate success, an error, or pending.- Certain requests are asynchronous (and will be pending), as seen with shared folders earlier. These can be canceled by writing the request's physical address to the
TG_PORT_CANCELport.
- Certain requests are asynchronous (and will be pending), as seen with shared folders earlier. These can be canceled by writing the request's physical address to the
RequestSize: size of the variably sizedTG_PAGED_REQUEST.RequestPages: physical page frame numbers for each page in theTG_PAGED_REQUESTstructure.- Only really necessary if the request spans multiple pages.
RequestPages[0]is somewhat redundant considering the physical address written to the I/O port.
- Only really necessary if the request spans multiple pages.
Buffers: "out-of-line" data blobs, again with physical page frame numbers for each page of each blob.- The name
Vaimplying virtual address is a bit odd, but in reality only the page offset (Va & 0xfff) matters; thePagesarray defines the actual location in guest memory by page frame number.
- The name
A page frame number is the identifier of a physical page. A virtual address is the address a program sees, which the operating system translates to a physical address behind the scenes. Va & 0xfff uses a bitwise AND to keep only the lowest 12 bits, which is the position within a 4096-byte page (the offset).
The host is free to use the inline data and/or the buffers both as input and/or output. For example, a specific opcode may expect Buffers[0] to be an input buffer, and will use Buffers[1] as the output.
In prl_vm_app, the toolgate is represented by a CPCIToolgate class. A class is a blueprint in object-oriented programming that bundles data and the functions that work on it. One member is an array of registered handler entries containing a minimum/maximum opcode and the handler object itself. A handler is the piece of code that deals with a particular request. Upon receiving a guest request, this array is searched to find the handler (if any) that handles the given opcode. Then a virtual call on the handler object does all the operation-specific work. A virtual call means the program looks up which function to run at runtime, based on the object's actual type.
The members of this array define the attack surface. Breaking in the debugger and dumping the handlers array maps opcode ranges to their handlers:
| Opcode range (inclusive) | Handler C++ class name |
| ------------------------ | ----------------------- |
| 0x200-0x23f | CSFoldersTool |
| 0x8000-0x8001 | CUTCommandsSender |
| 0x8010-0x8012 | CPTool |
| 0x8020-0x8029 | CSMTool |
| 0x8030-0x8033 | LayoutSyncHost |
| 0x8040-0x8044 | CSFoldersTool |
| 0x8050-0x8050 | Tg2OtgImpl |
| 0x8200-0x8202 | CGracefulShutdownHost |
| 0x8210-0x8211 | CToolsCenterHost |
| 0x8220-0x8221 | CSIAServer |
| 0x8230-0x8231 | CCoherenceToolServer |
| 0x8301-0x8301 | CWinMicroApp |
| 0x8302-0x8302 | CFavRunAppsHost |
| 0x8304-0x8304 | CDragAndDropBase |
| 0x8320-0x8328 | CSHAShellExt |
| 0x8340-0x8347 | CUIEmuHost |
| 0x8410-0x8411 | CSharedProfileTool |
| 0x8420-0x8440 | CInvSharing |
| 0x8500-0x8503 | CDesktopUtilitiesHost |
| 0x8700-0x8702 | CSFilterTgHandler |
| 0x8800-0x8801 | CHostCEP |
| 0x8900-0x8900 | CPrintingTool |
| 0x9020-0x9021 | CLocationTool |
| 0x9030-0x9030 | CEnergySavingTool |
| 0x9040-0x9043 | CVSDebug |
| 0x9050-0x9050 | AutoPauseHost |
| 0x9060-0x9060 | VmHostname |
| 0x9070-0x9070 | UniversalChannelHost |
| 0x9080-0x9080 | CDynResHost |
| 0x9100-0x9101 | CWinMicroApp |
| 0x9110-0x9111 | VolumeControllerHost |
| 0x9120-0x9124 | TimeSynchronizationHost |
| 0x9200-0x9200 | CToolbox |
This is a table. The left column is a range of opcode numbers (inclusive means both ends count). The right column is the name of the C++ class that handles that range. For example, opcode 0x8050 is handled by Tg2OtgImpl, and opcode 0x8304 is handled by CDragAndDropBase. The names hint at what they do: CSFoldersTool for shared folders, CDragAndDropBase for drag and drop, CPrintingTool for printing, and so on.
There seemed to also be a video toolgate completely separate from the standard toolgate (different virtual device, different I/O base port). This component was not investigated much, but contained the following opcode ranges dumped dynamically as before:
| Opcode range (inclusive) | Handler C++ class name |
| ------------------------ | ---------------------- |
| 0x100-0x11f | VideoTgHandler |
| 0x400-0x41f | DirectXHandler |
| 0x8100-0x811f | VideoTgHandler |
| 0x8130-0x813f | OpenGLHandler |
Same idea: a second, separate channel for video, with its own handlers for video, DirectX (Microsoft's graphics interface) and OpenGL.
The reversing effort can then focus on the handlers' virtual methods for handling toolgate requests, code known to be reachable with arbitrary input. Based on the handler class names, these requests should do "interesting" things. The workflow is to pick a handler class, find its vtable (which will have a symbol name like vtable for 'CDragAndDropBase'), then reverse the virtual handler function (for example, the function at offset 16 in the vtable).
A vtable (virtual method table) is a hidden list of function addresses that a class uses to know which function to call for a virtual method. It is like a phone book the program consults at runtime. Finding it in a debugger or disassembler gives you a shortcut to the code that handles a request.
From here to vulnerability discovery is mostly the standard reversing grind. The report moves on to the bugs found in some of these opcode handlers.
Exploitation
Bug 1: Megasmash (an unbounded memcpy(...))
Opcode 0x8050 is handled by Tg2OtgImpl, seemingly a proxy between the toolgate and "OTG" (possibly Open Tools Gate). A proxy is a middleman that passes requests from one side to another. The proxy works something like this:
Buffers[0]contains a header of sorts. This includes the size of the OTG input request, and will contain the output return value and response size once handled- According to the input size from the header, the remaining buffers (starting at
Buffers[1]) are "flattened" into a single byte array. This flattened array is treated as the OTG request to pass through. - An OTG opcode is fetched from offset 0 in the flattened blob, and the request is dispatched to the appropriate OTG handler for that opcode
- The return value and response size are set in the header, and the response blob is "unflattened" into
Buffers[1]onwards
A header here means a small block of data at the start that describes the rest. To flatten means to join several separate chunks into one continuous block. A blob is just a chunk of bytes with no particular meaning to the reader.
The flattened request is represented by a QByteArray, a class supplied by the 3rd-party QtCore library, part of the Qt family. Qt is a widely used toolkit for building graphical programs; QtCore is its core library. It is instantiated in the following way, using size from the input header:
QByteArray::QByteArray(&arr, hdr[2], 0LL);
Line by line:
QByteArray::QByteArray(...)means "call the constructor of the QByteArray class". A constructor is the function that creates a new object.&arris the address of an existing array, passed in.hdr[2]is the third field of the header (counting from 0), which holds the size. This value comes from the guest, so the guest controls it.0LLis a constant (a 64-bit zero) passed as an extra argument.
And the respective QtCore implementation:
QByteArray::QByteArray(int size, Qt::Initialization)
{
d = Data::allocate(uint(size) + 1u);
Q_CHECK_PTR(d);
d->size = size;
d->data()[size] = '\0';
}
Line by line:
QByteArray::QByteArray(int size, Qt::Initialization)is the constructor, taking a size and an initialisation mode.d = Data::allocate(uint(size) + 1u);asks for memory.uint(size)reinterprets the size as an unsigned number.+ 1uadds one (for the terminating zero byte). The result is stored ind, a pointer to the allocated block.Q_CHECK_PTR(d);checks that the allocation succeeded.d->size = size;records the requested size in the block.d->data()[size] = '\0';writes a zero byte at the end, the standard way to mark the end of a string.
There is a pretty standard integer overflow here. If the provided size is -1 (0xffffffff), the size passed to Data::allocate will be 0. An integer overflow happens when a number is too big for its storage and wraps around, like a car odometer rolling from 999999 to 000000. Here, uint(-1) is 0xffffffff, and adding 1 wraps it to 0.
Looking at the allocate implementation, the following code will return a special empty singleton in QtCore's data section, qt_array_empty:
QArrayData *QArrayData::allocate(size_t objectSize, size_t alignment,
size_t capacity, AllocationOptions options) Q_DECL_NOTHROW
{
...
// Don't allocate empty headers
if (!(options & RawData) && !capacity) {
...
return const_cast<QArrayData *>(&qt_array_empty);
}
...
}
Line by line:
QArrayData *QArrayData::allocate(...)is the function that hands out memory blocks.- The parameters are the object size, alignment (how the address must line up), capacity (how many items), and options.
if (!(options & RawData) && !capacity) {checks: if the caller did not ask for raw data and the capacity is zero, then...return const_cast<QArrayData *>(&qt_array_empty);returns the address of a shared, empty placeholder object calledqt_array_empty. A singleton is a single shared instance used everywhere.const_castremoves a "read-only" marker so the code can return it as a normal pointer.
A QByteArray typically stores its data inline; in other words, d->data() in the snippet above is effectively (void*)d + sizeof(*d) (a pointer to the address immediately following the declared structure fields). In the case of the singleton, the inline data would also be in the data section (although it has size zero). The data section is the part of a program's memory that holds global variables and constants set up when the program starts.
Back in the OTG proxy, the provided buffers are flattened by a loop, which copies one buffer at a time into increasing offsets of the newly constructed QByteArray (which is expected to have size 0xffffffff, but is actually empty).
The overall effect of this loop can be summed up as:
memcpy(QtCore_data_section, controlled_data, 0xffffffff);
Line by line:
memcpyis a standard C function that copies bytes from one place to another. Its three arguments are: destination, source, and how many bytes.QtCore_data_sectionis the destination: the data section of the QtCore library.controlled_datais the source: bytes the guest controls.0xffffffffis the number of bytes: about 4 gigabytes, far more than the data section holds.
In theory, this lets the attacker corrupt a significant portion of QtCore's data section. There is, however, the small problem of the excessively large copy being guaranteed to cause a fault (there will be a read-only mapping at some point after the writable data section). A fault is what happens when a program tries to touch memory it is not allowed to; the operating system stops it. A read-only mapping is a region of memory the program may read but not write, so the copy will hit it and fail.
These kinds of "wild copy" bugs are less than ideal but have been proven exploitable by researchers several times in the past. Sometimes it is possible to modify memory or program state during the copy loop to cut it short, which was not viable in this case. Another method is to race another thread using the corrupted data before the copying thread crashes, which the researcher could not find a reliable method of doing. A race means two threads acting at the same time, where the outcome depends on who wins.
So this bug was kept "in our back pocket" for now. In other words, it was noted but not yet usable on its own.
Bug 2: An information leak
This bug is less exciting, but provides a useful information leak to bypass ASLR in the host process. ASLR (Address Space Layout Randomisation) is a defence where the operating system places programs and libraries at random addresses each time they run, so an attacker cannot know in advance where things are. An information leak is a bug that reveals data the attacker should not see, often memory contents that include addresses.
The OTG handler for OTG opcode 10 appears to fetch various configuration settings for the guest. Different types of settings can be requested; the vulnerable type is 2. Here is a rough pseudocode interpretation for this type of request:
void otg_getdisablewin7logo(QByteArray *req, QByteArray *out) {
QByteArray::resize(out, 0x90); // new bytes left uninitialized ([docs](https://doc.qt.io/qt-5/qbytearray.html#resize))
// write the first 0x20 bytes of out->data()
memcpy(out->data(), req->data(), 0x10);
if (CVmRunTimeOptions::isDisableWin7Logo(...))
*(long*)(out->data() + 0x10) = 0x600000001;
else
*(long*)(out->data() + 0x10) = 0x1f00000000;
*(int*)(out->data() + 0x18) = ...;
*(int*)(out->data() + 0x1c) = 1;
}
Line by line:
void otg_getdisablewin7logo(QByteArray *req, QByteArray *out)is a function taking an input request and an output buffer.QByteArray::resize(out, 0x90);makes the output buffer 0x90 (144) bytes long. The comment notes that the new bytes are left uninitialised, meaning they contain whatever was in memory before, not zeros.memcpy(out->data(), req->data(), 0x10);copies 0x10 (16) bytes from the request into the start of the output.if (CVmRunTimeOptions::isDisableWin7Logo(...))checks a configuration setting.*(long*)(out->data() + 0x10) = 0x600000001;writes an 8-byte value at offset 0x10 (16) in the output. The*(long*)syntax means "treat this address as a long integer and store there".elsehandles the other case, writing a different 8-byte value.*(int*)(out->data() + 0x18) = ...;writes a 4-byte value at offset 0x18 (24).*(int*)(out->data() + 0x1c) = 1;writes a 4-byte value of 1 at offset 0x1c (28).
This handler resizes the output QByteArray to size 0x90, then proceeds to populate the first 0x20 bytes. The remaining 0x70 bytes are left uninitialised, and will be copied out to the guest by the OTG proxy. 0x90 - 0x20 = 0x70, so 112 bytes of old memory are handed back.
This allows leaking 0x70 bytes of uninitialised heap memory from the prl_vm_app host process, which can be repeated as necessary to obtain any leaks (heap or .text) needed. The heap is the area of memory used for data created while a program runs. The .text section is the part of a program that holds its executable code. Leaking a pointer into either tells the attacker where that region sits in memory, defeating ASLR.
Bug 3: Limited stack buffer overflow
Opcode 0x8304 is handled by CDragAndDropBase, presumably to implement drag and drop behaviour.
This handler uses "worker" objects, represented by CDragDropWorkerBase. An initial request must be made to create a new worker, and a handle to this worker is passed back to the guest for use in subsequent requests. A handle is a reference the guest can use later to refer to the same object. As a side note, the handle was simply the heap address of the worker object, so was a limited information leak by itself.
Drag-and-drop requests have their own structure expected by the host, including a type field specifying what drag-and-drop operation to perform. A pseudocode snippet of the vulnerable code is reproduced below, preceded by some relevant structure definitions (struct interpretations are the researcher's own):
// input request from guest, completely controlled
struct dnd_blob {
unsigned type;
...
QChar qstr[1024];
... // 0x74 additional bytes
};
// internal message passed off to further layers
struct msg {
...
QChar qstr[1024];
... // 0x68 byte gap
CDragDropWorkerBase* worker;
};
void CDragAndDrop_process_blob(CDragDropWorkerBase* worker, tg_req* req, dnd_blob blob) {
switch (blob.type) {
case 0x107:
QString qstr = QString::fromUtf16(&blob.qstr, -1).normalized(); // [1]
...
struct msg msg;
msg.worker = worker;
memcpy(msg.qstr, qstr.utf16(), 2*qstr.size() + 2); // [2]
...
msg.worker->queued_req = req; // [3]
return;
}
}
Line by line:
struct dnd_blob { ... };describes the data the guest sends.unsigned type;says which drag-and-drop operation.QChar qstr[1024];is a fixed array of 1024 characters (UTF-16, so 2 bytes each). The comment says there are0x74additional bytes after it.struct msg { ... };describes an internal message. It also has aQChar qstr[1024];, then a gap of0x68bytes, thenCDragDropWorkerBase* worker;, a pointer to the worker object.void CDragAndDrop_process_blob(...)is the function that handles the request.switch (blob.type) { case 0x107:picks the branch for operation type 0x107.QString qstr = QString::fromUtf16(&blob.qstr, -1).normalized(); // [1]turns the guest's UTF-16 characters into a QString. Passing-1as the length means "keep reading until you find a zero terminator".normalized()tidies up the text.struct msg msg;creates a local message on the stack. The stack is the area of memory used for local variables and function bookkeeping; it grows and shrinks as functions are called.msg.worker = worker;stores the worker pointer in the message.memcpy(msg.qstr, qstr.utf16(), 2*qstr.size() + 2); // [2]copies the string into the message's fixed 1024-character field.2*qstr.size() + 2is the number of bytes: two per character plus two for the terminator.msg.worker->queued_req = req; // [3]stores the request pointer inside the worker object.
The guest-supplied string is supposed to contain a maximum of 1024 UTF-16 characters. At the first annotation [1] the length passed to QString::fromUtf16(...) is -1, indicating that the input should be treated as null-terminated to determine the actual length. A null terminator is a zero byte that marks the end of a string.
There is no check, however, that the input indeed contains a null terminator. The 0x74 additional bytes following the input (and potentially whatever is on the stack afterwards) may be interpreted as part of the string, exceeding the expected 1024 length limit.
At [2], the string is copied into a local stack structure. This is where the overflow can occur. There is just enough data in the input dnd_blob structure to corrupt the msg.worker pointer with a controlled value, which is written to at [3]. This gives us a write of an uncontrolled value (the req pointer) to an arbitrary location. A stack buffer overflow is when more data is written into a fixed-size buffer on the stack than it can hold, spilling into neighbouring data such as pointers.
In theory, if the contents of the stack after the dnd_blob structure were non-zero and somewhat controllable, this overflow could corrupt the return address or other stack data. The return address is the place the program jumps back to when a function finishes; controlling it is the classic route to running your own code. Empirically, there seemed to always be zeroes following the dnd_blob, and this path was not pursued.
Exception handling on macOS
It is likely possible the semi-controlled pointer write above would have been enough to reach code execution. Instead, the exploit leverages this weaker bug to render the megasmash (bug #1) reliably exploitable.
The key realisation is that when the megasmash inevitably causes a page fault, this does not necessarily result in the death of the process. A page fault is the CPU's way of saying "this memory access is not allowed". As part of the Mach architecture of macOS, the page fault generates an exception (EXC_BAD_ACCESS), which is sent as a mach message to the registered exception port (at either the thread, task, or host level). Mach is the core of macOS's operating system design; an exception port is like a mailbox where crash reports are delivered. The thread that generated the exception remains suspended until a response to the mach message is received (but other threads may continue to run). Suspended means paused, not running.
prl_vm_app, however, does register a task-level exception port using task_set_exception_ports, for 3 exception types: EXC_BAD_ACCESS, EXC_BAD_INSTRUCTION, and EXC_ARITHMETIC. A task on macOS is roughly what most people call a process. EXC_BAD_INSTRUCTION means the CPU was asked to do something impossible; EXC_ARITHMETIC means a maths error such as dividing by zero.
I know the pieces fit
In terms of intended functionality, the researcher's guess is that Parallels intercepts these exceptions for crash reporting purposes. A separate thread is spawned with the sole purpose of, in a loop, reading messages from the exception port, handling them, and responding back.
What happens if this exception handling thread triggers an exception?
- The exception handling thread enters the kernel exception delivery code, and is effectively suspended
- The kernel waits for a response...
This response will never come, seeing as the thread intended by prl_vm_app to respond to the exception port message is itself suspended due to an exception. The kernel is the core of the operating system, the part with the highest privilege.
As a side note, a potentially more robust technique would have been to set the exception ports at the thread level (with thread_set_exception_ports), for each individual thread except for the exception handler. That way, exceptions generated by the handler will get forwarded to the default host-level machinery.
If a way is found to force the exception handler thread to fault, the megasmash suddenly seems a lot more exploitable:
- Perform whatever setup so the exception handler will crash later
- Megasmash the QtCore data section, which faults and generates an exception
- Exception handler faults and generates an exception, leaving both threads suspended indefinitely
- Wait for another thread to use the corrupted QtCore data section in an interesting way
Using the limited stack-based buffer overflow (bug #3), a pointer the exception handler will later attempt dereferencing can be corrupted, causing the thread to fault and suspend indefinitely. To dereference a pointer means to read or write the memory it points at.
This is simple to achieve in practice. When the exception handler is being initialised, prior to calling task_set_exception_ports, the pre-existing ports are retrieved (with task_get_exception_ports) and stored in a heap allocated structure. Later on, when the handler thread receives an exception message, one of its first actions is to reset the exception ports to the original ones using this structure. This heap pointer resides in the data section, and serves as the target pointer to corrupt.
Putting everything together
The final exploit looks something like this:
- Use the info leak (bug #2) to obtain the base addresses of
prl_vm_appand QtCoreprl_vm_app: Experimenting by running the leak many times had a text pointer showing up relatively often. It turned out to be a function pointer passed toCFRunLoopTimerCreate- QtCore: The
CDragDropWorkerBaseobjects containQListobjects, which if empty, contain a pointer toQListData::shared_null(in the QtCore data section). By spraying many workers then deleting them, we can (eventually) get this leak
- Use the uncontrolled pointer write (bug #3) to corrupt the pointer to the original exception ports
- By misaligning the write 4 bytes into the 8-byte pointer, we can ensure the new value will be a non-canonical garbage address
- Megasmash the QtCore data section (bug #1)
- We target a function pointer
qt_signal_spy_callback_set(a hook of sorts triggered often through normal operation ofprl_vm_app) with fully controlled and carefully placed data, amidst our massive corruption of Qt's writable data segment - The megasmash will run off the end of the writable data segment triggering an
EXC_BAD_ACCESS
- We target a function pointer
- Crash the exception handler thread
- The
prl_vm_appexception handler will attempt to restore the original exception ports from the heap-allocated structure. Since we corrupted this pointer with an invalid address in step 2, it will force the exception handler thread to fault.
- The
- Wait for another thread to use the corrupted function pointer
- Stack pivot, short ropchain to call
system(...)rcxhappens to be pointing into the corrupted QtCore data section, anlea rsp, [rcx+0x30] ; retgadget kicks off the ropchain
- Providing the string
open -a Calculatortosystem(...)is sufficient to pop calc
- Stack pivot, short ropchain to call
Some of these terms need explaining:
- A base address is where a program or library is loaded in memory; once you know it, you can work out the address of anything inside it by adding a fixed offset.
- A function pointer is a variable that holds the address of a function, so the program can call it later. Overwriting one is a classic way to redirect execution.
- Spraying means creating many objects of the same kind to make memory predictable, then freeing them to leave useful leftovers.
- A non-canonical address is an address that is not valid on the CPU (on 64-bit x86, addresses must have a particular shape); using one guarantees a fault.
- A stack pivot is a technique that changes the stack pointer to point at attacker-controlled data, so that a ROP chain can run. ROP (Return-Oriented Programming) is a way to build a program out of small existing code fragments called gadgets, each ending in a
retinstruction. lea rsp, [rcx+0x30] ; retis a gadget:lealoads an address into a register, here setting the stack pointerrspto 0x30 bytes past whateverrcxpoints at;retthen returns, which starts running the chain placed there.system(...)is a C function that runs a shell command.open -a Calculatoris a macOS command that launches the Calculator app.
Roughly, the steps described above which make up the final exploit are illustrated by the following animation:
A less dramatic video of the successful exploit entry running live is available on ZDI's day two stream of Pwn2Own 2021. The full exploit code can be found here on GitHub.
Root cause
Three distinct bugs are chained.
Bug 1 (megasmash). The OTG proxy takes a size from a guest-controlled header and passes it to the QByteArray constructor. In QtCore, Data::allocate(uint(size) + 1u) overflows when size is 0xffffffff: uint(size) + 1u becomes 0, and allocate returns the qt_array_empty singleton in QtCore's data section instead of a real allocation. The QByteArray is then treated as if it had size 0xffffffff, and the flattening loop copies guest buffers into it, producing memcpy(QtCore_data_section, controlled_data, 0xffffffff). The copy is guaranteed to fault once it reaches a read-only mapping after the writable data segment.
Bug 2 (info leak). The handler for OTG opcode 10, type 2, resizes the output QByteArray to 0x90 and populates only the first 0x20 bytes. The remaining 0x70 bytes are left uninitialised and are copied out to the guest by the OTG proxy.
Bug 3 (stack buffer overflow). QString::fromUtf16(&blob.qstr, -1) treats the guest string as null-terminated, but there is no check that a null terminator is present within the expected 1024 UTF-16 characters. The 0x74 additional bytes after the input, and potentially whatever is on the stack afterwards, may be interpreted as part of the string. The subsequent memcpy(msg.qstr, qstr.utf16(), 2*qstr.size() + 2) then overflows the local msg structure on the stack, allowing the msg.worker pointer to be corrupted with a controlled value, which is then written to at msg.worker->queued_req = req. That is a write of an uncontrolled value (the req pointer) to an arbitrary location.
Why the defences did not stop it: the report does not describe ASLR, stack canaries or other mitigations being bypassed in detail beyond the use of the info leak to defeat ASLR. The report does not say which other mitigations were present. A stack canary is a secret value placed next to the return address; if a buffer overflow overwrites it, the program notices and stops. The key design weakness that made the megasmash survivable is that prl_vm_app registers a task-level exception port for EXC_BAD_ACCESS, EXC_BAD_INSTRUCTION and EXC_ARITHMETIC, and handles those exceptions on a thread that can itself be made to fault, leaving both the faulting thread and the handler suspended indefinitely rather than killing the process.
Impact
Given privileged code execution in the guest (for example via a kernel module), the exploit obtains code execution in the Parallels application process running on the host system. In the demonstrated case, the payload runs open -a Calculator via system(...), popping calc on the host. The report describes this as a guest-to-host virtualization escape and states that the entry was successful at Pwn2Own 2021 with a $40,000 bounty. CVSS is a standard scoring system for how severe a vulnerability is.
Fix
The bugs used in this exploit were all patched by Parallels version 49187. A patch is an update that fixes a bug.
- Bug #3 (the stack buffer overflow) was patched with a check for a null word in the first 1024 UTF-16 characters
- Bug #2 (the information leak) was patched by calling
bzero(...)after resizing the output array.bzerofills memory with zeros, so no old data is left behind. - Bug #1 (megasmash) was patched by ensuring the size passed to
QByteArrayis non-negative- While potentially a dangerous pattern, Qt stated that the QtCore integer overflow was not a bug in QtCore, instead that it is a misuse of the API to ask to create a structure with negative size. An API (Application Programming Interface) is the set of functions a library offers to programmers.
- Interestingly, at the time, the master branch of QtCore did not exhibit the integer overflow due to a refactor in how the size parameter is passed around. A refactor is a rewrite of code that keeps the same behaviour but changes its structure.
The confusion over whether Qt should actually fix the overflow further delayed the publication of this writeup.
For one reason or another, ZDI opted to drop Parallels from 2022's competition:
RIP Parallels 2021-2021 https://t.co/aThASMwp1P
, Bruno (@bkth_) January 12, 2022
Variants to test
These are ideas for other researchers to try, based on the same patterns:
- Other toolgate handlers. The handler table maps many opcode ranges to classes (
CPTool,CSMTool,CUIEmuHost,CInvSharing,CDesktopUtilitiesHost, and so on). For each, find the vtable (for examplevtable for 'CDragAndDropBase') and reverse the virtual handler function. A positive result is a handler that copies guest-controlled data into a fixed-size buffer or uses a guest-supplied length without validation. - Other OTG opcodes behind
Tg2OtgImpl. The proxy flattens buffers according to a header size and dispatches on an OTG opcode at offset 0. Try other OTG opcodes and other settings types for the opcode 10 handler. A positive result is another handler that resizes an output buffer and leaves part of it uninitialised, or that trusts a length field. - Null-termination assumptions. Look for other uses of
QString::fromUtf16(..., -1)or similar APIs on guest input where the buffer is not guaranteed to contain a terminator within its declared length. A positive result is a string whose length exceeds the declared field size and overflows a destination. - Exception port handling. On other macOS applications that register task-level exception ports, check whether the handler thread can be made to fault. A positive result is a process that survives a faulting thread because the exception handler is itself suspended, leaving corrupted state usable by other threads.
- Wild copy survival. For other unbounded copies, look for a mechanism that keeps the faulting thread alive (exception ports, signal handlers, a supervisor) and for another thread that uses the corrupted data. A positive result is a corrupted data section that is consumed by a different thread after the copy faults.
- Integer overflow in allocation size. Look for
uint(size) + 1ustyle arithmetic where a negative size wraps to zero and returns a shared empty singleton. A positive result is a structure that reports a huge size while pointing at a small or empty allocation.
Glossary
- API: Application Programming Interface; the set of functions a library or service offers to programmers.
- ASLR: Address Space Layout Randomisation; a defence that loads programs and libraries at random addresses each run.
- Array: A numbered list of items stored one after another in memory.
- Attack surface: All the places where an outsider can send data into a program.
- Backtrace: The list of function calls that led to the current point in a running program.
- Base address: Where a program or library is loaded in memory.
- Binary: A compiled program file.
- Bitfield: A way to pack several small values into a single number using a specified number of bits each.
- Bitwise AND: An operation that compares bits one by one and keeps only positions where both are 1;
& 0xfffkeeps the lowest 12 bits. - Blob: A chunk of bytes with no particular meaning to the reader.
- Bounty: A cash reward paid for finding and demonstrating a security flaw.
- Breakpoint: A marker that tells a debugger to pause a program at a particular point.
- Buffer: A fixed-size area of memory used to hold data.
- Byte: 8 bits, the basic unit of data.
- Class: A blueprint in object-oriented programming that bundles data and the functions that work on it.
- Constructor: The function that creates a new object.
- CVSS: A standard scoring system for how severe a vulnerability is.
- Data section: The part of a program's memory that holds global variables and constants set up at start-up.
- Debugger: A tool that lets you pause a running program and inspect it.
- Decompiler: A tool that turns a compiled program back into C-like code.
- Dereference: To read or write the memory a pointer points at.
- Disassembler: A tool that turns a compiled program back into assembly instructions.
- Enum: A named list of related constants.
- Exception: A signal that something unusual happened, such as an illegal memory access.
- Exception port: A mailbox where macOS delivers exception messages.
- Fault: What happens when a program tries to touch memory it is not allowed to.
- Flatten: To join several separate chunks into one continuous block.
- Function pointer: A variable that holds the address of a function.
- Gadget: A short sequence of existing instructions ending in
ret, used to build a ROP chain. - Guest: The virtual machine running inside the host.
- Handle: A reference used later to refer to the same object.
- Header: A small block of data at the start that describes the rest.
- Header file: A file that declares names and numbers used by code.
- Heap: The area of memory used for data created while a program runs.
- Hexadecimal: A base-16 way of writing numbers, prefixed with
0x. - Host: The real computer that runs the virtual machine.
- Hypervisor: The software that creates and runs virtual machines.
- I/O port: A numbered channel the CPU uses to talk to devices.
- Information leak: A bug that reveals data the attacker should not see.
- Integer overflow: When a number is too big for its storage and wraps around.
- Kernel: The core of the operating system, with the highest privilege.
- Kernel module: A piece of code that plugs into the kernel to add a feature.
- lldb: A debugger commonly used on macOS.
- Mach: The core of macOS's operating system design.
- Mach-O: The file format macOS uses for programs.
- memcpy: A standard C function that copies bytes from one place to another.
- Null terminator: A zero byte that marks the end of a string.
- Opcode: A number that says which operation is being requested.
- Page: A fixed-size block of memory (commonly 4096 bytes) managed as a unit.
- Page fault: The CPU's way of saying a memory access is not allowed.
- Page frame number: The identifier of a physical page.
- Parse: To read structured data and make sense of its fields.
- Patch: An update that fixes a bug.
- Physical address: The actual location of data in the machine's memory chips.
- Process: A running program.
- Protocol: An agreed way of exchanging messages.
- Proxy: A middleman that passes requests from one side to another.
- Pwn2Own: A yearly contest where researchers try to break into well-known software.
- Queue: A line of items waiting to be processed, first in, first out.
- Race: Two threads acting at the same time, where the outcome depends on who wins.
- Read-only mapping: A region of memory the program may read but not write.
- Refactor: A rewrite of code that keeps the same behaviour but changes its structure.
- Request structure: A block of data laid out in a defined order, like a form with fixed fields.
- Return address: The place the program jumps back to when a function finishes.
- Reverse engineering: Working out what a compiled program does, usually without source code.
- ROP (Return-Oriented Programming): Building a program out of small existing code fragments called gadgets.
- Singleton: A single shared instance used everywhere.
- Slot: One position in an array.
- Source code: The human-readable text a program is written in.
- Spraying: Creating many objects of the same kind to make memory predictable.
- Stack: The area of memory used for local variables and function bookkeeping.
- Stack buffer overflow: Writing more data into a fixed-size buffer on the stack than it can hold.
- Stack canary: A secret value placed next to the return address to detect overflows.
- Stack pivot: Changing the stack pointer to point at attacker-controlled data.
- Struct: A bundle of named fields stored together in memory.
- Suspended: Paused, not running.
- Switch-case: A programming construct that picks one branch based on a value.
- Task: On macOS, roughly what most people call a process.
- Thread: A unit of work inside a process.
- Toolgate: Parallels' name for the channel through which the guest asks the host to do something.
- Uninitialised: Memory that still contains whatever was there before, not zeros.
- Virtual address: The address a program sees, translated by the operating system to a physical address.
- Virtual CPU: The pretend processor the guest sees.
- Virtual machine (VM): A computer running inside another computer.
- Virtualization: Running one computer system inside another.
- Virtual call: A function call resolved at runtime based on the object's actual type.
- vtable: A hidden list of function addresses a class uses for virtual methods.
- Watchpoint: A breakpoint for memory: pauses the program when a location is read or written.
- Wild copy: An unbounded copy that runs far past its intended destination.
- .text section: The part of a program that holds its executable code.