GHSL-2021-088_093: Code execution outside the virtualized guest in bhyve - CVE-2021-29631
Several bhyve virtio device emulation functions failed to check the return value of vq_getchain, leading to use of uninitialized iovec structures. A malicious guest could trigger these bugs to crash the host (denial of service) and potentially cause memory corruption.
Originally disclosed on GitHub Security Lab
A malicious guest can trigger vulnerabilities in the host by abusing certain drivers that may lead to code execution outside the virtualized guest.
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.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the functions call vq_getchain without checking its return value, so when it fails the iovec array remains uninitialized and is then used.
Impact
A malicious guest could crash the host (denial of service) and, under certain circumstances, may cause memory corruption.
What the attacker needed
Ability to run a guest VM with bhyve; guest configured with a vulnerable virtio device
The fix
The issues were fixed by the maintainers.
How it was found
- Boot a guest with the vtrnd device enabled.
- Select a virtio queue and set its page frame number.
- Set the available ring index to a value that satisfies vq_has_descs.
- Notify the device to trigger pci_vtrnd_notify and vq_getchain.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
bhyve is a hypervisor that runs virtual machines. The guest (the VM) can send requests to emulated devices like a random number generator. If the host code doesn't properly check the guest's input, it can use uninitialized memory, which may crash the host or corrupt memory.
What is Memory corruption?
Native code reads or writes memory it should not: overflows, use-after-free, type confusion. The core of browser, kernel and parser bugs.