In this post, we will discuss a recent vulnerability discovered in Xenstore, affecting the Xenstored service. The vulnerability allows attackers to crash the Xenstored process by exploiting the stack exhaustion issue. We will dive deep into the problem, discuss the affected components, and provide a code snippet, original references, and an overview of the exploit. The vulnerability is identified by the Common Vulnerabilities and Exposures (CVE) code CVE-2022-42321.


Xenstored is a critical process in the Xen Project's hypervisor, responsible for managing communication between the Xen domain and its guests (also known as virtual machines). Xenstored allows guests to store configuration data and coordinates with host resources. Crucially, Xenstored must remain available for guests to continue functioning correctly.

The Vulnerability

In some Xenstore operations, such as deleting a sub-tree of Xenstore nodes, Xenstored relies on recursion. When guests create a deeply nested hierarchy of nodes in the Xenstore, the stack can become exhausted, leading to Xenstored crashing. As a result, the host's functionality, including the guests' virtual machines, can be severely impacted. The vulnerability is identified as CVE-2022-42321.

The vulnerability occurs because attackers can create Xenstore nodes with a large number of children or a deep hierarchy while deleting them recursively. Xenstored, upon processing these nodes, will be forced to consume stack space until no more space is available, causing it to crash.

Code Snippet

Let's look at an example of how the recursion in the delete operation exhausts the stack of Xenstored:

int delete_subtree(Node *node) {
    // Loop through all the children of the current node
    for (int i=; i < node->num_children; i++) {
        // Delete all the children's sub-tree

    // Delete the current node
    return ;

In the code above, the delete_subtree function is called recursively to delete all nodes in the subtree. Each time the function is invoked, a new stack frame is created, consuming more stack memory. For a sufficiently deep or large tree, the stack space will be exhausted and cause Xenstored to crash.

Exploit Details

An attacker can exploit this vulnerability by creating a guest VM and then proceeding to create a large or deep hierarchy of Xenstore nodes. Once the nested structure has been created, they can initiate a delete operation, which causes Xenstored to enter a recursive loop leading to stack exhaustion and eventually crashing the Xenstored process.


The Xen Project team has already addressed this issue in the latest version of the Xen hypervisor. You can find the patch on their public repository here: Xen Commit

To protect your system from this vulnerability, you should update your Xen hypervisor installation to the latest version or apply the patch linked above. While patching your system, consider reviewing any related Xenstore configuration settings to ensure they follow best practices for security.


- CVE-2022-42321 - XenStore Vulnerability Advisory
- Xen Commit - Fixing Stack Exhaustion


CVE-2022-42321 represents a severe vulnerability in the Xenstored component of the Xen hypervisor, allowing an attacker to crash the Xenstored process. This post has outlined the technical specifics of the issue, including the affected components, a code snippet illustrating the problem, and an overview of the exploit. The patch for this vulnerability is already available, and users are encouraged to update their systems to mitigate the risk.


Published on: 11/01/2022 13:15:00 UTC
Last modified on: 11/03/2022 14:40:00 UTC