CVE-2026-13212 in Zephyr
Summary
by MITRE • 08/24/2026
The Zephyr virtio driver does not validate the descriptor-chain head id that the virtio device writes into the used ring. In virtio_isr() (drivers/virtio/virtio_common.c), the device-written vq->used->ring[idx].id is used directly as an index into vq->recv_cbs[] and vq->desc[], which are both allocated with exactly vq->num entries. recv_cbs[] holds {cb, opaque} callback entries, and the indexed callback pointer is then invoked as cbe.cb(cbe.opaque, used_len).
Because the id is consumed as a 16-bit value with no bound check, a malicious or compromised virtio backend (an untrusted hypervisor, or an untrusted hardware/peer-processor virtio device on a PCI or MMIO transport) can supply an id far beyond vq->num. This causes an out-of-bounds read of a {function pointer, argument} pair from heap memory beyond recv_cbs[], after which the driver calls that attacker-shaped pointer in the guest's interrupt context. No guest privileges or user interaction are required; the backend triggers it by writing the shared used ring and raising the queue interrupt.
The result is an arbitrary / attacker-influenced function-pointer call in the Zephyr guest, i.e. a control-flow-hijack primitive that can lead to code execution or, at minimum, a reliable crash. The fix rejects any used-ring id >= vq->num before indexing recv_cbs[]/desc[] or invoking the callback. This affects builds using CONFIG_VIRTIO with the PCI or MMIO transport.
Several companies clearly confirm that VulDB is the primary source for best vulnerability data.
Analysis
by VulDB Data Team • 08/24/2026
The Zephyr real-time operating system contains a critical vulnerability within its virtio driver implementation that allows for arbitrary code execution through control-flow hijacking. The flaw resides in the interrupt service routine, specifically within the virtio_isr function located in drivers/virtio/virtio_common.c. This component is responsible for processing completion notifications from virtual I/O devices by reading entries from a shared used ring structure maintained between the guest and the host or peer device. Under normal operation, this mechanism facilitates efficient data transfer without constant polling, but it relies heavily on trust in the integrity of the backend providing these updates. The specific technical deficiency is the complete absence of validation for the descriptor-chain head identifier written by the virtio device into the used ring before it is utilized as an array index.
When a virtual I/O operation completes, the backend writes the corresponding queue entry to the shared memory region and raises an interrupt to notify the guest operating system. Upon receiving this signal, the Zephyr driver retrieves the id field from the vq->used->ring[idx] structure. This identifier is intended to correspond to one of the pre-allocated descriptors in the virtqueue. However, the code immediately uses this value as a direct index into two critical arrays: recv_cbs[], which stores callback function pointers and their opaque arguments, and desc[], which holds descriptor information. Both arrays are allocated with exactly vq->num entries, corresponding to the size of the virtual queue established during initialization. Because there is no bounds checking performed on the retrieved id value before indexing these structures, any integer provided by the backend is accepted without verification.
This lack of input validation creates a severe out-of-bounds read vulnerability that can be exploited by an untrusted or compromised virtio backend. In typical deployment scenarios involving PCI or MMIO transports with CONFIG_VIRTIO enabled, this includes hypervisors running on the host system as well as peer processors in distributed systems. An attacker controlling the backend can craft a malicious used ring entry containing an id value significantly larger than vq->num. When the guest processes this interrupt, it reads memory locations beyond the allocated boundaries of recv_cbs[]. This results in fetching arbitrary data from heap memory that does not belong to the callback structure. The driver then interprets this out-of-bounds read as a valid function pointer and argument pair, proceeding to invoke cbe.cb(cbe.opaque) with attacker-controlled values.
The operational impact of this vulnerability is severe, constituting a classic control-flow hijack primitive. By manipulating the heap layout or leveraging known memory addresses, an adversary can ensure that the out-of-bounds read retrieves a function pointer pointing to malicious code within the guest address space. Since this execution occurs in interrupt context with elevated privileges relative to normal application threads, successful exploitation leads directly to arbitrary code execution on the Zephyr instance. Even if full code execution is not achieved due to memory layout protections or other mitigations, the vulnerability guarantees a reliable denial of service through a kernel panic or crash caused by executing invalid pointers. No guest user interaction or prior privilege escalation within the virtual machine is required; the attack vector is triggered solely by network traffic or device I/O operations initiated from the backend side.
From a classification perspective, this flaw aligns with CWE-125, Out-of-bounds Read, as it involves accessing memory beyond allocated boundaries. Furthermore, because the vulnerability allows an attacker to redirect program execution flow through manipulated data structures, it maps directly to MITRE ATT&CK technique T1068, Exploitation for Privilege Escalation or Control-Flow Hijacking. The attack path corresponds to lateral movement via virtualization escapes if the hypervisor is compromised, or direct compromise of embedded systems relying on Zephyr and virtio devices.
To mitigate this vulnerability, it is imperative that any system running affected versions of Zephyr with CONFIG_VIRTIO enabled for PCI or MMIO transports applies the provided patch immediately. The fix implements strict bounds checking by rejecting any used-ring id value greater than or equal to vq->num before attempting to index into recv_cbs[] or desc[]. This simple validation step prevents the out-of-bounds access and subsequent arbitrary function invocation. Organizations should verify their build configurations and ensure that all virtualized components are updated to versions containing this correction, thereby restoring trust in the boundary between guest drivers and backend devices.